-
Notifications
You must be signed in to change notification settings - Fork 8
/
askScreenPreference.m
84 lines (73 loc) · 2.34 KB
/
askScreenPreference.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
function handle = askScreenPreference(varargin)
% ASKSCREENPREFERENCE
% This function will attempt to detect multiple monitors and logs the
% screen sizes for future figure positions.
%
%
% Systems Biology and Evolution Toolbox (SBEToolbox).
% Author(s): Kranti Konganti.
% (C) Texas A&M University.
%
% $LastChangedDate: 2013-02-12 10:57:29 -0600 (Tue, 12 Feb 2013) $
% $LastChangedRevision: 428 $
% $LastChangedBy: konganti $
%
if nargin < 1
varargin{1} = 'NA';
end
if ~ispref('SBEToolbox', 'useMonitor')
addpref('SBEToolbox', 'useMonitor', 0);
elseif ~strcmp(varargin{1}, 'changeScrSize')
handle = 'noWait';
return;
end
figure('units', 'pixels', 'Position', [100 100 826 623]);
handle = gcf;
movegui(gcf, 'center');
uicontrol('Style', 'text', ...
'String', 'First, we will try to set your default screen position. Drag this window to the position of your choice and press OK below to set default screen position', ...
'Position', [100 550 500 30]);
uicontrol('Style', 'pushbutton', 'String', 'OK', ...
'Position', [200 400 50 30], ...
'Callback', @setScreenSize);
uicontrol('Style', 'pushbutton', 'String', 'Cancel', ...
'Position', [450 400 50 30], ...
'Callback', @closeFig);
%pos = get(mH, 'Position');
%setpref('SBEToolbox', 'useMonitor', pos);
%{
monitors = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment.getScreenDevices;
if size(monitors, 1) > 1
chooseMonitor(monitors)
else
setscreenpref(monitors, 1);
end
function chooseMonitor(m)
monCell = cell(size(m, 1), 1);
for mon = 1:size(m, 1);
monCell{mon} = ['Monitor ', num2str(mon), ' : ', ...
num2str(m(mon).getDefaultConfiguration.getBounds.getWidth), ...
' x ', num2str(m(mon).getDefaultConfiguration.getBounds.getHeight)];
end
monInd = Search(monCell, 'Choose a Monitor of your Preference: ');
if (monInd > 0)
setscreenpref(m, monInd);
end
end
function setscreenpref(m, ind)
setpref('SBEToolbox', 'useMonitor', ...
[num2str(m(ind).getDefaultConfiguration.getBounds.getWidth), ...
'|', num2str(m(ind).getDefaultConfiguration.getBounds.getHeight)]);
end
end
%}
function setScreenSize(varargin)
pos = get(gcf, 'Position');
set(0, 'DefaultFigurePosition', pos);
setpref('SBEToolbox', 'useMonitor', pos);
close(gcf);
end
function closeFig(varargin)
close(gcf);
end
end