views:

88

answers:

1

For portability, I set the units of my GUIs to 'characters'. Now I have a user who wants to use Matlab on his netbook, and the GUI window is larger than the screen (and thus cropped at the top).

I think I could try and write something in the openingFcn of the GUI that measures screen size and then adjusts the GUI accordingly, but I'd rather avoid that, because I then need to deal with text that is bigger than the text boxes, etc.

What I'd rather like to do is somehow adjust the unit 'character' on his Matlab installation. None of the font sizes in the preferences seem to have an effect on unit:character, though. Does anyone know whether there's a setting for that, which can be changed from within Matlab (I don't mind if it's something that is reset at every reboot, since I can just put it into the startup script)?

+2  A: 

Might I suggest an alternative to consider when designing your GUI:

  • Create all of your GUI objects with the 'FontUnits' property set to 'normalized'.
  • Create the figure with a default size, with everything set to look the way you want.
  • Set one or more of the CreateFcn/OpeningFcn/ResizeFcn functions so they will resize the GUI to fit the screen size.

When the GUI and its objects are resized, the text will resize accordingly, thus helping to avoid text that ends up bigger than the text boxes. One thing to keep note of is that normalized units for the font will interpret the value of 'FontSize' property as a fraction of the height of the uicontrol. I also make it a habit to set the 'FontName' property to 'FixedWidth' to help control the width of the text.

gnovice
Ack! I was afraid you'd say that I have to rework the GUI. Can't I just fix a setting somewhere instead? Please? Anyway, +1 for suggesting a workable plan B.
Jonas
Setting FontSize to 'normalized' programmatically for all the uicontrols in the GUI crashes Matlab for me. I'm setting the font to something small until I figure out what's going on, and it works. Thanks.
Jonas