Tabless panel

Just starting out? Need help? Post your questions and find answers here.
Joestes
User
User
Posts: 25
Joined: Thu Mar 19, 2009 12:42 pm
Location: Utrecht, The Netherlands

Tabless panel

Post 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.
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: Tabless panel

Post 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

zikitrake
Addict
Addict
Posts: 834
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Re: Tabless panel

Post by zikitrake »

RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4637
Joined: Sun Apr 12, 2009 6:27 am

Re: Tabless panel

Post 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

Egypt my love
Joestes
User
User
Posts: 25
Joined: Thu Mar 19, 2009 12:42 pm
Location: Utrecht, The Netherlands

Re: Tabless panel

Post 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 :(
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4637
Joined: Sun Apr 12, 2009 6:27 am

Re: Tabless panel

Post 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

Egypt my love
User avatar
blueb
Addict
Addict
Posts: 1041
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Tabless panel

Post 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
- It was too lonely at the top.

System : PB 6.10 Beta 9 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply