Allright,
1) You create a tab gadget
2) You add all the tabs you want
3) You create as many panels as there are tabs and size them over the tab.
4) You attach all new gadgets to the
panels that have a corresponding tab.
5) You hide every panel except for the active tab panel.
Or an example:
`Start the program and BlueGUI
sync on
startBlue "***", "******"
`Turn the main window into a gadget
hMain = createGadgetFromWindow(MainWindow())
`*** Here it starts ***
`I create a tab gadget
hTab = createTabs(0, 0, gadgetClientWidth(hMain), gadgetClientHeight(hMain), hMain)
`I add (in this example 3) tabs
addTab hTab, "First tab"
addTab hTab, "Second tab"
addTab hTab, "Third tab"
`Now i have to create 3 panels, one for each tab
Tabs = 3
dim TabPanel(Tabs)
for i = 1 to Tabs
TabPanel(i) = createPanel(3, 21, gadgetClientWidth(hTab) - 6, gadgetClientHeight(hTab) - 25, hTab)
next i
`And now, I just add the things for each tab, to the panel you created
`First tab panel
Label1 = createLabel(10, 10, 200, 20, "This is the first tab", TabPanel(1))
`Second tab panel
Label2 = createLabel(10, 10, 200, 20, "This is the second tab", TabPanel(2))
`Third tab panel
Label3 = createLabel(10, 10, 200, 20, "This is the third tab", TabPanel(3))
`Last step in the setup is hide everything except for the first
for i = 1 to Tabs
if selectedTab(hTab) <> i - 1 then setGadgetVisible TabPanel(i), 0
next i
do
getEvent
`***** This is also necessary to make it work *****
`Because we have to be able to change the current tab, we have to change the visible panel too
if eventType() = 513 : `513 is the equivalent of LEFTBUTTON_DOWN
if eventSource() = hTab : `if the tab is the gadget clicked
`We have to make every panel invisible, and the active tab panel visible
for i = 1 to Tabs
if selectedTab(hTab) = i - 1 then setGadgetVisible TabPanel(i), 1 else setGadgetVisible TabPanel(i), 0
next i
endif
endif
sync
loop
- tab numbers start from 0. Therefor you have to decrement i in "if selectedTab(hTab) = i - 1"
- I searched the correct tab position and size already. borders are 3px, and the tab buttons are 21 px high.
It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.