time | Calls | line |
|---|
| | 1 | function position = getpixelposition(h,recursive)
|
| | 2 | % GETPIXELPOSITION Get the position of an HG object in pixel units.
|
| | 3 | % GETPIXELPOSITION(HANDLE) gets the position of the object specified by
|
| | 4 | % HANDLE in pixel units.
|
| | 5 | %
|
| | 6 | % GETPIXELPOSITION(HANDLE, RECURSIVE) gets the position as above. If
|
| | 7 | % RECURSIVE is true, the returned position is relative to the parent
|
| | 8 | % figure of HANDLE.
|
| | 9 | %
|
| | 10 | % POSITION = GETPIXELPOSITION(...) returns the pixel position in POSITION.
|
| | 11 | %
|
| | 12 | % Example:
|
| | 13 | % f = figure;
|
| | 14 | % p = uipanel('Position', [.2 .2 .6 .6]);
|
| | 15 | % h1 = uicontrol(p, 'Units', 'normalized', 'Position', [.1 .1 .5 .2]);
|
| | 16 | % % Get pixel position w.r.t the parent uipanel
|
| | 17 | % pos1 = getpixelposition(h1)
|
| | 18 | % % Get pixel position w.r.t the parent figure using the recursive flag
|
| | 19 | % pos2 = getpixelposition(h1, true)
|
| | 20 | %
|
| | 21 | % See also SETPIXELPOSITION, UICONTROL, UIPANEL
|
| | 22 |
|
| | 23 | % Copyright 1984-2013 The MathWorks, Inc.
|
| | 24 |
|
| | 25 | % Verify that getpixelposition is given between 1 and 2 arguments
|
< 0.001 | 1 | 26 | narginchk(1, 2);
|
| | 27 |
|
| | 28 | % Verify that "h" is a handle
|
< 0.001 | 1 | 29 | if ~ishghandle(h)
|
| | 30 | error(message('MATLAB:getpixelposition:InvalidHandle'))
|
< 0.001 | 1 | 31 | end
|
| | 32 |
|
< 0.001 | 1 | 33 | if nargin < 2
|
< 0.001 | 1 | 34 | recursive = false;
|
< 0.001 | 1 | 35 | end
|
| | 36 |
|
0.004 | 1 | 37 | position = matlab.ui.internal.GetPixelPositionHelper.getPixelPositionHelper(h,recursive);
|
Other subfunctions in this file are not included in this listing.