diff options
-rw-r--r-- | extras/tiopf/demos/ListControlDemo/frmMain.pas | 19 | ||||
-rw-r--r-- | extras/tiopf/demos/ListControlDemo/listcontroldemo.lpi | 17 | ||||
-rw-r--r-- | extras/tiopf/gui/tiCompositeMediators.pas | 14 | ||||
-rw-r--r-- | extras/tiopf/gui/tiGenericListMediators.pas | 7 |
4 files changed, 38 insertions, 19 deletions
diff --git a/extras/tiopf/demos/ListControlDemo/frmMain.pas b/extras/tiopf/demos/ListControlDemo/frmMain.pas index ddb9d91a..7876ee3c 100644 --- a/extras/tiopf/demos/ListControlDemo/frmMain.pas +++ b/extras/tiopf/demos/ListControlDemo/frmMain.pas @@ -112,19 +112,29 @@ begin end; procedure TMainForm.lbSelectionChanged(Sender: TObject); +var + backup: TNotifyEvent; begin FListBoxMediator.HandleSelectionChanged; { This is only done to keep the ComboBox and ListBox in sync. This would not be done or needed in a real application } + backup := cbPeople.OnChange; + cbPeople.OnChange := nil; cbPeople.FocusItem := lbPeople.FocusItem; + cbpeople.OnChange := backup; end; procedure TMainForm.cbSelectionChanged(Sender: TObject); +var + backup: TNotifyEvent; begin FComboBoxMediator.HandleSelectionChanged; { This is only done to keep the ComboBox and ListBox in sync. This would not be done or needed in a real application } + backup := lbPeople.OnChange; + lbPeople.OnChange := nil; lbPeople.FocusItem := cbPeople.FocusItem; + lbPeople.OnChange := backup; end; procedure TMainForm.chkShowDeletedChange(Sender: TObject); @@ -134,6 +144,8 @@ begin end; procedure TMainForm.InitializeComponents; +var + lbl: TfpgLabel; begin btnClose := CreateButton(self, 416, 370, 75, 'Close', @btnCloseClick); btnClose.ImageName := 'stdimg.Close'; @@ -166,9 +178,10 @@ begin AgeTrackBar.ShowPosition := True; AgeTrackBar.Enabled := False; - CreateLabel(self, edtName.Right + 30, edtName.Top, 'These components observe the ').TextColor := clBlue; - CreateLabel(self, edtName.Right + 30, AgeTrackBar.Top-5, 'selected item of ComboBox').TextColor := clBlue; - + lbl := CreateLabel(self, edtName.Right + 30, edtName.Top, 'These components observe the selected item of ComboBox', 200, AgeTrackBar.Top-5); + lbl.TextColor := clBlue; + lbl.WrapText := True; + cbPeople := TfpgComboBox.Create(self); cbPeople.Top := AgeTrackBar.Bottom + 17; cbPeople.Left := 7; diff --git a/extras/tiopf/demos/ListControlDemo/listcontroldemo.lpi b/extras/tiopf/demos/ListControlDemo/listcontroldemo.lpi index ce2c1eaf..57dc14b8 100644 --- a/extras/tiopf/demos/ListControlDemo/listcontroldemo.lpi +++ b/extras/tiopf/demos/ListControlDemo/listcontroldemo.lpi @@ -1,15 +1,15 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <PathDelim Value="\"/> - <Version Value="5"/> + <PathDelim Value="/"/> + <Version Value="6"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value=".\"/> + <IconPath Value="./"/> <TargetFileExt Value=""/> </General> <VersionInfo> @@ -23,7 +23,7 @@ <RunParams> <local> <FormatVersion Value="1"/> - <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> + <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> </local> </RunParams> <RequiredPackages Count="1"> @@ -44,17 +44,17 @@ <UnitName Value="frmMain"/> </Unit1> <Unit2> - <Filename Value="..\Common\Model_View.pas"/> + <Filename Value="../Common/Model_View.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="Model_View"/> </Unit2> <Unit3> - <Filename Value="..\Common\Constants.pas"/> + <Filename Value="../Common/Constants.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="Constants"/> </Unit3> <Unit4> - <Filename Value="..\Common\Model.pas"/> + <Filename Value="../Common/Model.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="Model"/> </Unit4> @@ -62,9 +62,8 @@ </ProjectOptions> <CompilerOptions> <Version Value="5"/> - <PathDelim Value="\"/> <SearchPaths> - <OtherUnitFiles Value="..\Common\"/> + <OtherUnitFiles Value="../Common/"/> </SearchPaths> <CodeGeneration> <Generate Value="Faster"/> diff --git a/extras/tiopf/gui/tiCompositeMediators.pas b/extras/tiopf/gui/tiCompositeMediators.pas index 4ac4fece..34417aa8 100644 --- a/extras/tiopf/gui/tiCompositeMediators.pas +++ b/extras/tiopf/gui/tiCompositeMediators.pas @@ -24,14 +24,14 @@ type { Composite mediator for TfpgListView } TCompositeListViewMediator = class(TtiObject) private - FIsObserving: Boolean; - FDisplayNames: string; - FShowDeleted: Boolean; function GetSelectedObject: TtiObject; procedure SetSelectedObject(const AValue: TtiObject); procedure SetShowDeleted(const AValue: Boolean); procedure DoCreateItemMediator(AData: TtiObject); protected + FIsObserving: Boolean; + FDisplayNames: string; + FShowDeleted: Boolean; FView: TfpgListView; FModel: TtiObjectList; FMediatorList: TObjectList; @@ -98,7 +98,8 @@ type FModel: TtiObject; FView: TfpgLVItem; FDisplayNames: string; - procedure SetupFields; + protected + procedure SetupFields; virtual; public constructor CreateCustom(AModel: TtiObject; AView: TfpgLVItem; const ADisplayNames: string; IsObserving: Boolean = True); procedure BeforeDestruction; override; @@ -130,6 +131,11 @@ type end; +function tiFieldName(const AField: string): string; +function tiFieldWidth(const AField: string): integer; +function tiFieldCaption(const AField: string): string; + + implementation uses diff --git a/extras/tiopf/gui/tiGenericListMediators.pas b/extras/tiopf/gui/tiGenericListMediators.pas index 52aa60ed..4f15b9d1 100644 --- a/extras/tiopf/gui/tiGenericListMediators.pas +++ b/extras/tiopf/gui/tiGenericListMediators.pas @@ -215,8 +215,8 @@ begin selected := View.FocusItem; end; - ptr := View.OnSelect; - View.OnSelect := nil; + ptr := View.OnChange; + View.OnChange := nil; View.Items.BeginUpdate; try View.Items.Clear; @@ -237,7 +237,7 @@ begin finally View.Items.EndUpdate; view.Update; - View.OnSelect := ptr; + View.OnChange := ptr; HandleSelectionChanged; end; end; @@ -349,6 +349,7 @@ begin end; finally View.Items.EndUpdate; + View.FocusItem := 1; View.OnChange := ptr; HandleSelectionChanged; end; |