It is currently Thu Dec 05, 2019 8:40 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Embed CheckBox into PanelGadget header and trap CheckBox eve
PostPosted: Thu Jun 27, 2019 10:07 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Jun 23, 2010 5:13 pm
Posts: 206
Hi,
How it is possible to embed CheckBox into PanelGadget header and trap CheckBox event?


Top
 Profile  
Reply with quote  
 Post subject: Re: Embed CheckBox into PanelGadget header and trap CheckBox
PostPosted: Thu Jun 27, 2019 11:03 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3467
Hi
Code:

OpenWindow(0, 0, 0, 400, 300, "Check to Tab", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
         
 PanelGadget(1,5,5,390,290)
  AddGadgetItem(1, -1, "Tab #1     ")
  AddGadgetItem(1, -1, "Tab #2     ")
  AddGadgetItem(1, -1, "Tab #3     ")
 CloseGadgetList()

CheckBoxGadget(10,55,8,15,15,"")
BringWindowToTop_(GadgetID(10))

CheckBoxGadget(20,116,8,15,15,"")
BringWindowToTop_(GadgetID(20))

CheckBoxGadget(30,178,8,15,15,"")
BringWindowToTop_(GadgetID(30))
DisableGadget(20,1)
DisableGadget(30,1)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
     
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Select EventType()
            Case #PB_EventType_Change
             state = GetGadgetState(1)
              If state = 0
                DisableGadget(10,0)
                DisableGadget(20,1)
                DisableGadget(30,1)
              EndIf
              If state = 1
                DisableGadget(10,1)           
                DisableGadget(20,0)
                DisableGadget(30,1)
              EndIf           
              If state = 2
                DisableGadget(10,1)
                DisableGadget(20,1)
                DisableGadget(30,0)         
              EndIf
          EndSelect
         
        Case 10,20,30
          Debug EventGadget()
          Debug GetGadgetState(EventGadget())
      EndSelect   
  EndSelect
Until Quit = 1
End

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Embed CheckBox into PanelGadget header and trap CheckBox
PostPosted: Fri Jun 28, 2019 8:15 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Jun 23, 2010 5:13 pm
Posts: 206
Hmm, awesome...
Rashad, enormous thanks to You.

But what about instead of absolute coordinates of CheckBox items using relative coordinates of PanelGadget headers?


Top
 Profile  
Reply with quote  
 Post subject: Re: Embed CheckBox into PanelGadget header and trap CheckBox
PostPosted: Fri Jun 28, 2019 12:33 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3467
Hi
Code:

LoadFont(0,"Tahoma",12)
OpenWindow(0, 0, 0, 400, 300, "Check to Tab", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)       
 PanelGadget(1,5,5,390,290)
 SetGadgetFont(1,FontID(0))
 SetWindowLongPtr_( GadgetID(1), #GWL_STYLE, GetWindowLongPtr_( GadgetID(1), #GWL_STYLE )|#TCS_FIXEDWIDTH )
 SendMessage_( GadgetID(1), #TCM_SETITEMSIZE, 0,120|30<<16)
  AddGadgetItem(1, -1, "Tab #1               ")   ;Spaces to set the text left padding
  AddGadgetItem(1, -1, "Tab #2               ")
  AddGadgetItem(1, -1, "Tab #3               ")
 CloseGadgetList()

CheckBoxGadget(10,GadgetX(1)+100,GadgetY(1)+8,15,15,"")  ; x = GadgetX(1)+Tab Width(120)- CheckBox width - 5 (-20)
BringWindowToTop_(GadgetID(10))

CheckBoxGadget(20,GadgetX(1)+220,GadgetY(1)+8,15,15,"")  ;x = GadgetX(1)+Tab Width(120)- CheckBox width - 5 (-20) + 120
BringWindowToTop_(GadgetID(20))

CheckBoxGadget(30,GadgetX(1)+340,GadgetY(1)+8,15,15,"")
BringWindowToTop_(GadgetID(30))
DisableGadget(20,1)
DisableGadget(30,1)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
     
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Select EventType()
            Case #PB_EventType_Change
             state = GetGadgetState(1)
              If state = 0
                DisableGadget(10,0)
                DisableGadget(20,1)
                DisableGadget(30,1)
              EndIf
              If state = 1
                DisableGadget(10,1)           
                DisableGadget(20,0)
                DisableGadget(30,1)
              EndIf           
              If state = 2
                DisableGadget(10,1)
                DisableGadget(20,1)
                DisableGadget(30,0)         
              EndIf
          EndSelect
         
        Case 10,20,30
          Debug EventGadget()
          Debug GetGadgetState(EventGadget())
      EndSelect   
  EndSelect
Until Quit = 1
End

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Embed CheckBox into PanelGadget header and trap CheckBox
PostPosted: Fri Jun 28, 2019 2:03 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jun 24, 2006 3:29 am
Posts: 203
I have a folder in my pb sources: pbsnippets\RASHAD ;)

<3

_________________
Proud supporter of PB! * Musician * C64/6502 Freak


Top
 Profile  
Reply with quote  
 Post subject: Re: Embed CheckBox into PanelGadget header and trap CheckBox
PostPosted: Fri Jun 28, 2019 2:15 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3467
Thanks oreopa :mrgreen:
Much appreciated

You can use it to add BurttonGadget() and alike

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Embed CheckBox into PanelGadget header and trap CheckBox
PostPosted: Thu Jul 04, 2019 10:52 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Jun 23, 2010 5:13 pm
Posts: 206
Many thanks but expecting something different like instead of making tabs fixed length maybe get tab startX and width then create checkbox in proper place (because tabs should stay dynamic width according to text size)

Again huge thanks for effort.


Top
 Profile  
Reply with quote  
 Post subject: Re: Embed CheckBox into PanelGadget header and trap CheckBox
PostPosted: Thu Jul 04, 2019 11:36 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3467
No fixed width
Different tabs widths
Code:
LoadFont(0,"Tahoma",12)
OpenWindow(0, 0, 0, 400, 300, "Check to Tab", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)       
 PanelGadget(1,5,5,390,290)
 SetGadgetFont(1,FontID(0))
  AddGadgetItem(1, -1, "Tab1   ")   ;Spaces to set the text left padding
  AddGadgetItem(1, -1, "Tab2 #2   ")
  AddGadgetItem(1, -1, "Tab333 #3   ")
 CloseGadgetList()

SendMessage_(GadgetID(1),#TCM_GETITEMRECT,0,r.RECT)
cbtrim = (r\bottom-r\top -15)/2
CheckBoxGadget(10,r\right-12,GadgetY(1)+r\top+cbtrim,15,15,"")
BringWindowToTop_(GadgetID(10))

SendMessage_(GadgetID(1),#TCM_GETITEMRECT,1,r.RECT)
CheckBoxGadget(20,r\right-12,GadgetY(1)+r\top+cbtrim,15,15,"")
BringWindowToTop_(GadgetID(20))

SendMessage_(GadgetID(1),#TCM_GETITEMRECT,2,r.RECT)
CheckBoxGadget(30,r\right-12,GadgetY(1)+r\top+cbtrim,15,15,"")

BringWindowToTop_(GadgetID(30))
DisableGadget(20,1)
DisableGadget(30,1)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
     
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Select EventType()
            Case #PB_EventType_Change
             state = GetGadgetState(1)
              If state = 0
                DisableGadget(10,0)
                DisableGadget(20,1)
                DisableGadget(30,1)
              EndIf
              If state = 1
                DisableGadget(10,1)           
                DisableGadget(20,0)
                DisableGadget(30,1)
              EndIf           
              If state = 2
                DisableGadget(10,1)
                DisableGadget(20,1)
                DisableGadget(30,0)         
              EndIf
          EndSelect
         
        Case 10,20,30
          Debug EventGadget()
          Debug GetGadgetState(EventGadget())
      EndSelect   
  EndSelect
Until Quit = 1
End

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Embed CheckBox into PanelGadget header and trap CheckBox
PostPosted: Thu Jul 04, 2019 11:55 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Jun 23, 2010 5:13 pm
Posts: 206
Rashad, You are faster than 911.
These huge Thanks even not enough for You.
I didn't expect so fast and while searching, found same Your solution with getting rect from NetMaestro's (Add Close buttons to Panel Tabs).
That's why I'd like to thank NetMaestro as well.
Good night my friend.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye