source: Docking/CoolDocking/UCDCustomize.pas

Last change on this file was 437, checked in by chronos, 12 years ago
  • Fixed: Better switching tabbed controls.
File size: 4.6 KB
Line 
1unit UCDCustomize;
2
3{$mode delphi}{$H+}
4
5interface
6
7uses
8 Classes, LResources, Forms, Dialogs,
9 ComCtrls, StdCtrls, Spin, UCDLayout, UCDCommon;
10
11type
12
13 { TCDCustomizeForm }
14
15 TCDCustomizeForm = class(TForm)
16 published
17 ButtonLayoutDelete: TButton;
18 ButtonLayoutApply: TButton;
19 ButtonLayoutRename: TButton;
20 ButtonLayoutNew: TButton;
21 ButtonLayoutSave: TButton;
22 ButtonClose: TButton;
23 ComboBox1: TComboBox;
24 ComboBox2: TComboBox;
25 Label1: TLabel;
26 Label2: TLabel;
27 Label3: TLabel;
28 Label4: TLabel;
29 ListBox1: TListBox;
30 PageControl1: TPageControl;
31 SpinEdit1: TSpinEdit;
32 TabSheetSetting: TTabSheet;
33 TabSheetLayouts: TTabSheet;
34 procedure ButtonCloseClick(Sender: TObject);
35 procedure ButtonLayoutApplyClick(Sender: TObject);
36 procedure ButtonLayoutDeleteClick(Sender: TObject);
37 procedure ButtonLayoutNewClick(Sender: TObject);
38 procedure ButtonLayoutRenameClick(Sender: TObject);
39 procedure FormShow(Sender: TObject);
40 procedure ListBox1SelectionChange(Sender: TObject; User: boolean);
41 private
42 { private declarations }
43 public
44 LayoutList: TCDLayoutList;
45 end;
46
47 { TCDCustomize }
48
49 TCDCustomize = class(TCDCustomizeBase)
50 private
51 FLayoutList: TCDLayoutList;
52 Form: TCDCustomizeForm;
53 procedure SetLayoutList(const AValue: TCDLayoutList);
54 public
55 function Execute: Boolean;
56 constructor Create(AOwner: TComponent); override;
57 destructor Destroy; override;
58 published
59 property LayoutList: TCDLayoutList read FLayoutList write SetLayoutList;
60 end;
61
62
63implementation
64
65uses
66 UCDMaster;
67
68resourcestring
69 SNewLayout = 'New Layout';
70 SEnterNewName = 'Enter new name';
71
72{ TCDCustomizeForm }
73
74procedure TCDCustomizeForm.ButtonCloseClick(Sender: TObject);
75begin
76 Close;
77end;
78
79procedure TCDCustomizeForm.ButtonLayoutApplyClick(Sender: TObject);
80begin
81 if ListBox1.ItemIndex <> - 1 then
82 TCDLayout(LayoutList.Items[ListBox1.ItemIndex]).Restore;
83end;
84
85procedure TCDCustomizeForm.ButtonLayoutDeleteClick(Sender: TObject);
86begin
87 if ListBox1.ItemIndex <> - 1 then begin
88 LayoutList.Items.Delete(ListBox1.ItemIndex);
89 LayoutList.PopulateStringList(ListBox1.Items);
90 end;
91end;
92
93procedure TCDCustomizeForm.ButtonLayoutNewClick(Sender: TObject);
94var
95 NewLayout: TCDLayout;
96 NewName: string;
97begin
98 NewName := SNewLayout;
99 if InputQuery(SNewLayout, SEnterNewName, NewName) then
100 if not Assigned(LayoutList.FindByName(NewName)) then begin
101 NewLayout := TCDLayout.Create;
102 NewLayout.Name := NewName;
103 NewLayout.Store;
104 LayoutList.Items.Add(NewLayout);
105 LayoutList.PopulateStringList(ListBox1.Items);
106 end;
107end;
108
109procedure TCDCustomizeForm.ButtonLayoutRenameClick(Sender: TObject);
110var
111 NewName: string;
112begin
113 NewName := TCDLayout(LayoutList.Items[ListBox1.ItemIndex]).Name;
114 if InputQuery(SNewLayout, SEnterNewName, NewName) then begin
115 TCDLayout(LayoutList.Items[ListBox1.ItemIndex]).Name := NewName;
116 LayoutList.PopulateStringList(ListBox1.Items);
117 end;
118end;
119
120procedure TCDCustomizeForm.FormShow(Sender: TObject);
121begin
122 if Assigned(LayoutList) then begin
123 LayoutList.PopulateStringList(ListBox1.Items);
124 end;
125end;
126
127procedure TCDCustomizeForm.ListBox1SelectionChange(Sender: TObject;
128 User: boolean);
129begin
130 ButtonLayoutRename.Enabled := ListBox1.ItemIndex <> -1;
131 ButtonLayoutDelete.Enabled := ListBox1.ItemIndex <> -1;
132 ButtonLayoutApply.Enabled := ListBox1.ItemIndex <> -1;
133 ButtonLayoutSave.Enabled := ListBox1.ItemIndex <> -1;
134end;
135
136
137{ TCDCustomize }
138
139procedure TCDCustomize.SetLayoutList(const AValue: TCDLayoutList);
140begin
141 if FLayoutList=AValue then exit;
142 FLayoutList:=AValue;
143end;
144
145function TCDCustomize.Execute: Boolean;
146begin
147 Form := TCDCustomizeForm.Create(Self);
148 if Assigned(Master) then begin
149 Form.SpinEdit1.Value := TCDMaster(Master).DefaultMoveSpeed;
150 Form.ComboBox1.ItemIndex := Integer(TCDMaster(Master).DefaultTabsPos);
151 Form.ComboBox2.ItemIndex := Integer(TCDMaster(Master).DefaultHeaderPos);
152 Form.LayoutList := FLayoutList;
153 end;
154 Form.ShowModal;
155 if Assigned(Master) then begin
156 TCDMaster(Master).DefaultMoveSpeed := Form.SpinEdit1.Value;
157 TCDMaster(Master).DefaultTabsPos := THeaderPos(Form.ComboBox1.ItemIndex);
158 TCDMaster(Master).DefaultHeaderPos := THeaderPos(Form.ComboBox2.ItemIndex);
159 end;
160 Form.Free;
161 Result := True;
162end;
163
164constructor TCDCustomize.Create(AOwner: TComponent);
165begin
166 inherited Create(AOwner);
167end;
168
169destructor TCDCustomize.Destroy;
170begin
171 Master := nil;
172 inherited Destroy;
173end;
174
175
176initialization
177 {$I UCDCustomize.lrs}
178
179end.
180
Note: See TracBrowser for help on using the repository browser.