source: trunk/src/msgbox_uvmat.m @ 2

Last change on this file since 2 was 2, checked in by gostiaux, 11 years ago
  • Initial import
  • Add .m files in src
  • Add .fig files in src
  • Add .xml config files
File size: 6.6 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    isequal(varargout{1},'')
145    if isempty(varargout{1}) || isequal(varargout{1},'')
146        varargout{1}='Yes';
147    end
148end
149% The figure can be deleted now
150delete(handles.figure1);
151
152% --- Executes on button press in OK.
153function OK_Callback(hObject, eventdata, handles)
154handles.output = get(hObject,'String');
155guidata(hObject, handles);% Update handles structure
156uiresume(handles.figure1);
157
158% --- Executes on button press in No.
159function No_Callback(hObject, eventdata, handles)
160handles.output='No';
161guidata(hObject, handles);
162uiresume(handles.figure1);
163
164% --- Executes on button press in Cancel.
165function Cancel_Callback(hObject, eventdata, handles)
166handles.output = get(hObject,'String');
167%handles.output = 'Cancel'
168guidata(hObject, handles); % Update handles structure
169% Use UIRESUME instead of delete because the OutputFcn needs
170% to get the updated handles structure.
171uiresume(handles.figure1);
172
173
174% --- Executes when user attempts to close figure1.
175function figure1_CloseRequestFcn(hObject, eventdata, handles)
176if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
177    % The GUI is still in UIWAIT, us UIRESUME
178    uiresume(handles.figure1);
179else
180    % The GUI is no longer waiting, just close it
181    delete(handles.figure1);
182end
183
184% --- Executes on key press over figure1 with no controls selected.
185function figure1_KeyPressFcn(hObject, eventdata, handles)
186% Check for "enter" or "escape"
187if isequal(get(hObject,'CurrentKey'),'escape')
188    % User said no by hitting escape
189    handles.output = 'No';
190   
191    % Update handles structure
192    guidata(hObject, handles);
193   
194    uiresume(handles.figure1);
195end
196if isequal(get(hObject,'CurrentKey'),'return')
197    uiresume(handles.figure1);
198end   
199
200
201
202
203
Note: See TracBrowser for help on using the repository browser.