|
| 1 | +# mlapptools |
| 2 | +`mlapptools` is an example set of static MATLAB methods for manipulating the DOM underlying the App Designer UI elements formally introduced in R2016a |
| 3 | + |
| 4 | +For additional information, see Iliya Romm's guest Undocumented Matlab article, [*Customizing uifigures part 2*](http://undocumentedmatlab.com/blog/customizing-uifigures-part-2), published Wednesday, September 7th, 2016 |
| 5 | + |
| 6 | +## Methods |
| 7 | +[`textAlign`](#textAlign) - Modify text alignment |
| 8 | +[`fontWeight`](#fontWeight) - Modify font weight |
| 9 | +[`fontColor`](#fontColor) - Modify font folor |
| 10 | + |
| 11 | +<a name="textAlign"></a> |
| 12 | +#### *mlapptools*.**textAlign**(*uielement*, *alignment*) |
| 13 | +##### Description |
| 14 | +Set the horizontal text alignment of the specified UI element, `uielement`, to that specified by the input alignment string, `alignment`. |
| 15 | + |
| 16 | +Valid alignment strings are: |
| 17 | + * `'left'` - Left align (default) |
| 18 | + * `'center'` - Center align |
| 19 | + * `'right'` - Right align |
| 20 | + * `'justify'` - Each line has equal width |
| 21 | + * `'initial'` - Revert to default |
| 22 | + |
| 23 | +##### Examples |
| 24 | +Using the demo GUI generated by `./Demo/DOMdemoGUI.m` |
| 25 | + |
| 26 | +```MATLAB |
| 27 | +myGUI = DOMdemoGUI; |
| 28 | +mlapptools.textAlign(myGUI.TextArea, 'center'); |
| 29 | +``` |
| 30 | + |
| 31 | +```MATLAB |
| 32 | +myGUI = DOMdemoGUI; |
| 33 | +mlapptools.textAlign(myGUI.TextArea, 'right'); |
| 34 | +``` |
| 35 | + |
| 36 | +<a name="fontWeight"></a> |
| 37 | +#### *mlapptools*.**fontWeight**(*uielement*, *weight*) |
| 38 | +##### Description |
| 39 | +Set the font weight of the specified UI element, `uielement`, to the input weight string or integer, `weight`. |
| 40 | + |
| 41 | +Valid font weight property values are: |
| 42 | + * `'normal'` - Normal characters (default) |
| 43 | + * `'bold'` - Thick characters |
| 44 | + * `'bolder'` - Thicker characters |
| 45 | + * `[400, 600, 800]` - Integers mapping to `'normal'`, `'bold'`, and `'bolder'`. Intermediate integers (and floats) are accepted but generally map to these 3 values |
| 46 | + * `'initial'` - Revert to default |
| 47 | + |
| 48 | +##### Examples |
| 49 | +Using the demo GUI generated by `./Demo/DOMdemoGUI.m` |
| 50 | + |
| 51 | +```MATLAB |
| 52 | +myGUI = DOMdemoGUI; |
| 53 | +mlapptools.fontWeight(myGUI.TextArea, 'bold'); |
| 54 | +``` |
| 55 | + |
| 56 | +```MATLAB |
| 57 | +myGUI = DOMdemoGUI; |
| 58 | +mlapptools.fontWeight(myGUI.TextArea, 600); |
| 59 | +``` |
| 60 | + |
| 61 | +<a name="fontColor"></a> |
| 62 | +#### *mlapptools*.**fontColor**(*uielement*, *newcolor*) |
| 63 | +##### Description |
| 64 | +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. |
| 65 | + |
| 66 | +Valid color specifications are: |
| 67 | + * Hexadecimal colors - e.g. `'#ff0000'` for red |
| 68 | + * RGB colors - e.g. `'rgb(255,165,0)'` for orange |
| 69 | + * RGBA colors - e.g. `'rgba(255,255,0,0.3)'` for yellow |
| 70 | + * HSL colors - e.g. `'hsl(120, 100%, 50%)'` for green |
| 71 | + * HSLA colors - e.g. `'hsla(240,100%,50%, 1.0)'` for blue |
| 72 | + * Predefined color names - e.g. `'red'`, `'orange'`, `'yellow'`, `'green'`, `'blue'`, `'indigo'`, `'violet'`. For more colors, see the predefined color names [CSS color specification](https://www.w3.org/TR/css3-color/). |
| 73 | + |
| 74 | +##### Examples |
| 75 | +Using the demo GUI generated by `./Demo/DOMdemoGUI.m` |
| 76 | + |
| 77 | +```MATLAB |
| 78 | +myGUI = DOMdemoGUI; |
| 79 | +mlapptools.fontColor(myGUI.TextArea, 'aqua'); |
| 80 | +``` |
| 81 | + |
| 82 | +```MATLAB |
| 83 | +myGUI = DOMdemoGUI; |
| 84 | +mlapptools.fontColor(myGUI.TextArea, 'rgb(255,165,0)'); |
| 85 | +``` |
0 commit comments