Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
17
Добавлен:
09.02.2015
Размер:
257.02 Кб
Скачать

Itself, or any object contained in the figure.

HANDLES = GUIHANDLES returns a structure of handles for the

current figure.

Example:

Suppose an application creates a figure with handle F, containing

a slider and an editable text uicontrol whose tags are 'valueSlider'

and 'valueEdit' respectively. The following excerpts from the

application's MATLAB file illustrate the use of GUIHANDLES in callbacks:

... excerpt from the GUI setup code ...

f = figure;

uicontrol('Style','slider','Tag','valueSlider', ...);

uicontrol('Style','edit','Tag','valueEdit',...);

... excerpt from the slider's callback ...

handles = guihandles(gcbo); % generate handles struct

set(handles.valueEdit, 'string',...

num2str(get(handles.valueSlider, 'value')));

... excerpt from the edit's callback ...

handles = guihandles(gcbo);

val = str2double(get(handles.valueEdit,'String'));

if isnumeric(val) & length(val)==1 & ...

val >= get(handles.valueSlider, 'Min') & ...

val <= get(handles.valueSlider, 'Max')

% update the slider's value if the edit's value is OK:

set(handles.valueSlider, 'Value', val);

else

% flush the bad string out of the edit; replace with slider's

% current value:

set(handles.valueEdit, 'String',...

num2str(get(handles.valueSlider, 'Value')));

end

Note that in this example, the structure of handles is created

each time a callback executes. See the GUIDATA help for an

example in which the structure is created only once, and cached

for subsequent use.

See also guidata, guide, openfig.

Reference page in Help browser

doc guihandles

<setpixelposition> - Set position HG object in pixels.

SETPIXELPOSITION Set position HG object in pixels.

SETPIXELPOSITION(HANDLE, POSITION) sets the position of the object specified by

HANDLE in pixel units to the specified POSITION.

SETPIXELPOSITION(HANDLE, POSITION, RECURSIVE) sets the position as above. If

RECURSIVE is true, the position is set relative to the parent

figure of HANDLE.

Example:

f = figure;

p = uipanel('Position', [.2 .2 .6 .6]);

h1 = uicontrol(p, 'Units', 'normalized', 'Position', [.1 .1 .5 .2]);

% Get pixel position w.r.t the parent uipanel

pos1 = getpixelposition(h1);

% Set pixel position on the uicontrol

pause(1);

setpixelposition(h1, pos1 + [10 10 20 20]);

See also getpixelposition, uicontrol, uipanel

Reference page in Help browser

doc setpixelposition

<textwrap> - Return wrapped string matrix for given UI Control.

TEXTWRAP Return wrapped string matrix for given UI Control.

OUTSTRING=TEXTWRAP(UIHANDLE,INSTRING) returns a wrapped

string cell array (OUTSTRING) that fits inside the given uicontrol.

OUTSTRING is the wrapped string matrix in cell array format.

UIHANDLE is the handle of the object the string is placed in.

Соседние файлы в папке Библиотеки Matlab