Page 1 of 1

Tabless panel

Posted: Fri Jul 16, 2021 12:01 pm
by Joestes
Does anyone know if it is possible to remove the top section of a panelgadget?

What I'm looking for is a "tabless panel", in which the panels can only be changed programmatically with setGadgetState(#panel, tab)

I forgot to mention, that I'm running Windows, cross-platform is not an issue for me.

Re: Tabless panel

Posted: Fri Jul 16, 2021 12:24 pm
by firace
Hi, standard Windows controls don't really support this, but try this solution I found a while ago:

Code: Select all


Procedure FlatPanelGadget(n, x, y, w, h)  
  
  ContainerGadget(3322, x, y, w, h)
  PanelGadget(n, 1, -28, w, h) 
  CloseGadgetList() 
  CloseGadgetList()
  
  SetWindowLongPtr_(GadgetID(n), #GWL_STYLE, GetWindowLongPtr_(GadgetID(n), #GWL_STYLE) | #TCS_BUTTONS|#TCS_FLATBUTTONS) 
  
EndProcedure  


OpenWindow(0, 300, 300, 500, 350,  "FlatPanelGadget test", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget, 0)

FlatPanelGadget(0, 10, 10, 400, 300)

OpenGadgetList(0)

For i = 0 To 4 ;; add 5 tabs to the PanelGadget
  AddGadgetItem(0, i, "Tab " + Str(i)) 
  TextGadget(300+i, 60, 60, 100, 40, "PAGE CONTENT " + i)
  ButtonGadget(200+i,1,1,200,20,"Button " + i)
Next 

CloseGadgetList() 

AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_K, 123) ;; test: Ctrl+K to show tab #2


Repeat
  e = WaitWindowEvent()
  Select e
    Case  #PB_Event_Menu
      SetGadgetState(0, 2)
    Case  #PB_Event_CloseWindow : End
  EndSelect
ForEver


Re: Tabless panel

Posted: Fri Jul 16, 2021 12:31 pm
by zikitrake

Re: Tabless panel

Posted: Fri Jul 16, 2021 12:43 pm
by RASHAD
Simple and maybe cross platform

Code: Select all

flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"Test",Flags)
ContainerGadget(10,10,10,306,180)
  PanelGadget     (0, 0,-30, 306, 203)
    AddGadgetItem (0, -1, "Panel 1")
      PanelGadget (1, 5, 5, 290, 166)
        AddGadgetItem(1, -1, "Sub-Panel 1")
        AddGadgetItem(1, -1, "Sub-Panel 2")
        AddGadgetItem(1, -1, "Sub-Panel 3")
      CloseGadgetList()
    AddGadgetItem (0, -1,"Panel 2")
      ButtonGadget(2, 10, 15, 80, 24,"Button 1")
      ButtonGadget(3, 95, 15, 80, 24,"Button 2")
  CloseGadgetList()
CloseGadgetList()

ButtonGadget(20,10,270,60,24,"RUN")

Repeat           
  Select WaitWindowEvent()      
    Case #PB_Event_CloseWindow
      Quit = 1 
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 20
          Run ! 1
          If Run = 1
            SetGadgetState(0,1)
          Else
            SetGadgetState(0,0)
          EndIf
      EndSelect 
  EndSelect 
  
Until Quit = 1
End


Re: Tabless panel

Posted: Fri Jul 16, 2021 1:08 pm
by Joestes
zikitrake wrote: Fri Jul 16, 2021 12:31 pm You can try RASHAD code
or STARGATE TabBarGadget
I have tried the TabBarGadget library, buy I can't figure out how to set it up like the panel gadget of PB: For example if i want multiple editorgadgets on the tabs, simply hiding/unhiding the gadgets when the tab is changed doesn't seem possible in a (flickerless) way :(

Re: Tabless panel

Posted: Fri Jul 16, 2021 1:46 pm
by RASHAD
No Tabs using Windows API

Code: Select all

flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"Test",Flags)
PanelGadget     (0, 10,10, 306, 203)
AddGadgetItem (0, -1, "Panel 1")
PanelGadget (1, 5, 5, 290, 166)
AddGadgetItem(1, -1, "Sub-Panel 1")
AddGadgetItem(1, -1, "Sub-Panel 2")
AddGadgetItem(1, -1, "Sub-Panel 3")
CloseGadgetList()
AddGadgetItem (0, -1,"Panel 2")
ButtonGadget(2, 10, 15, 80, 24,"Button 1")
ButtonGadget(3, 95, 15, 80, 24,"Button 2")
CloseGadgetList()
SetWindowLongPtr_( GadgetID(0), #GWL_STYLE, GetWindowLongPtr_( GadgetID(0), #GWL_STYLE )|#TCS_FIXEDWIDTH )
SendMessage_( GadgetID(0), #TCM_SETITEMSIZE, 0, 1<<16 | 0 )

;For PanelGadget 1
;SetWindowLongPtr_( GadgetID(1), #GWL_STYLE, GetWindowLongPtr_( GadgetID(1), #GWL_STYLE )|#TCS_FIXEDWIDTH )
;SendMessage_( GadgetID(1), #TCM_SETITEMSIZE, 0, 1<<16 | 0 )
SetGadgetState(0,1)
ButtonGadget(20,10,270,60,24,"RUN")

Repeat           
  Select WaitWindowEvent()      
    Case #PB_Event_CloseWindow
      Quit = 1 
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 20
          Run ! 1
          If Run = 0
            SetGadgetState(0,1)
          Else
            SetGadgetState(0,0)
          EndIf
      EndSelect 
  EndSelect 
  
Until Quit = 1
End


Re: Tabless panel

Posted: Sat Jul 17, 2021 11:19 am
by blueb
Not directly related, but you might look at Mohsen's example of using buttons to modify panels, etc.
It may give you a few ideas.

xButtonGadget (include file, and sample file below this post)
viewtopic.php?p=555070#p555070