Sign in Join
Wiki copytemporary

ATListbox: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# About
22
33ATListbox is OS-independant listbox control. It's made for dialog like Sublime Text's command list. If OnDrawItem is set, listbox is fully owner-drawn: you must not set items, just set ItemCount, ItemIndex.
44
55Listbox doesn't get focus by click; to get focus on click set CanGetFocus=true (if focused, it handles keys Up/Down/PgUp/PgDn/Home/End, else you need to handle OnKeyDown in form and set listbox's ItemIndex by hand, which is boring).
66
77Author: Alexey Torgashin
88
99Screenshot:
1010
11-<figure>
12-<img src="atlistbox.png" title="atlistbox.png" />
13-<figcaption>atlistbox.png</figcaption>
14-</figure>
11+![](/wiki-images/4/41/Atlistbox.png)
1512
1613# Download
1714
1815Homepage at github: <https://github.com/Alexey-T/ATFlatControls>
1916
2017# License
2118
2219MPL 2.0 or LGPL.
2320
2421# Properties
2522
2623- Items: StringList to store items, or you can ignore it if you use OnDrawItem event (listbox will be fully virtual)
2724- ItemCount: count of items
2825- ItemIndex: index of active item
2926- ItemTop: index of item visible at the top
3027- ItemHeight: height (in pixels) of each item
3128- VisibleItems: count of items fully visible inside control
3229- CanGetFocus: allow control to be focused on click
3330
3431- ThemedScrollbar: allows control to use [[ATScrollBar]] instead of default OS scrollbar
3532- ThemedColors: not used (made to use in CudaText app)
3633
3734Events
3835
3936- OnClick
4037- OnDblClick
4138- OnDrawItem: allows to owner-draw all items
4239- OnChangedSel: fired on changed ItemIndex
4340
4441# Example
4542
4643Let's create list:
4744
4845``` pascal
4946uses Math, ATListbox; //package atflatcontrols_package.lpk
5047
5148var
5249 b: TATListbox;
5350
5451procedure TfmMain.FormCreate(Sender: TObject);
5552begin
5653 b:= TATListbox.Create(Self);
5754 b.Parent:= Self;
5855 b.Align:= alClient;
5956
6057 b.OnDrawItem:= @ListDraw;
6158 b.OnClick:= @ListClick; //see example in github https://github.com/Alexey-T/ATFlatControls/blob/master/app/demo_listbox/unit1.pas
6259
6360 b.Color:= $e0e0e0;
6461 b.ItemCount:= 21;
6562end;
6663```
6764
6865Let's set OnDrawItem to this (simply paint "itemNN"):
6966
7067``` pascal
7168procedure TfmMain.ListDraw(Sender: TObject; C: TCanvas; AIndex: integer;
7269 const ARect: TRect);
7370begin
7471 C.Brush.Color:= IfThen(AIndex=b.ItemIndex, clMedGray, b.Color);
7572 C.FillRect(ARect);
7673
7774 C.Pen.Color:= clMedGray;
7875 C.Line(ARect.Left+2, ARect.Bottom-1, ARect.Right-2, ARect.Bottom-1);
7976
8077 C.TextOut(ARect.Left+6, ARect.Top+2, 'item '+inttostr(AIndex));
8178end;
8279```
8380
8481---
8582*From the Free Pascal wiki, page "ATListbox", as it stood on 2021-12-16 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
8683Category: Components
8784Category: Lazarus

Back to history