📄 movegui.cpp
字号:
//
old0units = Nget(1, mwVarargin(_mxarray22_, _mxarray39_));
//
// set(0, 'units', 'pixels');
//
ans.EqAns(Nset(0, mwVarargin(_mxarray22_, _mxarray39_, _mxarray41_)));
//
// screensize = get(0, 'screensize');
//
screensize = Nget(1, mwVarargin(_mxarray22_, _mxarray56_));
//
// set(0, 'units', old0units);
//
ans.EqAns(
Nset(
0, mwVarargin(_mxarray22_, _mxarray39_, mwVv(old0units, "old0units"))));
//
// swidth = screensize(3); sheight = screensize(4);
//
swidth = mclIntArrayRef(mwVv(screensize, "screensize"), 3);
sheight = mclIntArrayRef(mwVv(screensize, "screensize"), 4);
//
// % make sure the figure is not bigger than the screen size
// fwidth = min(fwidth, swidth); fheight = min(fheight, sheight);
//
fwidth = min(mwVv(fwidth, "fwidth"), mwVv(swidth, "swidth"));
fheight = min(mwVv(fheight, "fheight"), mwVv(sheight, "sheight"));
//
//
// % swidth - fwidth == remaining width
// rwidth = swidth-fwidth;
//
rwidth = mwVv(swidth, "swidth") - mwVv(fwidth, "fwidth");
//
//
// % sheight - fheight == remaining height
// rheight = sheight-fheight;
//
rheight = mwVv(sheight, "sheight") - mwVv(fheight, "fheight");
//
//
//
// if isnumeric(position)
//
if (tobool(isnumeric(mwVv(position, "position")))) {
//
// newpos = position;
//
newpos = mwVv(position, "position");
//
// if(newpos(1) < 0) newpos(1) = rwidth + newpos(1); end
//
if (mclLtBool(mclIntArrayRef(mwVv(newpos, "newpos"), 1), _mxarray22_)) {
mclIntArrayAssign(
&newpos,
mwVv(rwidth, "rwidth")
+ mclIntArrayRef(mwVv(newpos, "newpos"), 1),
1);
}
//
// if(newpos(2) < 0) newpos(2) = rheight + newpos(2); end
//
if (mclLtBool(mclIntArrayRef(mwVv(newpos, "newpos"), 2), _mxarray22_)) {
mclIntArrayAssign(
&newpos,
mwVv(rheight, "rheight")
+ mclIntArrayRef(mwVv(newpos, "newpos"), 2),
2);
}
//
// else
//
} else {
//
// switch position
//
mwArray v_ = mwVv(position, "position");
if (switchcompare(v_, _mxarray58_)) {
//
// case 'north', newpos = [rwidth/2, rheight];
//
newpos
= horzcat(
mwVarargin(
mwVv(rwidth, "rwidth") / _mxarray33_,
mwVv(rheight, "rheight")));
//
// case 'south', newpos = [rwidth/2, 0];
//
} else if (switchcompare(v_, _mxarray59_)) {
newpos
= horzcat(
mwVarargin(
mwVv(rwidth, "rwidth") / _mxarray33_, _mxarray22_));
//
// case 'east', newpos = [ rwidth, rheight/2];
//
} else if (switchcompare(v_, _mxarray60_)) {
newpos
= horzcat(
mwVarargin(
mwVv(rwidth, "rwidth"),
mwVv(rheight, "rheight") / _mxarray33_));
//
// case 'west', newpos = [ 0, rheight/2];
//
} else if (switchcompare(v_, _mxarray61_)) {
newpos
= horzcat(
mwVarargin(
_mxarray22_, mwVv(rheight, "rheight") / _mxarray33_));
//
// case 'northeast', newpos = [ rwidth, rheight];
//
} else if (switchcompare(v_, _mxarray62_)) {
newpos
= horzcat(
mwVarargin(
mwVv(rwidth, "rwidth"), mwVv(rheight, "rheight")));
//
// case 'southeast', newpos = [ rwidth, 0];
//
} else if (switchcompare(v_, _mxarray63_)) {
newpos = horzcat(mwVarargin(mwVv(rwidth, "rwidth"), _mxarray22_));
//
// case 'northwest', newpos = [ 0, rheight];
//
} else if (switchcompare(v_, _mxarray64_)) {
newpos = horzcat(mwVarargin(_mxarray22_, mwVv(rheight, "rheight")));
//
// case 'southwest', newpos = [ 0, 0];
//
} else if (switchcompare(v_, _mxarray65_)) {
newpos = _mxarray66_;
//
// case 'center', newpos = [rwidth/2, rheight/2];
//
} else if (switchcompare(v_, _mxarray68_)) {
newpos
= horzcat(
mwVarargin(
mwVv(rwidth, "rwidth") / _mxarray33_,
mwVv(rheight, "rheight") / _mxarray33_));
//
// case 'onscreen'
//
} else if (switchcompare(v_, _mxarray36_)) {
//
// if fleft < 0
//
if (mclLtBool(mwVv(fleft, "fleft"), _mxarray22_)) {
//
// fleft = 0;
//
fleft = _mxarray22_;
//
// end
//
}
//
// if fbottom < 0
//
if (mclLtBool(mwVv(fbottom, "fbottom"), _mxarray22_)) {
//
// fbottom = 0;
//
fbottom = _mxarray22_;
//
// end
//
}
//
// if fleft > rwidth
//
if (mclGtBool(mwVv(fleft, "fleft"), mwVv(rwidth, "rwidth"))) {
//
// fleft = rwidth;
//
fleft = mwVv(rwidth, "rwidth");
//
// end
//
}
//
// if fbottom > rheight
//
if (mclGtBool(mwVv(fbottom, "fbottom"), mwVv(rheight, "rheight"))) {
//
// fbottom = rheight;
//
fbottom = mwVv(rheight, "rheight");
//
// end
//
}
//
// newpos = [fleft, fbottom];
//
newpos
= horzcat(
mwVarargin(mwVv(fleft, "fleft"), mwVv(fbottom, "fbottom")));
//
// end
//
}
//
// end
//
}
//
//
// newpos(3:4) = [fwidth, fheight];
//
mclArrayAssign(
&newpos,
horzcat(mwVarargin(mwVv(fwidth, "fwidth"), mwVv(fheight, "fheight"))),
colon(_mxarray23_, _mxarray69_));
//
//
// if isunix
//
if (tobool(isunix())) {
//
// % remove width and height adjustments added above
// newpos(3) = newpos(3) - wfudge;
//
mclIntArrayAssign(
&newpos,
mclIntArrayRef(mwVv(newpos, "newpos"), 3) - mwVv(wfudge, "wfudge"),
3);
//
// newpos(4) = newpos(4) - hfudge;
//
mclIntArrayAssign(
&newpos,
mclIntArrayRef(mwVv(newpos, "newpos"), 4) - mwVv(hfudge, "hfudge"),
4);
//
// set(fig, 'position', newpos);
//
ans.EqAns(
Nset(
0,
mwVarargin(mwVv(fig, "fig"), _mxarray43_, mwVv(newpos, "newpos"))));
//
// else
//
} else {
//
// set(fig, 'outerposition', newpos);
//
ans.EqAns(
Nset(
0,
mwVarargin(mwVv(fig, "fig"), _mxarray54_, mwVv(newpos, "newpos"))));
//
// end
//
}
//
// set(fig, 'units', oldfunits);
//
ans.EqAns(
Nset(
0,
mwVarargin(
mwVv(fig, "fig"), _mxarray39_, mwVv(oldfunits, "oldfunits"))));
//
// % setting outposition on a figure sets the activepositionproperty
// % to 'outerposition'. It needs to be reset here.
// set(fig, 'activepositionproperty', oldposmode);
//
ans.EqAns(
Nset(
0,
mwVarargin(
mwVv(fig, "fig"), _mxarray37_, mwVv(oldposmode, "oldposmode"))));
//
//
// %----------------------------------------------------
//
}
//
// The function "Mmovegui_get_parent_fig" is the implementation version of the
// "movegui/get_parent_fig" M-function from file
// "e:\matlab6.5\toolbox\matlab\uitools\movegui.m" (lines 214-218). It contains
// the actual compiled code for that M-function. It is a static function and
// must only be called from one of the interface functions, appearing below.
//
//
// function h = get_parent_fig(h)
//
static mwArray Mmovegui_get_parent_fig(int nargout_, mwArray h_in) {
mwLocalFunctionTable save_local_function_table_
= &_local_function_table_movegui;
mwArray h = mwArray::UNDEFINED;
h.CopyInputArg(h_in);
//
// while ~isempty(h) & ~strcmp(get(h,'type'), 'figure')
//
for (;;) {
mwArray a_ = ~ isempty(mwVa(h, "h"));
if (tobool(a_)
&& tobool(
a_
& ~ strcmp(
Nget(1, mwVarargin(mwVa(h, "h"), _mxarray47_)),
_mxarray70_))) {
} else {
break;
}
//
// h = get(h, 'parent');
//
h = Nget(1, mwVarargin(mwVa(h, "h"), _mxarray72_));
//
// end
//
}
mwValidateOutput(h, 1, nargout_, "h", "movegui/get_parent_fig");
return h;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -