📄 movegui.cpp
字号:
// % V (for v < 0) offset of top edge from top of screen
// %
// % MOVEGUI(POSITION) moves the GCBF or GCF to the specified
// % position.
// %
// % MOVEGUI(H) moves the specified figure 'onscreen'.
// %
// % MOVEGUI moves the GCBF or GCF 'onscreen' (useful as a
// % string-based CreateFcn callback for a saved figure, to ensure it
// % will appear onscreen when reloaded, regardless of its saved
// % position)
// %
// % MOVEGUI(H, <event data>)
// % MOVEGUI(H, <event data>, POSITION) when used as a function-handle
// % callback, moves the specified figure to the default position, or
// % to the specified position, safely ignoring the automatically
// % passed-in event data struct.
// %
// % Example:
// % This example demonstrates MOVEGUIs usefulness as a means of
// % ensuring that a saved GUI will appear onscreen when reloaded,
// % regardless of differences between screen sizes and resolutions
// % between the machines on which it was saved and reloaded. It
// % creates a figure off the screen, assigns MOVEGUI as its CreateFcn
// % callback, then saves and reloads the figure:
// %
// % f=figure('position', [10000, 10000, 400, 300]);
// % set(f, 'CreateFcn', 'movegui')
// % hgsave(f, 'onscreenfig')
// % close(f)
// % f2 = hgload('onscreenfig')
// %
// % The following are a few variations on ways MOVEGUI can be
// % assigned as the CreateFcn, using both string and function-handle
// % callbacks, with and without extra arguments, to achieve a variety
// % of behaviors:
// %
// % set(gcf, 'CreateFcn', 'movegui center')
// % set(gcf, 'CreateFcn', @movegui)
// % set(gcf, 'CreateFcn', {@movegui, 'northeast'})
// % set(gcf, 'CreateFcn', {@movegui, [-100 -50]})
// %
// % See also OPENFIG, GUIHANDLES, GUIDATA, GUIDE.
//
// % Damian T. Packer 2-5-2000
// % Copyright 1984-2002 The MathWorks, Inc.
// % $Revision: 1.14 $ $Date: 2002/04/22 22:25:49 $
//
// POSITIONS = {'north','south','east','west',...
//
POSITIONS = _mxarray0_;
//
// 'northeast','southeast','northwest','southwest',...
// 'center','onscreen'};
//
// error(nargchk(0, 3, nargin));
//
error(mwVarargin(nargchk(_mxarray22_, _mxarray23_, nargin_)));
//
// position = '';
//
position = _mxarray24_;
//
// fig = [];
//
fig = _mxarray25_;
{
//
//
// for i=1:nargin
//
int v_ = mclForIntStart(1);
int e_ = nargin_;
if (v_ > e_) {
i = _mxarray25_;
} else {
//
// numel = prod(size(varargin{i}));
// if ishandle(varargin{i}) & numel == 1
// fig = get_parent_fig(varargin{i});
// if isempty(fig)
// error('handle of figure or descendant required');
// end
// elseif isstr(varargin{i})
// position = varargin{i};
// if isempty(strmatch(position,POSITIONS,'exact'))
// error('unrecognized position');
// end
// elseif isnumeric(varargin{i}) & numel == 2
// position = varargin{i};
// elseif ~isempty(gcbo) & i==2
// continue; % skip past the event data struct, if in a callback
// else
// error('unrecognized input argument');
// end
// end
//
for (; ; ) {
numel
= prod(
feval(
mwValueVarargout(),
mlxSize,
mwVarargin(mwVa(varargin, "varargin").cell(v_))));
{
mwArray a_
= feval(
mwValueVarargout(),
mlxIshandle,
mwVarargin(mwVa(varargin, "varargin").cell(v_)));
if (tobool(a_)
&& tobool(a_ & mwVv(numel, "numel") == _mxarray26_)) {
fig
= feval(
mwValueVarargout(),
mlxMovegui_get_parent_fig,
mwVarargin(mwVa(varargin, "varargin").cell(v_)));
if (tobool(isempty(mwVv(fig, "fig")))) {
error(mwVarargin(_mxarray27_));
}
} else {
if (tobool(
feval(
mwValueVarargout(),
mlxIsstr,
mwVarargin(
mwVa(varargin, "varargin").cell(v_))))) {
position = mwVa(varargin, "varargin").cell(v_);
if (tobool(
isempty(
strmatch(
mwVv(position, "position"),
mwVv(POSITIONS, "POSITIONS"),
_mxarray29_)))) {
error(mwVarargin(_mxarray31_));
}
} else {
mwArray a_0
= feval(
mwValueVarargout(),
mlxIsnumeric,
mwVarargin(
mwVa(varargin, "varargin").cell(v_)));
if (tobool(a_0)
&& tobool(
a_0
& mwVv(numel, "numel") == _mxarray33_)) {
position = mwVa(varargin, "varargin").cell(v_);
} else {
mwArray a_1 = ~ isempty(Ngcbo(1, NULL));
if (tobool(a_1) && tobool(a_1 & v_ == 2)) {
} else {
error(mwVarargin(_mxarray34_));
}
}
}
}
}
if (v_ == e_) {
break;
}
++v_;
}
i = v_;
}
}
//
//
// if isempty(fig)
//
if (tobool(isempty(mwVv(fig, "fig")))) {
//
// fig = gcbf;
//
fig = gcbf();
//
// if(isempty(fig))
//
if (tobool(isempty(mwVv(fig, "fig")))) {
//
// fig = gcf;
//
fig = gcf();
//
// end
//
}
//
// end
//
}
//
//
// if isempty(position)
//
if (tobool(isempty(mwVv(position, "position")))) {
//
// position = 'onscreen';
//
position = _mxarray36_;
//
// end
//
}
//
//
// drawnow
//
drawnow(mwArray::DIN);
//
// oldposmode = get(fig,'activepositionproperty');
//
oldposmode = Nget(1, mwVarargin(mwVv(fig, "fig"), _mxarray37_));
//
// oldfunits = get(fig, 'units');
//
oldfunits = Nget(1, mwVarargin(mwVv(fig, "fig"), _mxarray39_));
//
// set(fig, 'units', 'pixels');
//
ans.EqAns(Nset(0, mwVarargin(mwVv(fig, "fig"), _mxarray39_, _mxarray41_)));
//
//
// if isunix
//
if (tobool(isunix())) {
//
// % on unix, we can't rely on outerposition to place the figure
// % correctly. use reasonable defaults and place using regular
// % position. i call it fudge because it's just a guess.
// oldpos = get(fig, 'position');
//
oldpos = Nget(1, mwVarargin(mwVv(fig, "fig"), _mxarray43_));
//
// wfudge = 6;
//
wfudge = _mxarray45_;
//
// hfudge = 24;
//
hfudge = _mxarray46_;
//
//
// if ~isempty(findall(fig,'type','uimenu'))
//
if (mclNotBool(
isempty(
findall(
mwVv(fig, "fig"), mwVarargin(_mxarray47_, _mxarray49_))))) {
//
// hfudge = hfudge + 32;
//
hfudge = mwVv(hfudge, "hfudge") + _mxarray51_;
//
// end
//
}
//
//
// numtoolbars = length(findall(fig,'type','uitoolbar'));
//
numtoolbars
= mclLengthInt(
findall(mwVv(fig, "fig"), mwVarargin(_mxarray47_, _mxarray52_)));
//
// if numtoolbars > 0
//
if (mclGtBool(mwVv(numtoolbars, "numtoolbars"), _mxarray22_)) {
//
// hfudge = hfudge + 24 * numtoolbars;
//
hfudge
= mwVv(hfudge, "hfudge")
+ _mxarray46_ * mwVv(numtoolbars, "numtoolbars");
//
// end
//
}
//
//
// oldpos(3) = oldpos(3) + wfudge;
//
mclIntArrayAssign(
&oldpos,
mclIntArrayRef(mwVv(oldpos, "oldpos"), 3) + mwVv(wfudge, "wfudge"),
3);
//
// oldpos(4) = oldpos(4) + hfudge;
//
mclIntArrayAssign(
&oldpos,
mclIntArrayRef(mwVv(oldpos, "oldpos"), 4) + mwVv(hfudge, "hfudge"),
4);
//
// else
//
} else {
//
// oldpos = get(fig, 'outerposition');
//
oldpos = Nget(1, mwVarargin(mwVv(fig, "fig"), _mxarray54_));
//
// end
//
}
//
//
// fleft = oldpos(1);
//
fleft = mclIntArrayRef(mwVv(oldpos, "oldpos"), 1);
//
// fbottom = oldpos(2);
//
fbottom = mclIntArrayRef(mwVv(oldpos, "oldpos"), 2);
//
// fwidth = oldpos(3);
//
fwidth = mclIntArrayRef(mwVv(oldpos, "oldpos"), 3);
//
// fheight = oldpos(4);
//
fheight = mclIntArrayRef(mwVv(oldpos, "oldpos"), 4);
//
//
// old0units = get(0, 'units');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -