I just discovered in the header file HITheme.h of my OS X 10.6 SDK
that there even exits a Mini tab size which is even smaller than
kControlSizeSmall in my previous code example. Therefore I want
to present a new example which toggles between 3 tab sizes:
normal, small and mini.
Another interesting feature of this example is that I solved the
problem of redraw errors in the PanelGadget. To see what I mean
simply comment out the line
Code: Select all
InvalWindowRect(WindowID(0), @Bounds)
The tabs are redrawn by Draw1Control_() but the window background
is not updated. Therefore the need to invalidate the area around the
tabs by InvalWindowRect() so that MacOS is informed to redraw the
given area behind the tabs.
Hint to Fred and freak:
This also might be a solution to solve Andre's bug posting
Refreshing
with Container &small ListIcon or to eliminate the drawing artefact of
my bug posting
[4.60 B1] New Mac help: no positioning and drawing
artefact...
Code: Select all
EnableExplicit
ImportC ""
InvalWindowRect(WindowRef.L, *Bounds)
SetControlData(Control.L, ControlPartCode.L, TagName.L, BufferSize.L, *Buffer)
EndImport
#kControlEntireControl = 0
#kHIThemeTabSizeMini = 3
#kHIThemeTabSizeNormal = 0
#kHIThemeTabSizeSmall = 1
#kControlSizeTag = 'size'
Structure Rect
Top.W
Left.W
Bottom.W
Right.W
EndStructure
Define Bounds.Rect
Define GadgetID.L
Define i.L
Dim TabSize.W(2)
TabSize(0) = #kHIThemeTabSizeNormal
TabSize(1) = #kHIThemeTabSizeSmall
TabSize(2) = #kHIThemeTabSizeMini
OpenWindow(0, 270, 100, 320, 245, "Change Tab size of PanelGadget")
PanelGadget(0, 10, 5, 300, 175)
Frame3DGadget(1, 10, 190, WindowWidth(0) - 20, 45, "Tab size:")
OptionGadget(2, GadgetX(1) + 10, GadgetY(1) + 18, 70, 20, "Normal")
OptionGadget(3, GadgetX(1) + 120, GadgetY(1) + 18, 60, 20, "Small")
OptionGadget(4, GadgetX(1) + 230, GadgetY(1) + 18, 50, 20, "Mini")
SetGadgetState(2, #True)
For i = 1 To 4
AddGadgetItem(0, -1, "Panel " + Str(i))
Next i
Bounds\Left = 0
Bounds\Top = 0
Bounds\Right = WindowWidth(0)
Bounds\Bottom = 40
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
GadgetID = EventGadget()
Select GadgetID
Case 2 To 4
SetControlData(GadgetID(0), #kControlEntireControl, #kControlSizeTag, 2, @TabSize(GadgetID - 2))
Draw1Control_(GadgetID(0))
InvalWindowRect(WindowID(0), @Bounds)
EndSelect
EndSelect
ForEver
An alternative way to display lots of tabs would be to use the new
CanvasGadget in the way it is implemented cross-platform in the
new PB IDE of 4.60. STARGĂ…TE has posted an image and a download
link to his nice TabBarGadget:
http://www.purebasic.fr/english/viewtop ... 12&t=47588