1 | unit MultiColumnListBox;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Messages, SysUtils, Classes, Graphics, Forms, Dialogs,
|
---|
7 | StdCtrls, ComCtrls, CustomHeaderControl; // menus for SPCC v2.5+
|
---|
8 |
|
---|
9 | const
|
---|
10 | mclbImageMarker = #11;
|
---|
11 |
|
---|
12 | type
|
---|
13 | TMultiColumnListBox = class(TControl)
|
---|
14 | protected
|
---|
15 | FHeader: TCustomHeaderControl;
|
---|
16 | FLIstBox: TListBox;
|
---|
17 | FImageList: TImageList;
|
---|
18 |
|
---|
19 | FSavedSelectedObject: TObject;
|
---|
20 |
|
---|
21 | FBorderStyle: TBorderStyle;
|
---|
22 | Procedure SetBorderStyle( NewValue: TBorderStyle );
|
---|
23 |
|
---|
24 | function GetHeaderPenColor: TColor;
|
---|
25 | procedure SetHeaderPenColor( NewValue: TColor );
|
---|
26 | function GetListPenColor: TColor;
|
---|
27 | procedure SetListPenColor( NewValue: TColor );
|
---|
28 |
|
---|
29 | function GetEnabled: boolean; //override;
|
---|
30 | function GetExtendedSelect: boolean;
|
---|
31 | function GetHeaderFont: TFont;
|
---|
32 | function GetHeaderHeight: integer;
|
---|
33 | function GetHeaderParentFont: boolean;
|
---|
34 | function GetItemHeight: integer;
|
---|
35 | function GetListFont: TFont;
|
---|
36 | function GetListParentFont: boolean;
|
---|
37 | function GetMultiSelect: boolean;
|
---|
38 | function GetParentColor: boolean;
|
---|
39 | function GetParentShowHint: boolean;
|
---|
40 | function GetThePopupMenu: TPopupMenu;
|
---|
41 | function GetShowHint: boolean;
|
---|
42 | // procedure SetEnabled(NewState:Boolean); override;
|
---|
43 | procedure SetExtendedSelect(const Value: boolean);
|
---|
44 | procedure SetHeaderFont(const Value: TFont);
|
---|
45 | procedure SetHeaderHeight(const Value: integer);
|
---|
46 | procedure SetHeaderParentFont(const Value: boolean);
|
---|
47 | procedure SetItemHeight(const Value: integer);
|
---|
48 | procedure SetListFont(const Value: TFont);
|
---|
49 | procedure SetListParentFont(const Value: boolean);
|
---|
50 | procedure SetMultiSelect(const Value: boolean);
|
---|
51 | procedure SetParentShowHint(const Value: boolean);
|
---|
52 | procedure SetPopupMenu(const Value: TPopupMenu);
|
---|
53 | procedure SetShowHint(const Value: boolean);
|
---|
54 | procedure SetSelectedObject(const Value: TObject);
|
---|
55 | function GetOnClick: TNotifyEvent;
|
---|
56 | procedure SetOnClick(const Value: TNotifyEvent);
|
---|
57 | function GetOnDblClick: TNotifyEvent;
|
---|
58 | procedure SetOnDblClick(const Value: TNotifyEvent);
|
---|
59 | procedure SetSelectedItem(const Value: string);
|
---|
60 | function GetTopObject: TObject;
|
---|
61 | procedure SetTopObject(const Value: TObject);
|
---|
62 |
|
---|
63 | function GetItems: TStrings;
|
---|
64 | procedure SetItems( Items: TStrings );
|
---|
65 | function GetHeaderSections: TCustomHeaderSections;
|
---|
66 | procedure SetHeaderSections( Sections: TCustomHeaderSections );
|
---|
67 | function GetSelectedItem: string;
|
---|
68 | function GetSelectedObject: TObject;
|
---|
69 | function GetItemIndex: integer;
|
---|
70 | procedure SetItemIndex( const Value: integer );
|
---|
71 | procedure SetImageList( ImageList: TImageList );
|
---|
72 | procedure Notification( AComponent: TComponent;
|
---|
73 | Operation: TOperation); override;
|
---|
74 |
|
---|
75 | procedure SetOnItemFocus( Value: TItemFocusEvent );
|
---|
76 | function GetOnItemFocus: TItemFocusEvent;
|
---|
77 | function GetOnItemSelect: TItemSelectEvent;
|
---|
78 | procedure SetOnItemSelect( Value: TItemSelectEvent );
|
---|
79 |
|
---|
80 | function GetOnEnter: TNotifyEvent;
|
---|
81 | procedure SetOnEnter( Value: TNotifyEvent );
|
---|
82 | function GetOnExit: TNotifyEvent;
|
---|
83 | procedure SetOnExit( Value: TNotifyEvent );
|
---|
84 |
|
---|
85 | procedure SetSelected( Index: longint; Value: boolean );
|
---|
86 | function GetSelected( Index: longint ): boolean;
|
---|
87 |
|
---|
88 | Procedure SetColor(NewColor:TColor); Override;
|
---|
89 |
|
---|
90 | procedure Layout;
|
---|
91 | procedure DrawListBoxItem( Sender: TObject;
|
---|
92 | Index: longint;
|
---|
93 | Rect: TRect;
|
---|
94 | State: TOwnerDrawState );
|
---|
95 | procedure ChangeHeader( HeaderControl: TCustomHeaderControl;
|
---|
96 | Section: TCustomHeaderSection );
|
---|
97 | procedure Resize; override;
|
---|
98 | procedure SetupShow; override;
|
---|
99 | procedure SetupComponent; override;
|
---|
100 |
|
---|
101 | Procedure ReadSCUResource(Const ResName:TResourceName;Var Data;DataLen:LongInt);Override;
|
---|
102 | Function WriteSCUResource(Stream:TResourceStream):Boolean;Override;
|
---|
103 |
|
---|
104 | function GetTabStop:boolean;
|
---|
105 | procedure SetTabStop(Value:boolean);
|
---|
106 |
|
---|
107 | procedure WMFocussing( Var Msg: TMessage ); message WM_FOCUSSING;
|
---|
108 | public
|
---|
109 | destructor Destroy; override;
|
---|
110 |
|
---|
111 | property ItemIndex: integer read GetItemIndex write SetItemIndex;
|
---|
112 | property SelectedItem: string read GetSelectedItem write SetSelectedItem;
|
---|
113 | property SelectedObject: TObject read GetSelectedObject write SetSelectedObject;
|
---|
114 | property TopObject: TObject read GetTopObject write SetTopObject;
|
---|
115 |
|
---|
116 | procedure SetSelectedItemTo( Text: string );
|
---|
117 | property Selected[ Index: longint ]: boolean read GetSelected write SetSelected;
|
---|
118 |
|
---|
119 | property Parent;
|
---|
120 |
|
---|
121 | published
|
---|
122 | property Items: TStrings
|
---|
123 | read GetItems
|
---|
124 | write SetItems;
|
---|
125 | property HeaderColumns: TCustomHeaderSections
|
---|
126 | read GetHeaderSections
|
---|
127 | write SetHeaderSections;
|
---|
128 | property ImageList: TImageList
|
---|
129 | read FImageList
|
---|
130 | write SetImageList;
|
---|
131 |
|
---|
132 | Property BorderStyle:TBorderStyle read FBorderStyle write SetBorderStyle;
|
---|
133 |
|
---|
134 | property ListPenColor: TColor read GetListPenColor write SetListPenColor;
|
---|
135 | property HeaderPenColor: TColor read GetHeaderPenColor write SetHeaderPenColor;
|
---|
136 |
|
---|
137 | property ListFont: TFont read GetListFont write SetListFont;
|
---|
138 | property ListParentFont: boolean read GetListParentFont write SetListParentFont;
|
---|
139 |
|
---|
140 | property HeaderFont: TFont read GetHeaderFont write SetHeaderFont;
|
---|
141 | property HeaderParentFont: boolean read GetHeaderParentFont write SetHeaderParentFont;
|
---|
142 |
|
---|
143 | property ShowHint: boolean read GetShowHint write SetShowHint;
|
---|
144 | property ParentShowHint: boolean read GetParentShowHint write SetParentShowHint;
|
---|
145 |
|
---|
146 | property PopupMenu: TPopupMenu read GetThePopupMenu write SetPopupMenu;
|
---|
147 |
|
---|
148 | property HeaderHeight: integer read GetHeaderHeight write SetHeaderHeight;
|
---|
149 | property ItemHeight: integer read GetItemHeight write SetItemHeight;
|
---|
150 |
|
---|
151 | property MultiSelect: boolean read GetMultiSelect write SetMultiSelect;
|
---|
152 | property ExtendedSelect: boolean read GetExtendedSelect write SetExtendedSelect;
|
---|
153 |
|
---|
154 | property Enabled; //: boolean read GetEnabled write SetEnabled;
|
---|
155 |
|
---|
156 | property Align;
|
---|
157 | property Color;
|
---|
158 | property ParentColor;
|
---|
159 | property TabStop: boolean read GetTabStop write SetTabStop;
|
---|
160 | property TabOrder;
|
---|
161 |
|
---|
162 | // Events
|
---|
163 | property OnClick: TNotifyEvent read GetOnClick write SetOnClick;
|
---|
164 | property OnDblClick: TNotifyEvent read GetOnDblClick write SetOnDblClick;
|
---|
165 | property OnItemFocus: TItemFocusEvent read GetOnItemFocus write SetOnItemFocus;
|
---|
166 | property OnItemSelect: TItemSelectEvent read GetOnItemSelect write SetOnItemSelect;
|
---|
167 | property OnEnter: TNotifyEvent read GetOnEnter write SetOnEnter;
|
---|
168 | property OnExit: TNotifyEvent read GetOnExit write SetOnExit;
|
---|
169 | end;
|
---|
170 |
|
---|
171 | exports
|
---|
172 | TMultiColumnListBox, 'User', 'MultiColumnListBox.bmp';
|
---|
173 |
|
---|
174 | implementation
|
---|
175 |
|
---|
176 | uses
|
---|
177 | StringUtilsUnit;
|
---|
178 |
|
---|
179 | { TMultiColumnListBox }
|
---|
180 |
|
---|
181 | procedure TMultiColumnListBox.SetupComponent;
|
---|
182 | var
|
---|
183 | Section: TCustomHeaderSection;
|
---|
184 | begin
|
---|
185 | inherited SetupComponent;
|
---|
186 |
|
---|
187 | Width := 100;
|
---|
188 | Height := 100;
|
---|
189 |
|
---|
190 | ParentCOlor := true;
|
---|
191 |
|
---|
192 | Name := 'MultiColumnListBox';
|
---|
193 |
|
---|
194 | FTabStop := false;
|
---|
195 |
|
---|
196 | FHeader := TCustomHeaderControl.Create( Self );
|
---|
197 | FHeader.Parent := self;
|
---|
198 | FHeader.Height := 22;
|
---|
199 | FHeader.BevelWidth := 1;
|
---|
200 | FHeader.TabStop := false;
|
---|
201 | Include( FHeader.ComponentState, csDetail );
|
---|
202 |
|
---|
203 | // Create a couple of default header sections
|
---|
204 | // so it's obvious that it's there.
|
---|
205 | Section := FHeader.Sections.Add;
|
---|
206 | Section.Text := 'Column 1';
|
---|
207 | Section.AllowClick := false;
|
---|
208 | Section := FHeader.Sections.Add;
|
---|
209 | Section.Text := 'Column 2';
|
---|
210 |
|
---|
211 | FListBox := TListBox.Create( Self );
|
---|
212 | FListBox.Parent := self;
|
---|
213 | // FListBox.ItemHeight := 16;
|
---|
214 |
|
---|
215 | FListBox.Style := lbOwnerDrawFixed;
|
---|
216 |
|
---|
217 | FListBox.OnDrawItem := DrawListBoxItem;
|
---|
218 |
|
---|
219 | FListBox.TabStop := true;
|
---|
220 | Include( FListBox.ComponentState, csDetail );
|
---|
221 | FListBox.ParentColor := true;
|
---|
222 |
|
---|
223 | // FListBox.BorderStyle := bsNone; // we draw it ourselves
|
---|
224 |
|
---|
225 | FHeader.OnSectionResize := ChangeHeader;
|
---|
226 |
|
---|
227 | FImageList := nil;
|
---|
228 |
|
---|
229 | // FAlwaysFocusChild := FListBox;
|
---|
230 |
|
---|
231 | Layout;
|
---|
232 |
|
---|
233 | end;
|
---|
234 |
|
---|
235 | procedure TMultiColumnListBox.SetupShow;
|
---|
236 | begin
|
---|
237 | Layout;
|
---|
238 | end;
|
---|
239 |
|
---|
240 | destructor TMultiColumnListBox.Destroy;
|
---|
241 | begin
|
---|
242 | inherited Destroy;
|
---|
243 | end;
|
---|
244 |
|
---|
245 | Procedure TMultiColumnListBox.ReadSCUResource( Const ResName: TResourceName;
|
---|
246 | Var Data;DataLen: LongInt );
|
---|
247 | begin
|
---|
248 | if ResName = rnHeaders then
|
---|
249 | FHeader.ReadSCUResource( ResName, Data, DataLen )
|
---|
250 | else
|
---|
251 | inherited ReadSCUResource( ResName, Data, DataLen );
|
---|
252 |
|
---|
253 | end;
|
---|
254 |
|
---|
255 | Function TMultiColumnListBox.WriteSCUResource( Stream: TResourceStream ): Boolean;
|
---|
256 | begin
|
---|
257 | Result := Inherited WriteSCUResource(Stream);
|
---|
258 | If Not Result Then
|
---|
259 | Exit;
|
---|
260 | FHeader.WriteScuResource( Stream );
|
---|
261 | end;
|
---|
262 |
|
---|
263 | procedure TMultiColumnListBox.WMFocussing( Var Msg: TMessage );
|
---|
264 | begin
|
---|
265 | // focus listbox instead
|
---|
266 | Msg.Result := LONGWORD( FListBox );
|
---|
267 | msg.Handled := true;
|
---|
268 | end;
|
---|
269 |
|
---|
270 | function TMultiColumnListBox.GetTabStop:boolean;
|
---|
271 | begin
|
---|
272 | result:=FListBox.TabStop;
|
---|
273 | end;
|
---|
274 |
|
---|
275 | procedure TMultiColumnListBox.SetTabStop(Value:boolean);
|
---|
276 | begin
|
---|
277 | FListBox.TabStop:=Value;
|
---|
278 | end;
|
---|
279 |
|
---|
280 | procedure TMultiColumnListBox.DrawListBoxItem( Sender: TObject;
|
---|
281 | Index: longint;
|
---|
282 | Rect: TRect;
|
---|
283 | State: TOwnerDrawState );
|
---|
284 | var
|
---|
285 | ColumnIndex: integer;
|
---|
286 | X: integer;
|
---|
287 | ItemToDraw: string;
|
---|
288 | Line: string;
|
---|
289 | BitmapIndex: integer;
|
---|
290 | ColumnWidth: integer;
|
---|
291 | ItemRect: TRect;
|
---|
292 | Dest: TRect;
|
---|
293 | LineClipRect: TRect;
|
---|
294 | tmpColumns : TStringList;
|
---|
295 | i : longint;
|
---|
296 | begin
|
---|
297 | LineClipRect := FListBox.Canvas.ClipRect;
|
---|
298 |
|
---|
299 | ColumnIndex := 0;
|
---|
300 |
|
---|
301 | Dest := rect;
|
---|
302 | dec( Dest.top ); // minor adjustments since we seem to get a slightly
|
---|
303 | inc( Dest.left ); // incorrect area to draw on...
|
---|
304 |
|
---|
305 | X := Dest.Left;
|
---|
306 | Line := FListBox.Items[ Index ];
|
---|
307 |
|
---|
308 | with FListBox.Canvas do
|
---|
309 | begin
|
---|
310 | Pen.Color := FListBox.PenColor;
|
---|
311 | Brush.Color := FListBox.Color;
|
---|
312 | IF State * [odSelected] <> [] THEN
|
---|
313 | begin
|
---|
314 | Brush.Color := clHighLight;
|
---|
315 | Pen.Color := Color;
|
---|
316 | end;
|
---|
317 |
|
---|
318 | FillRect( Dest, Brush.Color );
|
---|
319 | end;
|
---|
320 |
|
---|
321 | tmpColumns := TStringList.Create;
|
---|
322 | StrExtractStrings(tmpColumns, Line, [#9], #0);
|
---|
323 |
|
---|
324 | for i := 0 to tmpColumns.Count - 1 do
|
---|
325 | begin
|
---|
326 | ItemToDraw := tmpColumns[i];
|
---|
327 | if ColumnIndex < FHeader.Sections.Count then
|
---|
328 | ColumnWidth := FHeader.Sections[ ColumnIndex ].Width
|
---|
329 | else
|
---|
330 | ColumnWidth := 50;
|
---|
331 |
|
---|
332 | ItemRect := Dest;
|
---|
333 | ItemRect.Left := X;
|
---|
334 | ItemRect.Right := X + ColumnWidth - 2;
|
---|
335 | FListBox.Canvas.ClipRect := IntersectRect( LineClipRect,
|
---|
336 | ItemRect );
|
---|
337 |
|
---|
338 | if StrLeft( ItemToDraw, 1 ) = mclbImageMarker then
|
---|
339 | begin
|
---|
340 | Delete( ItemToDraw, 1, 1 );
|
---|
341 | try
|
---|
342 | BitmapIndex := StrToInt( ItemToDraw );
|
---|
343 | except
|
---|
344 | BitmapIndex := -1;
|
---|
345 | end;
|
---|
346 | if Assigned( FImageList ) then
|
---|
347 | if ( BitmapIndex >= 0 )
|
---|
348 | and ( BitmapIndex < FImageList.Count ) then
|
---|
349 | begin
|
---|
350 | FImageList.Draw( FListBox.Canvas,
|
---|
351 | X, Dest.Bottom,
|
---|
352 | BitmapIndex );
|
---|
353 | end
|
---|
354 | else
|
---|
355 | begin
|
---|
356 | tmpColumns.Destroy;
|
---|
357 | raise Exception.Create( 'Bitmap index out of range in MultiColumnListBox' )
|
---|
358 | end
|
---|
359 | else
|
---|
360 | begin
|
---|
361 | tmpColumns.Destroy;
|
---|
362 | raise Exception.Create( 'No imagelist assigned in MultiColumnListBox' );
|
---|
363 | end
|
---|
364 | end
|
---|
365 | else
|
---|
366 | begin
|
---|
367 | FListBox.Canvas.TextOut( X, Dest.Bottom,
|
---|
368 | ItemToDraw );
|
---|
369 | end;
|
---|
370 | inc( X, ColumnWidth );
|
---|
371 | inc( ColumnIndex );
|
---|
372 | end;
|
---|
373 | tmpColumns.Destroy;
|
---|
374 | end;
|
---|
375 |
|
---|
376 | procedure TMultiColumnListBox.SetItems( Items: TStrings );
|
---|
377 | begin
|
---|
378 | FListBox.Items.Assign( Items );
|
---|
379 | end;
|
---|
380 |
|
---|
381 | function TMultiColumnListBox.GetHeaderSections: TCustomHeaderSections;
|
---|
382 | begin
|
---|
383 | Result := FHeader.Sections;
|
---|
384 | end;
|
---|
385 |
|
---|
386 | function TMultiColumnListBox.GetItems: TStrings;
|
---|
387 | begin
|
---|
388 | Result := FListBox.Items;
|
---|
389 | end;
|
---|
390 |
|
---|
391 | procedure TMultiColumnListBox.Layout;
|
---|
392 | var
|
---|
393 | LastSection: TCustomHeaderSection;
|
---|
394 | begin
|
---|
395 | FHeader.Align := alTop;
|
---|
396 |
|
---|
397 | //FListBox.Align := alClient;
|
---|
398 | {
|
---|
399 | if FBorderStyle = bsNone then
|
---|
400 | begin
|
---|
401 | }
|
---|
402 | FListBox.Left := 0;
|
---|
403 | FListBox.Width := Width;
|
---|
404 | FListBox.Bottom := 0;
|
---|
405 | FListBox.Height := Height - FHeader.Height + 2; // hide the top edge under header
|
---|
406 | FListBox.SendToBack;
|
---|
407 | {
|
---|
408 | end
|
---|
409 | else
|
---|
410 | begin
|
---|
411 | FListBox.Left := 2;
|
---|
412 | FListBox.Width := Width - 4;
|
---|
413 | FListBox.Bottom := 2;
|
---|
414 | FListBox.Height := Height - FHeader.Height - 4;
|
---|
415 | end;
|
---|
416 | }
|
---|
417 |
|
---|
418 | if HeaderColumns.Count > 0 then
|
---|
419 | begin
|
---|
420 | // Resize the last column to fit, if possible
|
---|
421 | LastSection := HeaderColumns[ HeaderColumns.Count - 1 ];
|
---|
422 | if LastSection.Left < Width then
|
---|
423 | LastSection.Width := Width - LastSection.Left;
|
---|
424 | end;
|
---|
425 |
|
---|
426 | end;
|
---|
427 |
|
---|
428 | procedure TMultiColumnListBox.SetBorderStyle( NewValue: TBorderStyle );
|
---|
429 | begin
|
---|
430 | if NewValue = FBorderStyle then
|
---|
431 | exit;
|
---|
432 | FBorderStyle := NewValue;
|
---|
433 | Layout;
|
---|
434 | Invalidate;
|
---|
435 | end;
|
---|
436 |
|
---|
437 | procedure TMultiColumnListBox.SetImageList(ImageList: TImageList);
|
---|
438 | begin
|
---|
439 | if FImageList <> nil then
|
---|
440 | // Tell the old imagelist not to inform us any more
|
---|
441 | FImageList.Notification( Self, opRemove );
|
---|
442 |
|
---|
443 | FImageList := ImageList;
|
---|
444 |
|
---|
445 | if FImageList <> nil then
|
---|
446 | begin
|
---|
447 | // request notification when other is freed
|
---|
448 | FImageList.FreeNotification( Self );
|
---|
449 | end;
|
---|
450 | end;
|
---|
451 |
|
---|
452 | procedure TMultiColumnListBox.SetHeaderSections(Sections: TCustomHeaderSections);
|
---|
453 | begin
|
---|
454 | FHeader.Sections.Assign( Sections );
|
---|
455 | end;
|
---|
456 |
|
---|
457 | procedure TMultiColumnListBox.Notification( AComponent: TComponent;
|
---|
458 | Operation: TOperation);
|
---|
459 | begin
|
---|
460 | inherited Notification( AComponent, Operation );
|
---|
461 | if AComponent = FImageList then
|
---|
462 | if Operation = opRemove then
|
---|
463 | // Image list is being destroyed
|
---|
464 | FImageList := nil;
|
---|
465 | end;
|
---|
466 |
|
---|
467 | procedure TMultiColumnListBox.ChangeHeader(HeaderControl: TCustomHeaderControl;
|
---|
468 | Section: TCustomHeaderSection);
|
---|
469 | begin
|
---|
470 | Layout;
|
---|
471 | FListBox.Invalidate;
|
---|
472 | end;
|
---|
473 |
|
---|
474 | function TMultiColumnListBox.GetSelectedItem: string;
|
---|
475 | begin
|
---|
476 | Result := '';
|
---|
477 | if FListBox.ItemIndex <> -1 then
|
---|
478 | Result := FListBox.Items[ FListBox.ItemIndex ];
|
---|
479 | end;
|
---|
480 |
|
---|
481 | function TMultiColumnListBox.GetSelectedObject: TObject;
|
---|
482 | begin
|
---|
483 | Result := nil;
|
---|
484 | if FListBox.ItemIndex <> -1 then
|
---|
485 | Result := FListBox.Items.Objects[ FListBox.ItemIndex ];
|
---|
486 |
|
---|
487 | end;
|
---|
488 |
|
---|
489 | procedure TMultiColumnListBox.SetItemIndex(const Value: integer );
|
---|
490 | begin
|
---|
491 | FListBox.ItemIndex := Value;
|
---|
492 | end;
|
---|
493 |
|
---|
494 | function TMultiColumnListBox.GetItemIndex: integer;
|
---|
495 | begin
|
---|
496 | Result := FListBox.ItemIndex;
|
---|
497 | end;
|
---|
498 |
|
---|
499 | function TMultiColumnListBox.GetHeaderPenColor: TColor;
|
---|
500 | begin
|
---|
501 | Result := FHeader.PenColor;
|
---|
502 | end;
|
---|
503 |
|
---|
504 | procedure TMultiColumnListBox.SetHeaderPenColor( NewValue: TColor );
|
---|
505 | begin
|
---|
506 | FHeader.PenColor := NewValue;
|
---|
507 | end;
|
---|
508 |
|
---|
509 | function TMultiColumnListBox.GetListPenColor: TColor;
|
---|
510 | begin
|
---|
511 | Result := FListBox.PenColor;
|
---|
512 | end;
|
---|
513 |
|
---|
514 | procedure TMultiColumnListBox.SetListPenColor( NewValue: TColor );
|
---|
515 | begin
|
---|
516 | FListBox.PenColor := NewValue;
|
---|
517 | end;
|
---|
518 |
|
---|
519 | function TMultiColumnListBox.GetEnabled: boolean;
|
---|
520 | begin
|
---|
521 | Result := FListBox.Enabled;
|
---|
522 | end;
|
---|
523 |
|
---|
524 | function TMultiColumnListBox.GetExtendedSelect: boolean;
|
---|
525 | begin
|
---|
526 | Result := FListBox.ExtendedSelect;
|
---|
527 | end;
|
---|
528 |
|
---|
529 | function TMultiColumnListBox.GetHeaderFont: TFont;
|
---|
530 | begin
|
---|
531 | Result := FHeader.Font;
|
---|
532 | end;
|
---|
533 |
|
---|
534 | function TMultiColumnListBox.GetHeaderHeight: integer;
|
---|
535 | begin
|
---|
536 | Result := FHeader.Height;
|
---|
537 | end;
|
---|
538 |
|
---|
539 | function TMultiColumnListBox.GetHeaderParentFont: boolean;
|
---|
540 | begin
|
---|
541 | Result := FHeader.ParentFont;
|
---|
542 | end;
|
---|
543 |
|
---|
544 | function TMultiColumnListBox.GetItemHeight: integer;
|
---|
545 | begin
|
---|
546 | Result := FListBox.ItemHeight;
|
---|
547 | end;
|
---|
548 |
|
---|
549 | function TMultiColumnListBox.GetListFont: TFont;
|
---|
550 | begin
|
---|
551 | Result := FListBox.Font;
|
---|
552 | end;
|
---|
553 |
|
---|
554 | function TMultiColumnListBox.GetListParentFont: boolean;
|
---|
555 | begin
|
---|
556 | Result := FListBox.ParentFont;
|
---|
557 | end;
|
---|
558 |
|
---|
559 | function TMultiColumnListBox.GetMultiSelect: boolean;
|
---|
560 | begin
|
---|
561 | Result := FListBox.MultiSelect;
|
---|
562 | end;
|
---|
563 |
|
---|
564 | function TMultiColumnListBox.GetParentColor: boolean;
|
---|
565 | begin
|
---|
566 | Result := FListBox.ParentColor;
|
---|
567 | end;
|
---|
568 |
|
---|
569 | function TMultiColumnListBox.GetParentShowHint: boolean;
|
---|
570 | begin
|
---|
571 | Result := FListBox.ParentShowHint;
|
---|
572 | end;
|
---|
573 |
|
---|
574 | function TMultiColumnListBox.GetThePopupMenu: TPopupMenu;
|
---|
575 | begin
|
---|
576 | Result := FListBox.PopupMenu;
|
---|
577 | end;
|
---|
578 |
|
---|
579 | function TMultiColumnListBox.GetShowHint: boolean;
|
---|
580 | begin
|
---|
581 | Result := FListBox.ShowHint;
|
---|
582 | end;
|
---|
583 |
|
---|
584 | {
|
---|
585 | procedure TMultiColumnListBox.SetEnabled(NewState:Boolean);
|
---|
586 | begin
|
---|
587 | FListBox.Enabled := NewState;
|
---|
588 | FHeader.Enabled := NewState;
|
---|
589 | end;
|
---|
590 | }
|
---|
591 |
|
---|
592 | procedure TMultiColumnListBox.SetExtendedSelect(const Value: boolean);
|
---|
593 | begin
|
---|
594 | FListBox.ExtendedSelect := Value;
|
---|
595 | end;
|
---|
596 |
|
---|
597 | procedure TMultiColumnListBox.SetHeaderFont(const Value: TFont);
|
---|
598 | begin
|
---|
599 | FHeader.Font := Value;
|
---|
600 | end;
|
---|
601 |
|
---|
602 | procedure TMultiColumnListBox.SetHeaderHeight(const Value: integer);
|
---|
603 | begin
|
---|
604 | FHeader.Height := Value;
|
---|
605 | end;
|
---|
606 |
|
---|
607 | procedure TMultiColumnListBox.SetHeaderParentFont(const Value: boolean);
|
---|
608 | begin
|
---|
609 | FHeader.ParentFont := Value;
|
---|
610 | end;
|
---|
611 |
|
---|
612 | procedure TMultiColumnListBox.SetItemHeight(const Value: integer);
|
---|
613 | begin
|
---|
614 | FListBox.ItemHeight := Value;
|
---|
615 | end;
|
---|
616 |
|
---|
617 | procedure TMultiColumnListBox.SetListFont(const Value: TFont);
|
---|
618 | begin
|
---|
619 | FListBox.Font := Value;
|
---|
620 | end;
|
---|
621 |
|
---|
622 | procedure TMultiColumnListBox.SetListParentFont(const Value: boolean);
|
---|
623 | begin
|
---|
624 | FListBox.ParentFont := Value;
|
---|
625 | end;
|
---|
626 |
|
---|
627 | procedure TMultiColumnListBox.SetMultiSelect(const Value: boolean);
|
---|
628 | begin
|
---|
629 | FListBox.MultiSelect := Value;
|
---|
630 | end;
|
---|
631 |
|
---|
632 | procedure TMultiColumnListBox.SetParentShowHint(const Value: boolean);
|
---|
633 | begin
|
---|
634 | FListBox.ParentShowHint := Value;
|
---|
635 | FHeader.ParentShowHint := Value;
|
---|
636 | end;
|
---|
637 |
|
---|
638 | procedure TMultiColumnListBox.SetPopupMenu(const Value: TPopupMenu);
|
---|
639 | begin
|
---|
640 | FListBox.PopupMenu := Value;
|
---|
641 | FHeader.PopupMenu := Value;
|
---|
642 | end;
|
---|
643 |
|
---|
644 | procedure TMultiColumnListBox.SetShowHint(const Value: boolean);
|
---|
645 | begin
|
---|
646 | FListBox.ShowHint := Value;
|
---|
647 | FHeader.ShowHint := Value;
|
---|
648 | end;
|
---|
649 |
|
---|
650 | procedure TMultiColumnListBox.SetSelectedObject(const Value: TObject);
|
---|
651 | var
|
---|
652 | Index: integer;
|
---|
653 | begin
|
---|
654 | Index := FListBox.Items.IndexOfObject( Value );
|
---|
655 | FListBox.ItemIndex := Index;
|
---|
656 | end;
|
---|
657 |
|
---|
658 | function TMultiColumnListBox.GetOnClick: TNotifyEvent;
|
---|
659 | begin
|
---|
660 | Result := FListBox.OnClick;
|
---|
661 | end;
|
---|
662 |
|
---|
663 | procedure TMultiColumnListBox.SetOnClick(const Value: TNotifyEvent);
|
---|
664 | begin
|
---|
665 | FListBox.OnClick := Value;
|
---|
666 | end;
|
---|
667 |
|
---|
668 | function TMultiColumnListBox.GetOnDblClick: TNotifyEvent;
|
---|
669 | begin
|
---|
670 | Result := FListBox.OnDblClick;
|
---|
671 | end;
|
---|
672 |
|
---|
673 | procedure TMultiColumnListBox.SetOnDblClick(const Value: TNotifyEvent);
|
---|
674 | begin
|
---|
675 | FListBox.OnDblClick := Value;
|
---|
676 | end;
|
---|
677 |
|
---|
678 | procedure TMultiColumnListBox.SetSelectedItem(const Value: string);
|
---|
679 | var
|
---|
680 | Index: integer;
|
---|
681 | begin
|
---|
682 | Index := FListBox.Items.IndexOf( Value );
|
---|
683 | FListBox.ItemIndex := Index;
|
---|
684 | end;
|
---|
685 |
|
---|
686 | procedure TMultiColumnListBox.SetSelectedItemTo(Text: string );
|
---|
687 | begin
|
---|
688 | if ItemIndex = -1 then
|
---|
689 | raise Exception.Create( 'MultiColumnListBox: no item selected to set!' );
|
---|
690 |
|
---|
691 | Items[ ItemIndex ] := Text;
|
---|
692 | end;
|
---|
693 |
|
---|
694 | procedure TMultiColumnListBox.Resize;
|
---|
695 | begin
|
---|
696 | Layout;
|
---|
697 | end;
|
---|
698 |
|
---|
699 |
|
---|
700 | function TMultiColumnListBox.GetTopObject: TObject;
|
---|
701 | begin
|
---|
702 | Result := nil;
|
---|
703 | if ( FListBox.TopIndex >0 )
|
---|
704 | and ( FListBox.TopIndex < FListBox.Items.Count ) then
|
---|
705 | Result := FListBox.Items.Objects[ FLIstBox.TopIndex ];
|
---|
706 |
|
---|
707 | end;
|
---|
708 |
|
---|
709 | procedure TMultiColumnListBox.SetTopObject(const Value: TObject);
|
---|
710 | var
|
---|
711 | Index: integer;
|
---|
712 | begin
|
---|
713 | Index := FListBox.Items.IndexOfObject( Value );
|
---|
714 | if Index <> -1 then
|
---|
715 | FListBox.TopIndex := Index;
|
---|
716 | end;
|
---|
717 |
|
---|
718 | procedure TMultiColumnListBox.SetOnItemFocus( Value: TItemFocusEvent );
|
---|
719 | begin
|
---|
720 | FListBox.OnItemFocus := Value;
|
---|
721 | end;
|
---|
722 |
|
---|
723 | function TMultiColumnListBox.GetOnItemFocus: TItemFocusEvent;
|
---|
724 | begin
|
---|
725 | Result := FListBox.OnItemFocus;
|
---|
726 | end;
|
---|
727 |
|
---|
728 | function TMultiColumnListBox.GetOnItemSelect: TItemSelectEvent;
|
---|
729 | begin
|
---|
730 | Result := FListBox.OnItemSelect;
|
---|
731 | end;
|
---|
732 |
|
---|
733 | procedure TMultiColumnListBox.SetOnItemSelect( Value: TItemSelectEvent );
|
---|
734 | begin
|
---|
735 | FListBox.OnItemSelect := Value;
|
---|
736 | end;
|
---|
737 |
|
---|
738 | function TMultiColumnListBox.GetOnEnter: TNotifyEvent;
|
---|
739 | begin
|
---|
740 | Result := FListBox.OnEnter;
|
---|
741 | end;
|
---|
742 |
|
---|
743 | procedure TMultiColumnListBox.SetOnEnter( Value: TNotifyEvent );
|
---|
744 | begin
|
---|
745 | FListBox.OnEnter := Value;
|
---|
746 | end;
|
---|
747 |
|
---|
748 | function TMultiColumnListBox.GetOnExit: TNotifyEvent;
|
---|
749 | begin
|
---|
750 | Result := FListBox.OnExit;
|
---|
751 | end;
|
---|
752 |
|
---|
753 | procedure TMultiColumnListBox.SetOnExit( Value: TNotifyEvent );
|
---|
754 | begin
|
---|
755 | FListBox.OnExit := Value;
|
---|
756 | end;
|
---|
757 |
|
---|
758 | procedure TMultiColumnListBox.SetSelected( Index: longint; Value: boolean );
|
---|
759 | begin
|
---|
760 | FListBox.Selected[ Index ] := Value;
|
---|
761 | end;
|
---|
762 |
|
---|
763 | function TMultiColumnListBox.GetSelected( Index: longint ): boolean;
|
---|
764 | begin
|
---|
765 | Result := FListBox.Selected[ Index ];
|
---|
766 | end;
|
---|
767 |
|
---|
768 | Procedure TMultiColumnListBox.SetColor(NewColor:TColor);
|
---|
769 | begin
|
---|
770 | inherited SetColor( NewColor );
|
---|
771 | end;
|
---|
772 |
|
---|
773 | Initialization
|
---|
774 | {Register classes}
|
---|
775 | RegisterClasses([TMultiColumnListBox]);
|
---|
776 | end.
|
---|