Home > NoiseTools > private > getnicedialoglocation.m

# getnicedialoglocation

## PURPOSE

adjust the specified figure position to fig nicely over GCBF

## SYNOPSIS

function figure_size = getnicedialoglocation(figure_size, figure_units)

## DESCRIPTION

     adjust the specified figure position to fig nicely over GCBF
     or into the upper 3rd of the screen

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- listdlg3

## SOURCE CODE

    0001 function figure_size = getnicedialoglocation(figure_size, figure_units)
    0002 % adjust the specified figure position to fig nicely over GCBF
    0003 % or into the upper 3rd of the screen
    0004
    0005 %  Copyright 1999-2010 The MathWorks, Inc.
    0006 %  $Revision: 1.1.6.5 $
    0007
    0008 parentHandle = gcbf;
    0009 convertData.destinationUnits = figure_units;
    0010 if ~isempty(parentHandle)
    0011     % If there is a parent figure
    0012     convertData.hFig = parentHandle;
    0013     convertData.size = get(parentHandle,'Position');
    0014     convertData.sourceUnits = get(parentHandle,'Units');
    0015     c = [];
    0016 else
    0017     % If there is no parent figure, use the root's data
    0018     % and create a invisible figure as parent
    0019     convertData.hFig = figure('visible','off');
    0020     convertData.size = get(0,'ScreenSize');
    0021     convertData.sourceUnits = get(0,'Units');
    0022     c = onCleanup(@() close(convertData.hFig));
    0023 end
    0024
    0025 % Get the size of the dialog parent in the dialog units
    0026 container_size = hgconvertunits(convertData.hFig, convertData.size ,...
    0027     convertData.sourceUnits, convertData.destinationUnits, get(convertData.hFig,'Parent'));
    0028
    0029 delete(c);
    0030
    0031 figure_size(1) = container_size(1)  + 1/2*(container_size(3) - figure_size(3));
    0032 figure_size(2) = container_size(2)  + 2/3*(container_size(4) - figure_size(4));
    0033
    0034