-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfm_choice.m
148 lines (131 loc) · 3.88 KB
/
fm_choice.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
function fig = fm_choice(varargin)
% FM_CHOICE open dialog box and wait for input
%
% FM_CHOICE(TEXT)
% FM_CHOICE(TEXT,MODE)
% TEXT = text to be displayed
% MODE = message mode
% 1 - ask for choice (default)
% 2 - warning
% 3 - callbacks
%
% (user's preference is stored in "Settings.ok")
%
%Author: Federico Milano
%Date: 11-Nov-2002
%Version: 1.0.0
%
%E-mail: [email protected]
%Web-site: faraday1.ucd.ie/psat.html
%
% Copyright (C) 2002-2019 Federico Milano
global Path Theme Settings
pos = sizefig(0.4,0.13333);
a = 1/4;
text = varargin{1};
mode = 1;
if nargin == 2,
mode = varargin{2};
end
if mode == 3
switch text
case 'keypress'
key = get(gcbf,'CurrentCharacter');
if double(key) == 13
Settings.ok = 1;
elseif double(key) == 27
Settings.ok = 0;
end,
close(gcbf)
return
end
end
h0 = figure('Color',Theme.color02, ...
'Units', 'normalized', ...
'Colormap',[], ...
'KeyPressFcn','fm_choice(''keypress'',3)', ...
'MenuBar','none', ...
'Name','PSAT Message', ...
'NumberTitle','off', ...
'PaperPosition',[18 180 576 432], ...
'PaperType','A4', ...
'PaperUnits','points', ...
'Position',pos, ...
'RendererMode','manual', ...
'Resize','on', ...
'ToolBar','none');
if Settings.hostver < 7.05
set(h0,'ShareColors','on')
end
fm_set colormap
h1 = axes('Parent',h0, ...
'CameraUpVector',[0 1 0], ...
'CameraUpVectorMode','manual', ...
'Box', 'on', ...
'Color',Theme.color04, ...
'ColorOrder',Settings.color, ...
'Layer','top', ...
'Position',[0.0 0.0 a 1], ...
'Tag','Axes1', ...
'XColor',Theme.color02, ...
'XLim',[0.5 206.5], ...
'XLimMode','manual', ...
'XTick',[], ...
'YColor',Theme.color02, ...
'YDir','reverse', ...
'YLim',[0.5 210.5], ...
'YLimMode','manual', ...
'YTick',[], ...
'ZColor',[0 0 0]);
warn_image = fm_mat('choice_warn');
try
warn_image = imresize(warn_image,[206 210],'bilinear');
catch
% imresize not found...
end
h2 = image('Parent',h1, ...
'CData',warn_image, ...
'Tag','Axes1Image1', ...
'XData',[1 206], ...
'YData',[1 210]);
if mode == 1
h1 = uicontrol('Parent',h0, ...
'CData', fm_mat('choice_yes'), ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color02, ...
'Callback','Settings.ok = 1; close(gcf);', ...
'Position',[(a+0.075) 0.1 a 0.3], ...
'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
'CData', fm_mat('choice_no'), ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color02, ...
'Callback','Settings.ok = 0; close(gcf);', ...
'Position',[(0.925-a) 0.1 a 0.3], ...
'Tag','Pushbutton1');
elseif mode == 2
fm_disp(text)
h1 = uicontrol( ...
'Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color02, ...
'Callback','Settings.ok = 1; close(gcf);', ...
'Position',[(1.5*a+0.1125) 0.1 a 0.3], ...
'String', 'OK', ...
'Tag','Pushbutton1');
end
FontSize = 10;
if ~isunix
FontSize = 8;
end
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color02, ...
'ForegroundColor',Theme.color05, ...
'FontName', 'helvetica', ...
'FontSize', FontSize, ...
'Position',[a+0.05 0.5 (0.9-a) 0.3], ...
'String', text, ...
'Style','text', ...
'Tag','StaticText1');
if nargout > 0, fig = h0; end