0001 function [gui_handles] = create_gui(this)
0002
0003
0004
0005
0006
0007 S = get(0,'ScreenSize');
0008
0009
0010
0011
0012 Width = 380;
0013 Height = 440;
0014
0015
0016 BorderH = 10;
0017 BorderV = 5;
0018
0019
0020
0021 CurrentDirTextWidth = Width - 2*BorderH;
0022 CurrentDirTextHeight = 20;
0023 CurrentDirTextLeft = BorderH;
0024 CurrentDirTextBottom = Height - CurrentDirTextHeight;
0025
0026
0027 CurrentDirPopupWidth = Width - 2*BorderH;
0028 CurrentDirPopupHeight = 20;
0029 CurrentDirPopupLeft = BorderH;
0030 CurrentDirPopupBottom = CurrentDirTextBottom - CurrentDirPopupHeight;
0031
0032
0033
0034 ExtensionTextWidth = 0.6*(CurrentDirPopupWidth/2);
0035 ExtensionTextHeight = 20;
0036 ExtensionTextLeft = BorderH;
0037 ExtensionTextBottom = CurrentDirPopupBottom - (ExtensionTextHeight+BorderV);
0038
0039
0040 ExtensionPopupWidth = CurrentDirPopupWidth/2 - ExtensionTextWidth;
0041 ExtensionPopupHeight = ExtensionTextHeight;
0042 ExtensionPopupLeft = ExtensionTextLeft + ExtensionTextWidth;
0043 ExtensionPopupBottom = ExtensionTextBottom;
0044
0045
0046
0047 DriveTextWidth = ExtensionTextWidth;
0048 DriveTextHeight = ExtensionPopupHeight;
0049 DriveTextLeft = ExtensionPopupLeft + ExtensionPopupWidth;
0050 DriveTextBottom = ExtensionPopupBottom;
0051
0052
0053 DrivePopupWidth = ExtensionPopupWidth;
0054 DrivePopupHeight = DriveTextHeight;
0055 DrivePopupLeft = DriveTextLeft + DriveTextWidth;
0056 DrivePopupBottom = DriveTextBottom;
0057
0058
0059
0060 PanelWidth = CurrentDirPopupWidth;
0061 PanelHeighth = 320;
0062 PanelLeft = BorderH;
0063 PanelBottom = ExtensionTextBottom - (PanelHeighth+BorderV);
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 [major, minor, rev] = vb_matlab_version;
0076 version_value = 100*major + 10*minor + rev * 1;
0077 if version_value < 704
0078 TmpLeft = PanelLeft; TmpBottom = PanelBottom;
0079 else
0080 TmpLeft = 0; TmpBottom = 0;
0081 end
0082
0083
0084
0085
0086 DirTextWidth = PanelWidth*2/5 - BorderH;
0087 DirTextHeight = 20;
0088 DirTextLeft = TmpLeft + BorderH;
0089 DirTextBottom = TmpBottom + PanelHeighth - (DirTextHeight+BorderV);
0090
0091
0092 DirListWidth = DirTextWidth;
0093 DirListHeight = 180;
0094 DirListLeft = DirTextLeft;
0095 DirListBottom = DirTextBottom - DirListHeight;
0096
0097
0098
0099 FnameTextWidth = PanelWidth - DirTextWidth - 2*BorderH;
0100 FnameTextHeight = DirTextHeight;
0101 FnameTextLeft = DirTextLeft + DirTextWidth;
0102 FnameTextBottom = DirTextBottom;
0103
0104
0105 FnameListWidth = FnameTextWidth;
0106 FnameListHeight = DirListHeight;
0107 FnameListLeft = FnameTextLeft;
0108 FnameListBottom = DirListBottom;
0109
0110
0111
0112 FilterFnameTextWidth = PanelWidth - 2*BorderH;
0113 FilterFnameTextHeight= 20;
0114 FilterFnameTextLeft = TmpLeft + BorderH;
0115 FilterFnameTextBottom= DirListBottom - (FilterFnameTextHeight+BorderV);
0116
0117
0118 FilterFnameEditWidth = FilterFnameTextWidth;
0119 FilterFnameEditHeight= 22;
0120 FilterFnameEditLeft = FilterFnameTextLeft;
0121 FilterFnameEditBottom= FilterFnameTextBottom - FilterFnameEditHeight;
0122
0123
0124 SelFnameTextWidth = PanelWidth - 2*BorderH;
0125 SelFnameTextHeight = 20;
0126 SelFnameTextLeft = TmpLeft + BorderH;
0127 SelFnameTextBottom = FilterFnameEditBottom - (SelFnameTextHeight+BorderV);
0128
0129
0130 SelFnameEditWidth = SelFnameTextWidth;
0131 SelFnameEditHeight = 22;
0132 SelFnameEditLeft = SelFnameTextLeft;
0133 SelFnameEditBottom = SelFnameTextBottom - SelFnameEditHeight;
0134
0135
0136
0137 CancelWidth = CurrentDirPopupWidth/2;
0138 CancelHeight = 35;
0139 CancelLeft = BorderH;
0140 CancelBottom = PanelBottom - (CancelHeight+BorderV);
0141
0142
0143 DoneWidth = CancelWidth;
0144 DoneHeight = CancelHeight;
0145 DoneLeft = CancelLeft + CancelWidth;
0146 DoneBottom = CancelBottom;
0147
0148
0149
0150 dialog_color = this.public.dialog_color;
0151 dialog_title = this.public.dialog_title;
0152 bgcol_panel = this.public.bgcol_panel;
0153 fgcol_panel = this.public.fgcol_panel;
0154 fgcol_text = this.public.fgcol_text;
0155 bgcol_popup = this.public.bgcol_popup;
0156 fgcol_popup = this.public.fgcol_popup;
0157 bgcol_listbox = this.public.bgcol_listbox;
0158 fgcol_listbox = this.public.fgcol_listbox;
0159 bgcol_edit = this.public.bgcol_edit;
0160 fgcol_edit = this.public.fgcol_edit;
0161 bgcol_push = this.public.bgcol_push;
0162 fgcol_push = this.public.fgcol_push;
0163
0164
0165
0166 dialog_handle = figure('Name', dialog_title, 'Tag', 'SelFileWin',...
0167 'MenuBar', 'none',...
0168 'NumberTitle', 'off',...
0169 'Color', dialog_color,...
0170 'Resize', 'off',...
0171 'Visible', 'off',...
0172 'Units', 'Pixels',...
0173 'Position',...
0174 [S(3)/2-Width/2, S(4)/2-Height/2, Width, Height]);
0175
0176
0177 uicontrol('Parent', dialog_handle, 'Style', 'text',...
0178 'String', 'current directory',...
0179 'BackgroundColor', dialog_color, 'ForegroundColor', fgcol_text,...
0180 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0181 'Position',...
0182 [CurrentDirTextLeft, CurrentDirTextBottom,...
0183 CurrentDirTextWidth, CurrentDirTextHeight]);
0184
0185
0186 current_dir_popup_handle = uicontrol('Parent',dialog_handle,...
0187 'Style', 'popup', 'String', ' ', 'Value', 1,...
0188 'BackgroundColor', bgcol_popup, 'ForegroundColor', fgcol_popup,...
0189 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0190 'CallBack', {@current_dir_popup, dialog_handle},...
0191 'Position',...
0192 [CurrentDirPopupLeft, CurrentDirPopupBottom,...
0193 CurrentDirPopupWidth, CurrentDirPopupHeight]);
0194
0195
0196
0197 uicontrol('Parent', dialog_handle, 'Style', 'text',...
0198 'String', 'Extension',...
0199 'BackgroundColor', dialog_color, 'ForegroundColor', fgcol_text,...
0200 'FontSize', 12,...
0201 'Position',...
0202 [ExtensionTextLeft, ExtensionTextBottom,...
0203 ExtensionTextWidth, ExtensionTextHeight]);
0204
0205
0206 str = sprintf('|%s', this.public.file_extensions{:}); str(1) = [];
0207 extension_popup_handle = uicontrol('Parent', dialog_handle,...
0208 'Style', 'popup', 'String', str, 'Value', 1,...
0209 'BackgroundColor', bgcol_popup, 'ForegroundColor', fgcol_popup,...
0210 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0211 'CallBack', {@extension_popup, dialog_handle},...
0212 'Position',...
0213 [ExtensionPopupLeft, ExtensionPopupBottom,...
0214 ExtensionPopupWidth, ExtensionPopupHeight]);
0215
0216
0217
0218 drive_text = uicontrol('Parent', dialog_handle, 'Style', 'text',...
0219 'String', 'Drive',...
0220 'BackgroundColor', dialog_color, 'ForegroundColor', fgcol_text,...
0221 'FontSize', 12,...
0222 'Position',...
0223 [DriveTextLeft, DriveTextBottom, DriveTextWidth, DriveTextHeight]);
0224
0225
0226 drive_popup_handle = uicontrol('Parent',dialog_handle, 'Style', 'popup',...
0227 'String', ' ',...
0228 'BackgroundColor', bgcol_popup, 'ForegroundColor', fgcol_popup,...
0229 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0230 'CallBack', {@drive_popup, dialog_handle},...
0231 'Position',...
0232 [DrivePopupLeft DrivePopupBottom DrivePopupWidth DrivePopupHeight]);
0233
0234
0235
0236
0237 if version_value < 704
0238 tmp = uicontrol('Parent', dialog_handle, 'Style', 'Frame',...
0239 'Position', [PanelLeft PanelBottom PanelWidth PanelHeighth],...
0240 'BackgroundColor', bgcol_panel, 'ForegroundColor', fgcol_panel);
0241 panel = [];
0242 parent = dialog_handle;
0243 bgcol = get(tmp, 'BackgroundColor');
0244 else
0245 panel = uipanel('Parent', dialog_handle, 'Title', '', 'FontSize', 12,...
0246 'Units', 'pixels',...
0247 'Position', [PanelLeft PanelBottom PanelWidth PanelHeighth],...
0248 'BackgroundColor', bgcol_panel, 'ForegroundColor', fgcol_panel);
0249 parent = panel;
0250 bgcol = get(panel, 'BackgroundColor');
0251 end
0252
0253
0254
0255 uicontrol('Parent', parent, 'Style', 'Text', 'String', 'Directories',...
0256 'BackgroundColor', bgcol_panel, 'ForegroundColor', fgcol_panel,...
0257 'HorizontalAlignment', 'Center', 'FontSize', 12,...
0258 'Position',[DirTextLeft DirTextBottom DirTextWidth DirTextHeight]);
0259
0260
0261 dir_listbox_handle = uicontrol('Parent', parent, 'Style', 'listbox',...
0262 'String', '',...
0263 'BackgroundColor', bgcol_listbox, 'ForegroundColor', fgcol_listbox,...
0264 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0265 'CallBack', {@dir_listbox, dialog_handle},...
0266 'Position', [DirListLeft DirListBottom DirListWidth DirListHeight]);
0267
0268
0269
0270 uicontrol('Parent', parent, 'Style', 'Text', 'String', 'Files',...
0271 'BackgroundColor', bgcol_panel, 'ForegroundColor', fgcol_panel,...
0272 'HorizontalAlignment', 'Center', 'FontSize', 12,...
0273 'Position',...
0274 [FnameTextLeft FnameTextBottom FnameTextWidth FnameTextHeight]);
0275
0276
0277 fname_listbox_handle = uicontrol('Parent', parent, 'Style', 'listbox',...
0278 'String', '',...
0279 'BackgroundColor', bgcol_listbox, 'ForegroundColor', fgcol_listbox,...
0280 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0281 'CallBack', {@fname_listbox, dialog_handle},...
0282 'Position',...
0283 [FnameListLeft FnameListBottom FnameListWidth FnameListHeight]);
0284
0285
0286
0287 uicontrol('Parent', parent, 'Style', 'text', 'String', 'Filter',...
0288 'BackgroundColor', bgcol_panel, 'ForegroundColor', fgcol_panel,...
0289 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0290 'Position',...
0291 [FilterFnameTextLeft, FilterFnameTextBottom,...
0292 FilterFnameTextWidth, FilterFnameTextHeight]);
0293
0294
0295 filter_str_edit = uicontrol('Parent', parent, 'Style', 'edit', 'String', '',...
0296 'BackgroundColor', bgcol_edit, 'ForegroundColor', fgcol_edit,...
0297 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0298 'CallBack', {@fname_edit, dialog_handle},...
0299 'String', '*',...
0300 'Position',...
0301 [FilterFnameEditLeft,FilterFnameEditBottom,...
0302 FilterFnameEditWidth, FilterFnameEditHeight]);
0303
0304
0305 uicontrol('Parent', parent, 'Style', 'text', 'String', 'selected file(s)',...
0306 'BackgroundColor', bgcol_panel, 'ForegroundColor', fgcol_panel,...
0307 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0308 'Position',...
0309 [SelFnameTextLeft, SelFnameTextBottom,...
0310 SelFnameTextWidth, SelFnameTextHeight]);
0311
0312
0313 sel_fname_edit = uicontrol('Parent', parent, 'Style', 'edit', 'String', '',...
0314 'BackgroundColor', bgcol_edit, 'ForegroundColor', fgcol_edit,...
0315 'HorizontalAlignment', 'Left', 'FontSize', 12,...
0316 'CallBack', {@fname_edit, dialog_handle},...
0317 'Position',...
0318 [SelFnameEditLeft,SelFnameEditBottom,...
0319 SelFnameEditWidth, SelFnameEditHeight]);
0320
0321
0322
0323 uicontrol('Parent', dialog_handle, 'Style', 'push', 'String', 'Cancel',...
0324 'FontSize', 12, ...
0325 'BackgroundColor', bgcol_push, 'ForegroundColor', fgcol_push,...
0326 'CallBack', {@close_gui, dialog_handle, 'cancel'},...
0327 'Position', [CancelLeft CancelBottom CancelWidth CancelHeight]);
0328
0329
0330
0331 done_push = uicontrol('Parent', dialog_handle, 'Style', 'push',...
0332 'String', 'OK', 'FontSize', 12,...
0333 'BackgroundColor', bgcol_push, 'ForegroundColor', fgcol_push,...
0334 'CallBack', {@close_gui, dialog_handle, 'done'},...
0335 'Position', [DoneLeft DoneBottom DoneWidth DoneHeight]);
0336
0337
0338
0339 gui_handles = struct(...
0340 'dialog', dialog_handle,...
0341 'current_dir_popup', current_dir_popup_handle,...
0342 'panel', panel,...
0343 'extension_popup', extension_popup_handle,...
0344 'drive_text', drive_text,...
0345 'drive_popup', drive_popup_handle,...
0346 'dir_listbox', dir_listbox_handle,...
0347 'fname_listbox', fname_listbox_handle,...
0348 'filter_str_edit', filter_str_edit,...
0349 'sel_fname_edit', sel_fname_edit,...
0350 'done_push', done_push);
0351
0352
0353 set(dialog_handle, 'Units', 'normalized', 'Resize', 'on');
0354 h_all = [get(parent, 'children'); get(dialog_handle, 'children')];
0355 for k=1:length(h_all)
0356 try
0357 set(h_all(k), 'Units', 'normalized');
0358 catch
0359 end
0360 try
0361 set(h_all(k), 'FontUnit', 'normalized');
0362 catch
0363 end
0364 end
0365 pos = get(dialog_handle, 'Position');
0366 pos(3) = pos(3)*1.2;
0367 set(dialog_handle, 'Position', pos);