Matlab_GUI study notes (3) - Figure of the properties of common objects
1. Figure
Use the get function to easily view the properties of each object. Some properties can be roughly judged by their names. For example, the property of Figure is the CloseRequestFcn
function to be called when the form is closed; CurrentCharacter
the property is the current character, that is, if the form can In response to keyboard events, use this property to get which key we pressed.
>>get(figure)
Alphamap: [1×64 double]
BeingDeleted: 'off'
BusyAction: 'queue'
ButtonDownFcn: ''
Children: [0×0 GraphicsPlaceholder]
Clipping: 'on'
CloseRequestFcn: 'closereq'
Color: [0.9400 0.9400 0.9400]
Colormap: [64×3 double]
CreateFcn: ''
CurrentAxes: [0×0 GraphicsPlaceholder]
CurrentCharacter: ''
CurrentObject: [0×0 GraphicsPlaceholder]
CurrentPoint: [0 0]
DeleteFcn: ''
DockControls: 'on'
FileName: ''
GraphicsSmoothing: 'on'
HandleVisibility: 'on'
InnerPosition: [488 342 560 420]
IntegerHandle: 'on'
Interruptible: 'on'
InvertHardcopy: 'on'
KeyPressFcn: ''
KeyReleaseFcn: ''
MenuBar: 'figure'
Name: ''
NextPlot: 'add'
Number: 2
NumberTitle: 'on'
OuterPosition: [481 334.6000 574.4000 457.6000]
PaperOrientation: 'portrait'
PaperPosition: [3.0917 9.2937 14.8167 11.1125]
PaperPositionMode: 'auto'
PaperSize: [21.0000 29.7000]
PaperType: 'A4'
PaperUnits: 'centimeters'
Parent: [1×1 Root]
Pointer: 'arrow'
PointerShapeCData: [16×16 double]
PointerShapeHotSpot: [1 1]
Position: [488 342 560 420]
Renderer: 'opengl'
RendererMode: 'auto'
Resize: 'on'
Scrollable: 'off'
SelectionType: 'normal'
SizeChangedFcn: ''
Tag: ''
ToolBar: 'auto'
Type: 'figure'
UIContextMenu: [0×0 GraphicsPlaceholder]
Units: 'pixels'
UserData: []
Visible: 'on'
WindowButtonDownFcn: ''
WindowButtonMotionFcn: ''
WindowButtonUpFcn: ''
WindowKeyPressFcn: ''
WindowKeyReleaseFcn: ''
WindowScrollWheelFcn: ''
WindowState: 'normal'
WindowStyle: 'normal'
-
As can be seen from the above get results, CloseRequestFcn directly points to the function, that is, the form can be closed by calling this function. Next, we create a button in the figure to achieve this function.
CloRequestFcn
closereq
hf = figure; hb = uicontrol('Style', 'pushbutton', 'Callback', 'closereq');
-
The color attribute of the Color
form can be controlled to change the color of the form, and the parameter can be a character or an RGB value.set(hf, 'Color', 'w') %将颜色设置为白色
-
CurrentAxes If a child object
is added in the form , it points to the handle of the current coordinate axis object.Axes
CurrentAxes
-
CurrentCharacter
If the form can respond to keyboard events, itCurrentCharacter
points to the current key value. -
If CurrentObject puts a curve in it, it points to the current curve object.
CurrentAxes
CurrentObject
-
CurrentPoint
CurrentPoint
is the current pointing position of the mouse. -
Menubar
Menubar
is the menu bar of the form. The default is,figure
that is, our common default menu bar. If the window you create does not want this column, you can modify its properties through the set function.set(hf, 'Menubar', 'none');
-
Name&NumberTitle
Name
andNumberTitle
can be used together to name the form. As default is set toFigure 1
.set(hf, 'NumberTitle', 'off', 'Name', 'Instance' );
-
Nextplot
Nextplot
indicates whether to overwrite the original image and redraw it next time, or to add it directly on the original basis. -
Position&Units
Position
isUnits
used in conjunction with general. If the unit is set to normalization, then the position parameter is set between 0-1, that is, the relative position is taken, and a relatively uniform layout can be obtained on screens with different resolutions.set(hf, 'Units', 'Normalized', 'Position', '[0.2,0.2,0.6,0.8]);
-
Resize,
as the nameResize
suggests, indicates whether the form can be resized again by clicking and dragging the mouse. With the property set to off, the form can no longer be resized.set(hf, 'Resize', 'off');
-
The callback functions starting with Window…(series) have similar basic functions. The following uses the combined functions as an example to illustrate how to use them:
Window
WindowButtonDownFcn
WindowKeyPressFcn
closereq
set(hf, 'WindowButtonDownFcn', 'closereq'); set(hf, 'WindowKeyPressFcn', 'closereq');
Clicking anywhere on the form with the mouse or pressing any key on the keyboard will close the form.
-
WindowStyle
sets the window mode, which can be set to dialog mode, that is, the window cannot be closed by clicking any irrelevant position on the screen.set(hf, 'WindowStyle', 'modal');
-
Whether the Visible
form is visible or not is used in some programs that call multiple sub-windows to avoid opening and displaying many windows at one time.pause(3) set(hf, 'Visable', 'off') pause(3) set(hf, 'Visable', 'on')