-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExtColEd.pas
276 lines (245 loc) · 7.25 KB
/
ExtColEd.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
unit ExtColEd;
(******************************************************************************
*
* Description : A Property Editor for the TdfsExtListColumns class
*
* Author : Mike Lindre
* Edited for use with TdfsExtListView v3.00 with Delphi 2 by Brad Stowers
*
*
******************************************************************************)
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtListView, {$IFDEF DFS_NO_DSGNINTF}
DesignIntf,
DesignEditors
{$ELSE}
DsgnIntf
{$ENDIF};
type
TfrmExtListColumns = class(TForm)
btnOk: TButton;
btnCancel: TButton;
GroupBox2: TGroupBox;
Label1: TLabel;
edtImageIndex: TEdit;
GroupBox3: TGroupBox;
lbColumns: TListBox;
btnNew: TButton;
btnDelete: TButton;
cmbAlignment: TComboBox;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure btnNewClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure lbColumnsClick(Sender: TObject);
procedure edtImageIndexChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure cmbAlignmentChange(Sender: TObject);
private
{ Private declarations }
Updating: Boolean;
FColumns: TdfsExtListColumns;
// Str: TStrings;
function GetExtColumns: TdfsExtListColumns;
procedure SetExtColumns(Value: TdfsExtListColumns);
procedure RefreshList;
procedure BeginUpdate;
procedure EndUpdate;
procedure UpdateComboBox;
public
{ Public declarations }
property ExtColumns: TdfsExtListColumns read GetExtColumns write SetExtColumns;
end;
{The TClassProperty object is the default property editor for all
properties which are themselves objects. Users cannot modify object-type
properties directly, but the editor displays the name of the object type,
and allows editing of the object's properties as subproperties of the property.}
{This is the Animation Property Class
Edit - Will Copy the Current TListColBitMaps Object in the Component
and display it in an Editor.
This Editor will allow the Object to be replaced or cleared
GetAttributes - Select and Edit TFrame Object only using
a dialog box
}
TdfsExtListColumnsProperty = class(TClassProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
implementation
{$R *.DFM}
uses ComCtrls,CommCtrl;
Const
STR_LEFT_JUST = 0;
STR_RIGHT_JUST = 1;
ALIGN_STRS : array[STR_LEFT_JUST..STR_RIGHT_JUST] of string =
('Left of Text','Right of Text');
{ TdfsExtListColumnsProperty}
procedure TdfsExtListColumnsProperty.Edit;
var
frmExtListColumns: TfrmExtListColumns;
AListColumns: TdfsExtListColumns;
begin
AListColumns := TdfsExtListColumns(GetOrdValue);
frmExtListColumns := TfrmExtListColumns.Create(Application);
try
frmExtListColumns.ExtColumns := AListColumns;
frmExtListColumns.ShowModal;
{If OK is pressed re-Copy the Object from the Editor to the Component}
If frmExtListColumns.ModalResult = mrOK then
begin
AListColumns.Assign(frmExtListColumns.ExtColumns);
Modified;
end;
finally
frmExtListColumns.Free;
end;
end;
function TdfsExtListColumnsProperty.GetAttributes: TPropertyAttributes;
begin
{The property Can only be Edited using a Dialog}
Result := [paDialog];
end;
procedure TfrmExtListColumns.FormCreate(Sender: TObject);
begin
FColumns := TdfsExtListColumns.Create(nil);
Updating := False;
end;
procedure TfrmExtListColumns.FormDestroy(Sender: TObject);
begin
FColumns.Free;
end;
function TfrmExtListColumns.GetExtColumns:TdfsExtListColumns;
begin
Result := FColumns;
end;
procedure TfrmExtListColumns.SetExtColumns(Value:TdfsExtListColumns);
begin
FColumns.Assign(Value);
RefreshList;
end;
procedure TfrmExtListColumns.RefreshList;
var
Count: integer;
Align, Space:String;
begin
lbColumns.Items.Clear;
for Count := 0 to FColumns.Count - 1 do
begin
if FColumns[Count].ImageIndex <> -1 then
begin
if FColumns[Count].ImageAlignment = ciaLeftOfText then
Align := ALIGN_STRS[STR_LEFT_JUST]
else
Align := ALIGN_STRS[STR_RIGHT_JUST];
if FColumns[Count].ImageIndex > 9 then
Space := ' '
else
Space := ' ';
lbColumns.Items.Add(IntToStr(Count) + ' - ' + 'Image Index No: ' +
IntToStr(FColumns[Count].ImageIndex) + Space + 'Align: ' + Align);
end else
lbColumns.Items.Add(IntToStr(Count) + ' - ' + 'No Image');
end;
end;
procedure TfrmExtListColumns.btnNewClick(Sender: TObject);
begin
FColumns.Add;
RefreshList;
SendMessage(lbColumns.Handle,LB_SETCURSEL,lbColumns.Items.Count-1,0);
lbColumnsClick(nil);
end;
procedure TfrmExtListColumns.btnDeleteClick(Sender: TObject);
begin
if lbColumns.ItemIndex <> -1 then
begin
FColumns[lbColumns.ItemIndex].Free;
RefreshList;
SendMessage(lbColumns.Handle,LB_SETCURSEL,lbColumns.Items.Count-1,0);
lbColumnsClick(nil);
end;
end;
procedure TfrmExtListColumns.lbColumnsClick(Sender: TObject);
begin
BeginUpdate;
try
if lbColumns.ItemIndex <> -1 then
begin
edtImageIndex.Text := InttoStr(FColumns[lbColumns.ItemIndex].ImageIndex);
UpdateComboBox;
end;
finally
EndUpdate;
end;
end;
procedure TfrmExtListColumns.UpdateComboBox;
begin
if FColumns[lbColumns.ItemIndex].ImageIndex = -1 then
begin
cmbAlignment.Enabled := False;
SendMessage(cmbAlignment.Handle,CB_SETCURSEL,0,0);
end else begin
cmbAlignment.Enabled := True;
SendMessage(cmbAlignment.Handle,CB_SETCURSEL,
longint(FColumns[lbColumns.ItemIndex].ImageAlignment),0);
end;
end;
procedure TfrmExtListColumns.edtImageIndexChange(Sender: TObject);
var
X, Index: Integer;
begin
if not Updating and (lbColumns.ItemIndex <> -1) then
begin
try
X := StrToInt(edtImageIndex.Text);
Index := lbColumns.ItemIndex;
FColumns[Index].ImageIndex := X;
RefreshList;
SendMessage(lbColumns.Handle,LB_SETCURSEL,Index,0);
UpdateComboBox;
except
// do nothing
end;
end;
end;
procedure TfrmExtListColumns.BeginUpdate;
begin
Updating := True;
end;
procedure TfrmExtListColumns.EndUpdate;
begin
Updating := False;
end;
procedure TfrmExtListColumns.FormShow(Sender: TObject);
begin
if lbColumns.Items.Count > 0 then
begin
SendMessage(lbColumns.Handle,LB_SETCURSEL,0,0);
lbColumnsClick(nil);
end;
end;
procedure TfrmExtListColumns.cmbAlignmentChange(Sender: TObject);
var
Index: Integer;
Align: TColumnImageAlign;
begin
if not Updating and (lbColumns.ItemIndex <> -1) then
begin
try
if CompareText(cmbAlignment.Text,ALIGN_STRS[STR_LEFT_JUST]) = 0 then
Align := ciaLeftOfText
else
Align := ciaRightOfText;
Index := lbColumns.ItemIndex;
FColumns[Index].ImageAlignment := Align;
RefreshList;
SendMessage(lbColumns.Handle,LB_SETCURSEL,Index,0);
except
// do nothing
end;
end;
end;
end.