Skip to content

davidn-IA/mlapptools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimum Version

mlapptools

mlapptools is a collection of static methods for customizing the R2016a-introduced web-based uifigure windows and associated UI elements through DOM manipulations.

For additional information, see Iliya Romm's Undocumented Matlab guest article, Customizing uifigures part 2, published Wednesday, September 7th, 2016.

Contact us

Methods

aboutDojo - Return the dojo toolkit version.
fontColor - Modify font color.
fontWeight - Modify font weight.
getHTML - Return the full HTML code of a uifigure.
getWebElements - Extract a webwindow handle and a widget ID from a uifigure control handle.
getWebWindow - Extract a webwindow handle from a uifigure handle.
getWidgetInfo - Gather information about a specific dijit widget.
getWidgetList - Gather information about all dijit widget in a specified uifigure.
setStyle - Modify a specified style property.
setTimeout - Override the default timeout for dojo commands, for a specific uifigure.
textAlign - Modify text alignment.

mlapptools.aboutDojo()

Description

Returns a struct containing version information about the Dojo toolkit loaded into the first open uifigure. If no uifigure is open, a temporary window is created, queried, then closed - indicating the default Dojo version.

Examples
>> mlapptools.aboutDojo()

ans = 

  struct with fields:

       major: 1
       minor: 11
       patch: 2
        flag: ''
    revision: '91fa0cb'

mlapptools.fontColor(uiElement, newcolor)

Description

Set the font color of the specified UI element, 'uiElement', to the input color, newcolor. newcolor can be a predefined color string or a string containing a valid CSS color method call.

Valid color specifications are:

  • Hexadecimal colors - e.g. '#ff0000' for red
  • RGB colors - e.g. 'rgb(255,165,0)' for orange
  • RGBA colors - e.g. 'rgba(255,255,0,0.3)' for yellow
  • HSL colors - e.g. 'hsl(120, 100%, 50%)' for green
  • HSLA colors - e.g. 'hsla(240,100%,50%, 1.0)' for blue
  • Predefined color names - e.g. 'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'. For more colors, see the predefined color names CSS color specification.
Examples

Using the demo GUI generated by ./Demo/DOMdemoGUI.m

myGUI = DOMdemoGUI;
mlapptools.fontColor(myGUI.TextArea, 'aqua');
myGUI = DOMdemoGUI;
mlapptools.fontColor(myGUI.TextArea, 'rgb(255,165,0)');

mlapptools.fontWeight(uiElement, weight)

Description

Set the font weight of the specified UI element, uiElement, to the input weight string or integer, weight. For this setting to have an effect, the font being used must have built-in faces that match the specified weight.

Valid font weight property values are:

  • 'normal' - Normal characters (default)
  • 'bold' - Thick characters
  • 'lighter' / 'bolder' - The closest available "lighter" or "bolder" weight, relative to the parent.
  • 100 .. 900 - Integers mapping to 'normal', 'bold', etc. Intermediate integers (and floats) are accepted but generally map to the available values
  • 'initial' - Revert to default
Examples

Using the demo GUI generated by ./Demo/DOMdemoGUI.m

myGUI = DOMdemoGUI;
mlapptools.fontWeight(myGUI.TextArea, 'bold');
myGUI = DOMdemoGUI;
mlapptools.fontWeight(myGUI.TextArea, 600);

mlapptools.getHTML(hUIFigure)

Description

A method for obtaining the HTML code of a uifigure. Intended for R2017b (and onward?) where the CEF URL cannot be simply opened in a browser. The returned HTML is a deep copy, meaning that any changes will not modify the uifigure where it originated from.

Examples

Using the demo GUI generated by ./Demo/DOMdemoGUI.m

myGUI = DOMdemoGUI;
fullHTML = mlapptools.getHTML(myGUI.UIFigure);
web(['text://' fullHTML]);

mlapptools.getWebElements(uiElement)

Description

A method for obtaining the webwindow handle and the widget ID corresponding to the provided uifigure control. The widget ID can be used to call the 4-parameter variant of setStyle.

Examples
myGUI = DOMdemoGUI;
[win, widgetID] = mlapptools.getWebElements(myGUI.TextArea);

mlapptools.getWebWindow(hUIFigure)

Description

A method for getting the webwindow handle associated with the provided uifigure.

Examples

Using the demo GUI generated by ./Demo/DOMdemoGUI.m

myGUI = DOMdemoGUI;
win = mlapptools.getWebWindow(myGUI.UIFigure);

mlapptools.getWidgetInfo(hWebwindow, widgetID, verbosityFlag)

Description

Query the dijit registry for a widgets having a specific ID, and return its details in a scalar cell containing a struct.

Examples

Using the demo GUI generated by ./Demo/DOMdemoGUI.m

myGUI = DOMdemoGUI;
[win, widgetID] = mlapptools.getWebElements(myGUI.TextArea);
nfo = mlapptools.getWidgetInfo(win, widgetID);

mlapptools.getWidgetList(hUIFigure, verbosityFlag)

Description

Query the dijit registry for all widgets within the current page, and return them in a cell array of structs.

Examples

Using the demo GUI generated by ./Demo/DOMdemoGUI.m

myGUI = DOMdemoGUI;
nfoList = mlapptools.getWidgetList(myGUI.UIFigure);

mlapptools.setStyle(uiElement, styleAttr, styleValue)

Description

Set the style attribute styleAttr of the specified UI element, 'uiElement', to the value styleValue. styleAttr should be any valid CSS attribute, and styleValue a valid setting thereof.

This method provides a general interface to change CSS style attributes, with minimal input testing and error reporting, so it is up to the user to provide valid inputs.

Valid style attributes and corresponding settings can be found here.

Examples

Using the demo GUI generated by ./Demo/DOMdemoGUI.m

myGUI = DOMdemoGUI;
mlapptools.setStyle(myGUI.TextArea, 'background-image',...
 'url(https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg)');

mlapptools.setTimeout(hUIFig)

Description

Modify the amount of time allotted to dojo queries before they are considered "failed due to timeout". This value is uifigure-specific. If left unmodified, the default value is 5 seconds.

Examples
myGUI = DOMdemoGUI;
mlapptools.setTimeout(myGUI.UIFigure, 3); % This will wait less for dojo queries to finish.

mlapptools.textAlign(uiElement, alignment)

Description

Set the horizontal text alignment of the specified UI element, uiElement, to that specified by the input alignment string, alignment.

Valid alignment strings are:

  • 'left' - Left align (default)
  • 'center' - Center align
  • 'right' - Right align
  • 'justify' - Each line has equal width
  • 'initial' - Revert to default
Examples

Using the demo GUI generated by ./Demo/DOMdemoGUI.m

myGUI = DOMdemoGUI;
mlapptools.textAlign(myGUI.TextArea, 'center');
myGUI = DOMdemoGUI;
mlapptools.textAlign(myGUI.TextArea, 'right');

About

MATLAB class containing methods for programmatic uifigure modification

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • MATLAB 100.0%