PanelGadget under OSX

Mac OSX specific forum
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

PanelGadget under OSX

Post by dhouston »

I am trying to port my Windows/Linux app to OSX.

My PanelGadget has 10 tabs. The titles will depend on the user so the overall width is not constant. Both Windows and Linux handle this by scroll buttons at each end when the panel is wider than the main window (not resizable). OSX appears to lop off those on the ends, centering what's left. You can see Windows/Linux screenshots at http://davehouston.org/roZetta.htm.
Last edited by dhouston on Wed Aug 25, 2010 12:42 pm, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: MenuGadget & PanelGadget under OSX

Post by Fred »

You're right, it's a 'known' problem. Actually the OS X API doesn't even support tab scrolling, so we tried to implement some hacks without success. Just ensure than all fit on the screen, or use a different MDI selector, like a listviewgadget().
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: PanelGadget under OSX

Post by dhouston »

Fred wrote:You're right, it's a 'known' problem. Actually the OS X API doesn't even support tab scrolling, so we tried to implement some hacks without success. Just ensure than all fit on the screen, or use a different MDI selector, like a listviewgadget().
OK. I will need to experiment a little. Years ago I had an app where I thought the VB tab control looked too clunky (It had multiple rows when the horizontal space was too small.) so I created a crude one just using...

Code: Select all

| Vertical | Dividers | Between | Titles |
and bolding the selection. Perhaps, I can use buttons and create my own scroll buttons, if needed.
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: PanelGadget under OSX

Post by dhouston »

Perhaps this should be a Feature Request but since it is being discussed here...

I would really like to preserve the "look & feel" of my app across all three versions. I have 10 panels and each panel contains a large ListViewGadget and 7 ButtonGadgets. It makes for a very simple and intuitive user interface.

Fred, would it be possible to add an optional parameter to the PanelGadget that would suppress the drawing of the tabs? That way I could put buttons in place of the tabs and simulate horizontal scrolling of the buttons when necessary. This would preserve the "look & feel" as well as require a minimal amount of recoding (another desire).
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: PanelGadget under OSX

Post by Shardik »

Dave,

have you already tried to switch to small tabs and see whether your 10 tabs are
visible without being cut at the edges of your PanelGadget?

Please try this small code example to see what I mean:

Code: Select all

#kControlEntireControl = 0
#kControlSizeSmall = 1
#kControlSizeTag = 'size'
#kControlTabSizeSmall = #kControlSizeSmall
#noErr = 0

ImportC ""
  SetControlData(Control.L, ControlPartCode.L, TagName.L, BufferSize.L, *Buffer)
EndImport

OpenWindow(0, 0, 0, 320, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget(0, 10, 5, 300, 175)
ButtonGadget(1, 80, 190, 150, 20, "Reduce tab size")

For i = 1 To 5
  AddGadgetItem(0, -1, "Panel " + Str(i))
Next i 

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = 1
        TabSize.W = #kControlTabSizeSmall
        SetControlData(GadgetID(0), #kControlEntireControl, #kControlSizeTag, SizeOf(TabSize), @TabSize)
        SetGadgetState(0, 1)
        DisableGadget(1, #True)
        SetActiveGadget(0)
      EndIf
  EndSelect
ForEver
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: PanelGadget under OSX

Post by dhouston »

@Shardik,

I'm happy with the two main panels dividing things into smaller sub-panels as suggested by Vera in another thread. Since OSX has no menu bar atop the app, the overall size of my main screen stays similar to those for Windows and Linux, maintaining the look and feel across platforms so I don't need to maintain user manuals that have vast differences. See screenshots at...http://davehouston.org/roZetta.htm

The problem is that the PC, Mac, whatever interfaces with an embedded device which has up to 6 serial ports and up to 16 GPIO ports which then interface with multiple devices. The exact configuration depends on just what hardware each end user has. And, there may be as yet unreleased devices for it to interface with, as well. So I need either the flexibility of scrollable tabs or multiple panels.

Still, I'll try your example when I next fire up the Mini. Even if I don't use it in this project, it may be useful in some future project. Thanks for your suggestions both here and in other threads.
http://davehouston.org
Mac Mini (Intel) 10.6.8 - iMac G4 (PPC) 10.4.11
Dell Dimension 2400 W98SE,W2K,XP,Vista,W7,Debian,Ubuntu,Kubuntu,Xubuntu,Fedora,Mandriva,Mint
(on swappable HDDs)
Vizio VTAB1008 - Android 3.1
MK808 miniAndroidPC (Android 4.1)
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: PanelGadget under OSX

Post by Shardik »

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
Post Reply