1 | unit UCDCustomize;
|
---|
2 |
|
---|
3 | {$mode Delphi}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
---|
9 | ComCtrls, StdCtrls, Spin, UCDLayout, UCDCommon, UCDManager;
|
---|
10 |
|
---|
11 | type
|
---|
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 |
|
---|
63 | implementation
|
---|
64 |
|
---|
65 | uses
|
---|
66 | UCDClient, UCDMaster;
|
---|
67 |
|
---|
68 | resourcestring
|
---|
69 | SNewLayout = 'New Layout';
|
---|
70 | SEnterNewName = 'Enter new name';
|
---|
71 |
|
---|
72 | { TCDCustomizeForm }
|
---|
73 |
|
---|
74 | procedure TCDCustomizeForm.ButtonCloseClick(Sender: TObject);
|
---|
75 | begin
|
---|
76 | Close;
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TCDCustomizeForm.ButtonLayoutApplyClick(Sender: TObject);
|
---|
80 | begin
|
---|
81 | if ListBox1.ItemIndex <> - 1 then
|
---|
82 | TCDLayout(LayoutList.Items[ListBox1.ItemIndex]).Restore;
|
---|
83 | end;
|
---|
84 |
|
---|
85 | procedure TCDCustomizeForm.ButtonLayoutDeleteClick(Sender: TObject);
|
---|
86 | begin
|
---|
87 | if ListBox1.ItemIndex <> - 1 then begin
|
---|
88 | LayoutList.Items.Delete(ListBox1.ItemIndex);
|
---|
89 | LayoutList.PopulateStringList(ListBox1.Items);
|
---|
90 | end;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TCDCustomizeForm.ButtonLayoutNewClick(Sender: TObject);
|
---|
94 | var
|
---|
95 | NewLayout: TCDLayout;
|
---|
96 | NewName: string;
|
---|
97 | begin
|
---|
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;
|
---|
107 | end;
|
---|
108 |
|
---|
109 | procedure TCDCustomizeForm.ButtonLayoutRenameClick(Sender: TObject);
|
---|
110 | var
|
---|
111 | NewName: string;
|
---|
112 | begin
|
---|
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;
|
---|
118 | end;
|
---|
119 |
|
---|
120 | procedure TCDCustomizeForm.FormShow(Sender: TObject);
|
---|
121 | begin
|
---|
122 | if Assigned(LayoutList) then begin
|
---|
123 | LayoutList.PopulateStringList(ListBox1.Items);
|
---|
124 | end;
|
---|
125 | end;
|
---|
126 |
|
---|
127 | procedure TCDCustomizeForm.ListBox1SelectionChange(Sender: TObject;
|
---|
128 | User: boolean);
|
---|
129 | begin
|
---|
130 | ButtonLayoutRename.Enabled := ListBox1.ItemIndex <> -1;
|
---|
131 | ButtonLayoutDelete.Enabled := ListBox1.ItemIndex <> -1;
|
---|
132 | ButtonLayoutApply.Enabled := ListBox1.ItemIndex <> -1;
|
---|
133 | ButtonLayoutSave.Enabled := ListBox1.ItemIndex <> -1;
|
---|
134 | end;
|
---|
135 |
|
---|
136 |
|
---|
137 | { TCDCustomize }
|
---|
138 |
|
---|
139 | procedure TCDCustomize.SetLayoutList(const AValue: TCDLayoutList);
|
---|
140 | begin
|
---|
141 | if FLayoutList=AValue then exit;
|
---|
142 | FLayoutList:=AValue;
|
---|
143 | end;
|
---|
144 |
|
---|
145 | function TCDCustomize.Execute: Boolean;
|
---|
146 | begin
|
---|
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;
|
---|
162 | end;
|
---|
163 |
|
---|
164 | constructor TCDCustomize.Create(AOwner: TComponent);
|
---|
165 | begin
|
---|
166 | inherited Create(AOwner);
|
---|
167 | end;
|
---|
168 |
|
---|
169 | destructor TCDCustomize.Destroy;
|
---|
170 | begin
|
---|
171 | Master := nil;
|
---|
172 | inherited Destroy;
|
---|
173 | end;
|
---|
174 |
|
---|
175 |
|
---|
176 | initialization
|
---|
177 | {$I UCDCustomize.lrs}
|
---|
178 |
|
---|
179 | end.
|
---|
180 |
|
---|