Skip to content

Commit a534a88

Browse files
committed
Add demo GUI, README
1 parent 635c59c commit a534a88

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

Demo/DOMdemoGUI.m

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
classdef DOMdemoGUI < matlab.apps.AppBase
2+
3+
% Properties that correspond to app components
4+
properties (Access = public)
5+
UIFigure matlab.ui.Figure % UI Figure
6+
LabelTextArea matlab.ui.control.Label % Text Area
7+
TextArea matlab.ui.control.TextArea % This is some text.
8+
end
9+
10+
methods (Access = private)
11+
% Code that executes after component creation
12+
function startupFcn(app)
13+
end
14+
end
15+
16+
% App initialization and construction
17+
methods (Access = private)
18+
19+
% Create UIFigure and components
20+
function createComponents(app)
21+
% Create UIFigure
22+
app.UIFigure = uifigure;
23+
app.UIFigure.Position = [100 100 280 102];
24+
app.UIFigure.Name = 'UI Figure';
25+
setAutoResize(app, app.UIFigure, true)
26+
27+
% Create LabelTextArea
28+
app.LabelTextArea = uilabel(app.UIFigure);
29+
app.LabelTextArea.HorizontalAlignment = 'right';
30+
app.LabelTextArea.Position = [16 73 62 15];
31+
app.LabelTextArea.Text = 'Text Area';
32+
33+
% Create TextArea
34+
app.TextArea = uitextarea(app.UIFigure);
35+
app.TextArea.Position = [116 14 151 60];
36+
app.TextArea.Value = {'This is some text.'};
37+
end
38+
end
39+
40+
methods (Access = public)
41+
42+
% Construct app
43+
function app = DOMdemoGUI()
44+
% Create and configure components
45+
createComponents(app)
46+
47+
% Register the app with App Designer
48+
registerApp(app, app.UIFigure)
49+
50+
% Execute the startup function
51+
runStartupFcn(app, @startupFcn)
52+
53+
if nargout == 0
54+
clear app
55+
end
56+
end
57+
58+
% Code that executes before app deletion
59+
function delete(app)
60+
% Delete UIFigure when app is deleted
61+
delete(app.UIFigure)
62+
end
63+
end
64+
end

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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

Comments
 (0)