Creating Graphical User Interfaces    

Designing for Cross-Platform Compatibility

You can use specific property settings to create a GUI that behaves more consistently when run on different platforms.

Using the System Font

By default, uicontrols use the default font for the platform on which it is running. For example, when displaying your GUI on PCs, it uses MS San Serif. When your GUI runs on a different platform, it uses that computer's default font. This provides a consistent look with respect to your GUI and other application GUIs.

If you have set the FontName property to a named font and want to return to the default value, you can set the property to the string default. This ensures MATLAB uses the system default at run time.

Specifying a Fixed-Width Font

If you want to use a fixed-width font for a uicontrol, set its FontName property to the string fixedwidth. This special identifier ensures that your GUI uses the standard fixed-width font for the target platform.

You can find the name of the fixed-width font that is used on a given platform by querying the root FixedWidthFontName property.

Using a Specific Font Name

You can specify an actual font name (such as Times or Courier) for the FontName property. However, doing so may cause your GUI to look poorly when run on a different computer. If the target computer does not have the specified font, it will substitute another font that may not look good in your GUI or may not be the standard font used for GUIs on that system. Also, different versions of the same named font may have different size requirements for a given set of characters.

Using Standard Background Color

By default, uicontrols use the standard background color for the platform on which it is running (e.g., the standard shade of gray on the PC differs from that on UNIX). When your GUI is deployed on a different platform, it uses that computer's standard color. This provides a consistent look with respect to your GUI and other application GUIs.

If you change the BackgroundColor to another value, MATLAB always uses the specified color.

Cross-Platform Compatible Figure Units

Cross-platform compatible GUIs must look correct on computers having different size screens and different resolutions. Since the size of a pixel can vary on different computer displays, using the default figure Units of pixels does not produce a GUI that looks the same on all platforms.

System-Dependent Units

Figure character units are defined by characters from the default system font; the width of one character is the width of the letter x. The height of one character is the distance between the baselines of two lines of text (note that character units are not square).

Setting figure Units to characters enables you to develop a GUI that automatically adjusts the relative spacing and size of components as the GUI displays on different computers. For example, if the size of the text label on a component becomes larger because the system font metrics are different, then the component and the relative spacing increase proportionally.

GUIDE sets the figure Units to characters by default.


 Application-Defined Data Types of Callbacks