Developing on Mac, standalone on Windows

Pete pete at mollysrevenge.com
Mon Jan 23 19:19:35 EST 2012


Hi Ken,
Thanks you for the scripts.  I've basically adopted your approach of
setting the font based on what OS I'm running on and that makes things look
a LOT better!  I think property profiles would do the job and I could just
set the appropriate profile based on OS at start up but I need to figure
out a bit more about setting up profiles before even trying that.

Of course, there are still related issues!  For example, I have a series of
buttons with icons associated with them.  Each one also has a label
underneath it.  I carefully centered the button and the label on my Mac
development machine but on the WIndows machine, they're not quite centered,
presumably because of the font change.  Got the same type of issue in other
areas too. Oh well, I guess supporting WIndows as well as Mac is not QUITE
as straightforward as it seems.

I'm also now trying to figure out the best way to deal with screen
size/resolution issues on different computers, whether Mac or Windows.  I
think I've been round this loop once before many months ago and never did
come to a satisfactory resolution (no pun intended!). I thought the
geometry manager would be the way to go but I've seen several comments
about the GM creating a big mess in complicated stacks.

This may be a cop out but I'm included to put all my controls in a group,
set the stack size on startup based on the screen size, and resize the
group to fit the stack.  Then if the controls in the group no longer fit
within it, set the vscrollbar property of the group so the user can scroll
up and down to see everything.

Pete

On Mon, Jan 23, 2012 at 8:10 AM, Ken Ray <kray at sonsothunder.com> wrote:

>
> On Jan 22, 2012, at 11:55 PM, Pete wrote:
>
> > I just compiled and ran my fist standalone on Windows and I'm finally
> > realising the benefits of developing cross platform applications with LC.
> > I was pretty amazed when everything I developed on my Mac just ran as
> > expected on Windows!
> >
> > The on;y problem I need to address concerns fonts.  I have a very few
> > controls that depend on font size to correctly position themselves around
> > other, non-textobjects and it seems that LC's default font on WIndows is
> > different than on a Mac, or at least the font size/spacing is.
> >
> > I left the font and size blank in almost all of my controls' text
> > formatting options but perhaps I need to name a specific font to have
> > things line up correctly on OS X and Windows?
>
> Are you setting font names anywhere in your app or are you defaulting to
> the system fonts for everything? There are generally three schools of
> thought on font/platform management:
>
> 1) Use LC's built in property profiles. It's been a long time since I used
> them, and I came up with my own solution, so I don't really know the pros
> and cons. (Maybe someone else could fill this in?)
>
> 2) Pick a font that will be on all your target systems, and set the font
> of your stack(s) to that font, allowing it to be inherited by all cards and
> card objects.
>        - Pros: Easy to set up and implement
>        - Cons: Significant limitations on font choices; your controls will
> not end up being displayed in OS-compliant fonts; every control that has a
> separate style (like bold) will break the inheritance and you'll have to
> set those manually.
>
> 3) Set the font for your controls by hand, based on platform.
>        - Pros: More control over what's happening; can apply the same text
> attributes to multiple objects by code without having to set individual
> properties on the controls (unless you want to)
>        - Cons: Takes a little time to code and set up
>
> I have been using for a long time a frontscript that traps 'preOpenCard',
> and then just runs through the controls on the card in a repeat loop,
> setting the appropriate text attributes. For those controls that need
> custom styling (like bold, etc.), I check a custom property set and apply
> the styles/sizes/colors if it has them. Here's a scaled-down example of
> what I mean:
>
> -- Frontscript
> on preOpenCard
>  repeat with x = 1 to the number of controls of this card
>    put the customProperties["uTextAttribs"] of control x of this card into
> tAttribsA
>    put "font,style,size,color" into tAttribs
>    repeat for each item tAttrib in tAttribs
>      if tAttribsA[tAttrib] <> "" then
>         do "set the text" & tAttrib && "of control x of this card to
> tAttribsA[tAttrib]"
>      else
>         do "set the text" & tAttrib && "of control x of this card to
> TextAttribs(tAttrib)"
>      end if
>    end repeat
>  end repeat
>  pass preOpenCard
> end preOpenCard
>
> function TextAttribs pAttrib
>  put "font,style,size,color" into tAttribs
>  switch (the platform)
>    case "MacOS"
>      put "Lucida Grande,plain,12,black" into tSysAttribs
>      break
>    case "Win32"
>      if (word 2 of the systemVersion) > 5.1 then
>        put "Segoe UI,plain,12,black" into tSysAttribs
>      else
>        put "Tahoma,plain,11,black" into tSysAttribs
>      end if
>      break
>  end switch
>  return item (itemOffset(pAttrib,tAttribs)) of tSysAttribs
> end TextAttribs
>
> Obviously this doesn't handle a bunch of situations, isn't optimized, and
> is primarily meant to give you an idea how this can work. But LC is so fast
> that even with dozens of controls, the time to set the properties is not
> noticeable.
>
> Hope this helps,
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list