source: trunk/src/msgbox_uvmat.m @ 35

Last change on this file since 35 was 12, checked in by gostiaux, 15 years ago

The files from uvmat.2.2.beta that differed from the current version have been updated.
Now the /raid/soft/UVMAT/src should be operational

File size: 6.5 KB
Line 
1%'msgbox_uvmat': associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls
2% msgbox_uvmat(title,display)
3%
4% OUTPUT:
5% answer  (text string)= 'yes', 'No', 'cancel', or the text string introduced as input
6%
7%INPUT:
8% title: string indicating the type of message box:
9%          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N', default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).
10%          if title='INPUT_TXT', input data is asked in an edit box
11%          if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains  opened until a button 'OK' is pressed
12%          if title='INPUT_Y-N', an answer Yes/No is requested
13% display, displayed text
14% default_answer: default answer in the edit box (only used with title='INPUT_TXT')
15
16function varargout = msgbox_uvmat(varargin)
17
18% Last Modified by GUIDE v2.5 24-Oct-2009 21:55:17
19
20% Begin initialization code - DO NOT EDIT
21gui_Singleton = 1;
22gui_State = struct('gui_Name',       mfilename, ...
23                   'gui_Singleton',  gui_Singleton, ...
24                   'gui_OpeningFcn', @msgbox_uvmat_OpeningFcn, ...
25                   'gui_OutputFcn',  @msgbox_uvmat_OutputFcn, ...
26                   'gui_LayoutFcn',  [] , ...
27                   'gui_Callback',   []);
28if nargin && ischar(varargin{1})
29    gui_State.gui_Callback = str2func(varargin{1});
30end
31
32if nargout
33    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
34else
35    gui_mainfcn(gui_State, varargin{:});
36end
37% End initialization code - DO NOT EDIT
38
39% --- Executes just before msgbox_uvmat is made visible.
40function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display,default_answer)
41% This function has no output args, see OutputFcn.
42
43% Choose default command line output for msgbox_uvmat
44handles.output = 'Cancel';
45
46% Update handles structure
47guidata(hObject, handles);
48testNo=0;
49testCancel=1;
50testinputstring=0;
51icontype='quest';%default question icon (text input asked)
52if exist('title','var')
53      set(hObject, 'Name', title);
54      if isequal (title,'CONFIRMATION')
55         icontype='';
56         testCancel=0; %no cancel button
57      elseif isequal (title,'ERROR')
58         icontype='error';
59         testCancel=0; %no cancel button
60      elseif isequal (title,'WARNING')
61         icontype='warn';
62         testCancel=0; %no cancel button
63      elseif isequal (title,'INPUT_Y-N')
64         icontype='quest';
65         testNo=1; % button No activated
66      else
67          testinputstring=1;
68      end
69end
70if exist('display','var')
71    set(handles.text1, 'String', display);
72end
73if testinputstring
74    set(handles.edit_box, 'Visible', 'on');
75else
76    set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
77end
78if exist('default_answer','var') &&  testinputstring
79    set(handles.edit_box, 'String', default_answer);
80end
81% Determine the position of the dialog - centered on the screen
82FigPos=get(0,'DefaultFigurePosition');
83OldUnits = get(hObject, 'Units');
84set(hObject, 'Units', 'pixels');
85OldPos = get(hObject,'Position');
86FigWidth = OldPos(3);
87FigHeight = OldPos(4);
88ScreenUnits=get(0,'Units');
89set(0,'Units','pixels');
90ScreenSize=get(0,'ScreenSize');
91set(0,'Units',ScreenUnits);
92
93FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
94FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
95FigPos(3:4)=[FigWidth FigHeight];
96set(hObject, 'Position', FigPos);
97set(hObject, 'Units', OldUnits);
98
99% Show a question icon from dialogicons.mat - variables questIconData and questIconMap
100if isequal(icontype,'')
101    hima=findobj(handles.axes1,'Type','image');
102    if ~isempty(hima)
103        delete(hima)
104    end
105else
106    load dialogicons.mat
107    eval(['IconData=' icontype 'IconData;'])
108    eval(['IconCMap=' icontype 'IconMap;'])
109    questIconMap(256,:) = get(handles.figure1, 'Color');
110    Img=image(IconData, 'Parent', handles.axes1);
111    set(handles.figure1, 'Colormap', IconCMap);
112    set(handles.axes1, ...
113        'Visible', 'off', ...
114        'YDir'   , 'reverse'       , ...
115        'XLim'   , get(Img,'XData'), ...
116        'YLim'   , get(Img,'YData')  ...
117        );
118end
119if testCancel
120     set(handles.Cancel,'Visible','on')
121else
122    set(handles.Cancel,'Visible','off')
123end
124if testNo
125     set(handles.No,'Visible','on')
126else
127    set(handles.No,'Visible','off')
128end   
129set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
130% UIWAIT makes msgbox_uvmat wait for user response (see UIRESUME)
131uiwait(handles.figure1);
132
133
134% --- Outputs from this function are returned to the command line.
135function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles)
136
137% Get default command line output from handles structure
138if isequal(handles.output,'Cancel')
139    varargout{1}='Cancel';
140elseif isequal(handles.output,'No')
141    varargout{1}='No';
142else
143    varargout{1}=get(handles.edit_box,'String');
144    if isempty(varargout{1}) || isequal(varargout{1},'')
145        varargout{1}='Yes';
146    end
147end
148% The figure can be deleted now
149delete(handles.figure1);
150
151% --- Executes on button press in OK.
152function OK_Callback(hObject, eventdata, handles)
153handles.output = get(hObject,'String');
154guidata(hObject, handles);% Update handles structure
155uiresume(handles.figure1);
156
157% --- Executes on button press in No.
158function No_Callback(hObject, eventdata, handles)
159handles.output='No';
160guidata(hObject, handles);
161uiresume(handles.figure1);
162
163% --- Executes on button press in Cancel.
164function Cancel_Callback(hObject, eventdata, handles)
165handles.output = get(hObject,'String');
166%handles.output = 'Cancel'
167guidata(hObject, handles); % Update handles structure
168% Use UIRESUME instead of delete because the OutputFcn needs
169% to get the updated handles structure.
170uiresume(handles.figure1);
171
172
173% --- Executes when user attempts to close figure1.
174function figure1_CloseRequestFcn(hObject, eventdata, handles)
175if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
176    % The GUI is still in UIWAIT, us UIRESUME
177    uiresume(handles.figure1);
178else
179    % The GUI is no longer waiting, just close it
180    delete(handles.figure1);
181end
182
183% --- Executes on key press over figure1 with no controls selected.
184function figure1_KeyPressFcn(hObject, eventdata, handles)
185% Check for "enter" or "escape"
186if isequal(get(hObject,'CurrentKey'),'escape')
187    % User said no by hitting escape
188    handles.output = 'No';
189   
190    % Update handles structure
191    guidata(hObject, handles);
192   
193    uiresume(handles.figure1);
194end
195if isequal(get(hObject,'CurrentKey'),'return')
196    uiresume(handles.figure1);
197end   
198
199
200
201
202
Note: See TracBrowser for help on using the repository browser.