Treegadget problem...

Just starting out? Need help? Post your questions and find answers here.
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Treegadget problem...

Post by Inf0Byt3 »

Does anybody know how can i make some items in a treegadget have normal buttons (+'es) and some have checkboxes? AFAIK PB only allows creation of only-checkbox treegadget or simple ones with buttons...
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

For an example take a look here... Where can i find some information about this?

Image
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I think you'll have to supply your own stateicon images. So you'll either have to add them to the treeview image list or create a new image list from scratch. Of course PB already supplies it's own state images for the checkboxes and so you'll either need to replace these or add a couple more as required.

Afraid I haven't any example code to help out and I reckon it could be quite a bit of work if you're actually going to add more icons to those already there as you'll have to take charge of the hit-testing and deciding exactly which images to show etc. Some subclassing involved, but I don't think it will prove too difficult.
I may look like a mule, but I'm not a complete ass.
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Oh, i see... I was afraid there isn't a simple method to do this... I think i'll have to change the strategy if i can't get it to work... Found some code to add custom images to the imagelist on the forum and i hope it will not be too hard to make something usefull with it.

Thank you for the idea :).
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Using the #TVS_CHECKBOXES style only makes use of two stateicons (checked and non-checked) which is probably not enough for your requirements and so you'd probably have to dispense with this flag and 'go it alone'!

Of course checkboxes and such like are in addition to any icons you may associate with an item. So if you don't require both, then maybe you can use the regular icons to give you the effect you're after. This would still require some hit-testing though.
I may look like a mule, but I'm not a complete ass.
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

http://www.purebasic.fr/english/viewtop ... checkboxes

Just found something cool :). I'll post here if i'll make it... BTW, i only need checkboxes so i guess it's easy... Thank you for the help :)
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

In terms of checkboxes, all that code does is add the #TVS_CHECKBOXES style to the underlying tree gadget which forms the basis of the explorer tree.

Code: Select all

#TVS_CHECKBOXES = $100 
If OpenWindow(0, 0, 0, 300, 300, "ExplorerTreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  ExplorerTreeGadget(0, 10, 10, 280, 280, "*.pb;*.pbi")
  SetWindowLong_(GadgetID(0),#GWL_STYLE,GetWindowLong_(GadgetID(0),#GWL_STYLE) | #TVS_CHECKBOXES ) 
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf 
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

:?:

Code: Select all

Procedure RemoveTVIcheckbox(tvGadget, item)
  tvi.TV_ITEM
  tvi\mask = #TVIF_HANDLE | #TVIF_STATE 
  tvi\hItem = GadgetItemID(tvGadget, item)
  tvi\state = 0 << 12
  tvi\stateMask = #TVIS_STATEIMAGEMASK 
  SendMessage_(GadgetID(1), #TVM_SETITEM, 0, tvi)
EndProcedure

If OpenWindow(0, 0, 0, 400, 380, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  TreeGadget(1, 180, 10, 160, 360, #PB_Tree_CheckBoxes)
  For a = 0 To 4
    AddGadgetItem (1, -1, "Normal Item "+Str(a), 0, 0)
    AddGadgetItem (1, -1, "Node "+Str(a), 0, 0)
    AddGadgetItem(1, -1, "Sub-Item 1", 0, 1)
    AddGadgetItem(1, -1, "Sub-Item 2", 0, 1)
    AddGadgetItem(1, -1, "Sub-Item 3", 0, 1)
    AddGadgetItem(1, -1, "Sub-Item 4", 0, 1)
    AddGadgetItem (1, -1, "File "+Str(a), 0, 0)
  Next a
  RemoveTVIcheckbox(1, 1)
  RemoveTVIcheckbox(1, 6)
  For i = 8 To 12
    RemoveTVIcheckbox(1, i)
  Next i
  SetGadgetItemState(1, 8, #PB_Tree_Expanded)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

It's not that Sparks, I think Info is after two different types of checkbox or, one set of checkbox buttons and another set of push buttons instead etc.

I think that having first added a couple more images to the image list (3<<12 and 4<<12) we could then perhaps use your code to set the required state. But I've a feeling that, in this case, Windows will cycle through all 4 checkbox images as you click each check mark and thus we need to intercept the relevant notifications etc.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Actually Sparks, I may have misread Info's first post!!!!!!

I think I've allowed Info's second post to confuse me a little in which he displays 2 different types of checkbox!

*ollox!

@Info, if you simply want to remove the checkmarks from individual items then Sparkies code does the job nicely and I apologise for getting the wrong end of the stick! In which case I blame your second post! :evil:
However, if you do want 2 different types of checkbox image then you will have to delve a little deeper etc.
Last edited by srod on Sat Dec 09, 2006 6:08 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Oh well, I guess it was my turn to be off target this time srod. :P :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

I gotta learn to type faster :wink:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

:)

It's okay, I type faster than I think... sadly!

Actually, I am totally confused now as to what it is InfoByte is after? Oh well. 8)
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Well if we're lucky, we've now confused Inf0Byt3 as well, and this is all forgotten :lol:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

This is now completely off topic, but your avatar is simply too cool!

I'm going to change mine pronto!

8)
I may look like a mule, but I'm not a complete ass.
Post Reply