Saving seperate interface layouts for diff operating systems

Disclaimer: This may indeed be a ‘dumb…?’ question.

I have a project I’m working on now that is intended to be multi-platform :wink:

But… as luck would have it… mac and windows do not see eye-to-eye on layout formats, and as such I have to rearrange buttons, text sizes etc., over and over for each release… I know this can’t be the way its done… Can anyone point me in the right direction here?

How can i save alternate layouts ?

I don’t think you should have to resize text and rearrange buttons, if you’re doing that you may want to consider redesigning your interface. The only interface differences I have in my app are slight nudges in positioning and size for a few elements, which are handled with #if statements in the window open event.

I suppose if two separate interfaces were necessary you could use container controls and load the appropriate one per OS. But then you’d have to have an intricate web of methods to avoid having to code everything twice.

Have a look at container controls. I also build for both Mac and Win and I use containers extensively to create different looks for the platform in question. You can hide or show various containers as you may need. You can also build a separate container to deal with a specific GUI issus. For instance, mac and win want their “Accept” and “Cancel” buttons in different order. Create a container which handles that issue via platform specific constants and just drop it into the Window when you need it.

Have a peek at http://great-white-software.com/gws-rb-samples/StdControls.zip
Theres a sample in there of a container that will rearrange itself for the OK and Cancel buttons depending on the platform you’re using it on

There’s a calendar control in there too (doesn’t everyone have one)

You can just resolve any conflicts & update it - it was originally written in 2005 :stuck_out_tongue:

I’m having the same thing, to me it seems to be the font size difference is causing most of my issues which was the case doing QT applications also , with that you just specify which font and size to use as the form opens I don’t know if you can do that with Xojo

At least Xojo doesn’t switch the text alignment like QT, that really messes things up :confused:

I really don’t like posting code snippets as I no expert, but this seems to work for me
I can’t take any credit apart from fixing it up and travelled of the tinternet

Just change the form name “Main” to whatever your form/forms are, also the font names I’m developing on Windows so my default was System

[code] Dim X as Integer
if Main.ControlCount>-1 then

for X = 0 to Main.ControlCount -1
  
  if Main.Control(X) isa TextField then
    
    #If TargetWin32 then
      if TextField(Main.Control(X)).TextFont="System" then
        TextField(Main.Control(X)).TextSize= 12
      end if
    #endif
    
  elseif Main.Control(X) isa PushButton then
    
    #IF TargetMacOS
      PushButton(Main.Control(X)).Height"22"
      'windows pushbuttons are 24 pixels high, Mac are 22 high
      PushButton(Main.Control(X)).Top =
      PushButton(Main.Control(X)).Top+2 'Scoot them down 2 pixels to make up for shorter height
    #endif
    
    #If TargetWin32 then
      if PushButton(Main.Control(X)).TextFont="System" then
        PushButton(Main.Control(X)).TextSize= 12
      end if
      
    #endif
  end if
next

end if
[/code]

If its not a good solution please say!

You could also put the desired text size in a constant and define different values per platform.

It’s worse than that. The offset to the baseline change, so in one of my apps, for exactly the same font of mine used on the two platforms, I have to move labels some 15 points vertically for size 20 (which renders the same size on both Mac and Windows). So the change in platform requires also to tweak top.

I’ve seen people subclass each of the controls making ones that play nice on all platforms. For instance, if on Windows you wanted the buttons to be 2 pixels taller, you’d have something like this in the Open event:

#if targetWin32 Self.top=self.top-1 Self.height=self.height+2 #endif

[quote=129071:@nige cope]I really don’t like posting code snippets as I no expert, but this seems to work for me
I can’t take any credit apart from fixing it up and travelled of the tinternet

Just change the form name “Main” to whatever your form/forms are, also the font names I’m developing on Windows so my default was System

[code] Dim X as Integer
if Main.ControlCount>-1 then

for X = 0 to Main.ControlCount -1
  
  if Main.Control(X) isa TextField then[/code]

If its not a good solution please say![/quote]

I noticed you mentioned the word form… Does that apply for window… I just have a window with tons of co trols on it… So does window1.controlCount work ? Or would it be app… Or am I doing it wrong ? Lol

Also just to clarify the #if means compiler instruction right ? So its only compiled into the executable if it fits the condition ?

So you wouldn’t used standard if statement cause then your causing needless extra processing right ?

[quote=129033:@Norman Palardy]
Have a peek at http://great-white-software.com/gws-rb-samples/StdControls.zip
There’s a calendar control in there too (doesn’t everyone have one)[/quote]

here two versions of it

english

german

[quote=129118:@Axel Schneider]here two versions of it

english

german
[/quote]

That shameless plug tho. Lol