Comments (13)
Alexey, I looked at the listbox code and it looked like it would be a big deal to implement variable item heights. I made do with setting the itemheight big enough so that an inflate rect would let me draw a separator bar onto the canvas. I'm replicating a popup menu with the list so it can remain open when I select colors for my app. See the attached image. Unless you have some secret way of adjusting the image heights in varying sizes don't worry about this one.
from atflatcontrols.
Alexey, I looked at the listbox code and it looked like it would be a big deal to implement variable item heights.
yes, implementing var item height would be a hard work...
code needs equal item height.
from atflatcontrols.
Alexey, Thanks for taking a look. I was able to work around it and get a pretty convincing menu separator just by setting item heights, using an inflate rect to give a bit more room between items, and then drawing the separator on the canvas. All owner draw of course. Actually, doing it that way as opposed to a separate item with a "-" as a caption helps in some ways.
Also using owner draw, I implemented both multiselect and extended select for the ATlistbox and got the logic behind it working so that it functions like a regular system listbox (i.e., ctrl-select, shift-select, drag-select etc.). I also added a MenuItems property to allow adding items as TMenuItems to the list. That allows me to set image index, enabled/disabled, and all the stuff a menuitem has for each item in the listbox. Of course, you have to handle all the drawing in drawitem, but I was having to do that anyway.
If you are interested in seeing that code let me know how to email it to you and I'd be glad to do that.
The only thing I ran into again was that "gap" at the bottom of the list that was the color of the theme, not the color of my list items. What I finally used was this code in drawitem (TATListBoxEX is my derived component type):
with (Sender as TATListBoxEX) do
begin
r := ClientRect;
if VisibleItems < ItemCount then //items don't fill listbox
r.Top := VisibleItems * ItemHeight
else
r.Top := ItemCount * ItemHeight; //items fill listbox so it needs a vertical scrollbar
C.Brush.Color := Panel12.Color;
C.FillRect(r); //just fill in the gap from the bottom of the last item to the bottom of the clientrect
...
Without that code - ownerdraw (I don't want the light gray rect at the bottom):
With that code - ownerdraw (entire list is same bgnd color)
That code is working (so far) to "fill in" that area at the bottom with the color I'm using for the rest of it. If you have any clever recommendations on that I'd love to hear them! Note that this all applies only to ownerdraw ATlistbox.
Stan
from atflatcontrols.
If you are interested in seeing that code let me know how to email it to you and I'd be glad to do that.
code which fills listbox with the MenuItems? is it for all users or very rarely needed?
from atflatcontrols.
BG color. just set the items of Theme^ property. or- make new theme and set its pointer to Theme prop.
list.OwnerDrawn:= true;
list.Color:= $a080e0;
list.VirtualItemCount:= 4;
list.Theme^.ColorBgListbox:= $799920;
with this i get this pic-
from atflatcontrols.
If you are interested in seeing that code let me know how to email it to you and I'd be glad to do that.
code which fills listbox with the MenuItems? is it for all users or very rarely needed?
Menuitems are useful if the user is needing menu type functionality, OR user needs extra properties per item (like an imageindex, enabled/disabled, etc.). This could probably be implemented outside of ownerdraw/drawitem, although in my test stuff I am using them in drawitem.
Actually the multiselect and extended select stuff would be more generally useful. However, I only have it working for OwnerDraw. Other than the operational logic of the selections, none of it as it sits now is coded to work with items in regular (non-ownerdrawn) mode.
from atflatcontrols.
BG color. just set the items of Theme^ property. or- make new theme and set its pointer to Theme prop.
list.OwnerDrawn:= true; list.Color:= $a080e0; list.VirtualItemCount:= 4; list.Theme^.ColorBgListbox:= $799920;
FYI, the ATlists I'm playing with are set to ownerdrawn = true, virtualmode = false. I tried your code above and I was able to get it to work (I had to set it and then invalidate the list right after showing the panel the ATlist is sitting on; otherwise it wouldn't work if I set it before the panel is shown or used it in drawitem until the mouse entered the list; I need it changed before the list is seen).
If I try to set the list.color directly, I get [dcc32 Error] Unit1.pas(10740): E2362 Cannot access protected symbol TControl.Color
. I can set it if I use "with (Sender as TATListBox) do
" inside drawitem.
I guess my question is, if the ATList is set to ownerdrawn, shouldn't it ignore all the theme stuff while in that mode? I've worked around that but that was my original expectation in the beginning.
Also, another problem with setting "list.Theme^.ColorBgListbox:=" is that it changed all the ATlists in the app. Sometimes that's what I want, but sometimes (like my current app) I want different colors for each list. Is there a way to handle that (that's one main reason I'm using 2 of my ATlists in ownerdrawn mode)? Is there some way to "shut off" the theming code for a specific ATlist?
Thanks Alexey. Sorry to be a pest again.
from atflatcontrols.
I guess my question is, if the ATList is set to ownerdrawn, shouldn't it ignore all the theme stuff while in that mode?
then how ATlistbox will paint empty area? on the bottom. some color value is needed and it is in the theme^.
from atflatcontrols.
Also, another problem with setting "list.Theme^.ColorBgListbox:=" is that it changed all the ATlists in the app. Sometimes that's what I want, but sometimes (like my current app) I want different colors for each list.
there is way to fix it. make new record of Theme type. fill this record as needed.
e.g. this record is t
. then set listbox1.Theme:= @t
.
from atflatcontrols.
I guess my question is, if the ATList is set to ownerdrawn, shouldn't it ignore all the theme stuff while in that mode?
then how ATlistbox will paint empty area? on the bottom. some color value is needed and it is in the theme^.
The code below was what I was using to paint the empty area. It worked, but your idea on the new theme record is better (see next comment). But you can paint the canvas clientrect in drawitem this way and cover up that area below the items:
with (Sender as TATListBoxEX) do
begin
r := ClientRect;
if VisibleItems < ItemCount then //items don't fill listbox
r.Top := VisibleItems * ItemHeight
else
r.Top := ItemCount * ItemHeight; //items fill listbox so it needs a vertical scrollbar
C.Brush.Color := Panel12.Color;
C.FillRect(r); //just fill in the gap from the bottom of the last item to the bottom of the clientrect
from atflatcontrols.
Also, another problem with setting "list.Theme^.ColorBgListbox:=" is that it changed all the ATlists in the app. Sometimes that's what I want, but sometimes (like my current app) I want different colors for each list.
there is way to fix it. make new record of Theme type. fill this record as needed.
e.g. this record ist
. then setlistbox1.Theme:= @t
.
YES!! THIS^^^ worked a treat! No extra invalidates needed, no screwing around with the other ATlists. THANKS. Pointers and records are not my strong suit. But that worked both to keep the themes separate, and to allow painting in the area below the items (the empty area). Whew. I thought I'd never get that fixed.
Your ATListbox is so much better than the system listbox that I tend to use it anytime I need a listbox now and this idea alone is a lifesaver.
from atflatcontrols.
OK, still trying to figure this out. I'm having trouble with all the scrollbars taking on the same colors, so I thought I'd try the same trick and here's what I have:
Vars:
ATFlatThemeEx1: TATFlatTheme;
ATFlatThemeEx2: TATFlatTheme;
ATSBThemeEx1: TATScrollbarTheme;//PATScrollbarTheme;
ATSBThemeEx2: TATScrollbarTheme;//PATScrollbarTheme;
Example of set before I show the ATLBMisspelled ATlistbox:
ATLBMisspelled.Theme := @ATFlatThemeEx1; //works
ATLBMisspelled.Scrollbar.Theme := @ATSBThemeEx1; //doesn't work, scrollbars don't show
The TATFlatTheme stuff seems to work. But the scrollbars don't. If I set the scrollbar theme to one of my new records, they never show up. If I don't set them to anything they work OK, but then any settings I make are on all scrollbars of all ATlists. . For the scrollbars I've tried TATScrollbarTheme or PATScrollbarTheme. Like I say, records and pointers are not my forte. I suspect I'm calling and/or setting something wrong?
(BTW, place this in the nice to have category. If it's not possible that's OK)
from atflatcontrols.
copied project app/demo_listbox to new project.
added theme for scrollbar:
var
theme1: TATScrollbarTheme;
procedure TfmMain.FormCreate(Sender: TObject);
begin
//.......
theme1:= ATScrollbarTheme;
theme1.ColorBG:= clred;
list.Scrollbar.Theme:= @theme1;
ActiveControl:= list;
end;
and I see red color on scrollbar
let's continue in new topic.
this is big.
from atflatcontrols.
Related Issues (20)
- Font scaling correction HOT 8
- Question about buttons placed on the left side and tabwidth of the leftmost tab after scrolling HOT 4
- Can't compile ATCanvasPrimitives in 10.4 HOT 4
- How put a form insde tTab or controls like tpage HOT 3
- Prob with DragDrop (unexpected exchange of tabs)? HOT 14
- TATTabs: Missing Event while reordering Tabs HOT 7
- Little problem again HOT 4
- Small problem
- Little problem in Delphi
- How to change the position of dropdown list of a ATComboEdit? HOT 6
- Bug report in TabChangeQuery HOT 3
- Case where changed Data.TabHint is not reliably propagated to tab's hint HOT 9
- Problem HOT 2
- Delphi 11 + TAntialiasingMode HOT 8
- ATStatusBar.pas - Delphi 10.2 HOT 1
- Option for right click HOT 2
- OptMouseDragOutEnabled broken? HOT 3
- Drag marker shown after context menu HOT 21
- Drag marker shown at left click on active tab HOT 11
- TATListbox: OwnerDrawn + ScrollStyleHorz HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atflatcontrols.