1 | function mwizard(file) |
---|
2 | %MWIZARD - M2HTML Graphical User Interface |
---|
3 | % MWIZARD launches a Matlab GUI front-end to edit parameters |
---|
4 | % that are then used by M2HTML to generate HTML documentation. |
---|
5 | % MWIZARD(FILE) allows to specify a mat-file FILE from which |
---|
6 | % default parameters are extracted and can be updated. |
---|
7 | % |
---|
8 | % For more information, please read the M2HTML tutorial and FAQ at: |
---|
9 | % <http://www.artefact.tk/software/matlab/m2html/> |
---|
10 | % |
---|
11 | % See also M2HTML |
---|
12 | |
---|
13 | % Copyright (C) 2003-2005 Guillaume Flandin <Guillaume@artefact.tk> |
---|
14 | % $Revision: 0.5 $Date: 2004/05/24 20:12:17 $ |
---|
15 | |
---|
16 | % This program is free software; you can redistribute it and/or |
---|
17 | % modify it under the terms of the GNU General Public License |
---|
18 | % as published by the Free Software Foundation; either version 2 |
---|
19 | % of the License, or any later version. |
---|
20 | % |
---|
21 | % This program is distributed in the hope that it will be useful, |
---|
22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
24 | % GNU General Public License for more details. |
---|
25 | % |
---|
26 | % You should have received a copy of the GNU General Public License |
---|
27 | % along with this program; if not, write to the Free Software |
---|
28 | % Foundation Inc, 59 Temple Pl. - Suite 330, Boston, MA 02111-1307, USA. |
---|
29 | |
---|
30 | % Suggestions for improvement and fixes are always welcome, although no |
---|
31 | % guarantee is made whether and when they will be implemented. |
---|
32 | % Send requests to Guillaume@artefact.tk |
---|
33 | |
---|
34 | error(nargchk(0,1,nargin)); |
---|
35 | |
---|
36 | disp('This is a beta version of mwizard.'); |
---|
37 | disp('Please use the online version m2html instead.'); |
---|
38 | |
---|
39 | h = initWindow; |
---|
40 | |
---|
41 | initOptions(h); |
---|
42 | |
---|
43 | buildWindow(h); |
---|
44 | |
---|
45 | setappdata(h, 'handles', guihandles(h)); |
---|
46 | setappdata(h, 'pwd', pwd); |
---|
47 | |
---|
48 | if nargin == 0 |
---|
49 | setappdata(h, 'file', ''); |
---|
50 | setappdata(h, 'needsave', 1); |
---|
51 | else |
---|
52 | setappdata(h, 'file', file); |
---|
53 | setappdata(h, 'needsave', 0); |
---|
54 | opt = load(file, 'options'); |
---|
55 | setappdata(h, 'options', opt.options); |
---|
56 | refreshOptions(h); |
---|
57 | end |
---|
58 | |
---|
59 | set(h, 'HandleVisibility', 'callback'); |
---|
60 | |
---|
61 | %=============================================================================== |
---|
62 | |
---|
63 | function h = initWindow |
---|
64 | |
---|
65 | h = figure('Resize', 'on',... |
---|
66 | 'MenuBar', 'none',... |
---|
67 | 'NumberTitle', 'off',... |
---|
68 | 'Name', ':: M2HTML Wizard ::',... |
---|
69 | 'Position', [200 200 500 650],... |
---|
70 | 'Tag', mfilename); |
---|
71 | |
---|
72 | set(h, 'CloseRequestFcn', {@doClose,h}); |
---|
73 | |
---|
74 | %=============================================================================== |
---|
75 | |
---|
76 | function buildWindow(h) |
---|
77 | |
---|
78 | wincolor = struct('bg', [0.9 0.9 0.9], ... |
---|
79 | 'fg', [0.8 0.8 0.8], ... |
---|
80 | 'title', [0.8 0.8 0.9]); |
---|
81 | |
---|
82 | set(h, 'Color', wincolor.bg); |
---|
83 | |
---|
84 | %------------------------------------------------------------------------------- |
---|
85 | %- Menu |
---|
86 | %------------------------------------------------------------------------------- |
---|
87 | |
---|
88 | icons = load(fullfile(fileparts(which(mfilename)),'private', ... |
---|
89 | 'm2htmltoolbarimages.mat')); |
---|
90 | |
---|
91 | uipushtool('CData',icons.newIcon,... |
---|
92 | 'enable','on',... |
---|
93 | 'Separator','off',... |
---|
94 | 'ToolTipString','New File',... |
---|
95 | 'ClickedCallback',{@doNewFile,h},... |
---|
96 | 'Tag','NewTool'); |
---|
97 | |
---|
98 | uipushtool('CData',icons.openIcon,... |
---|
99 | 'enable','on',... |
---|
100 | 'Separator','off',... |
---|
101 | 'ToolTipString','Open File',... |
---|
102 | 'ClickedCallback',{@doOpenFile,h},... |
---|
103 | 'Tag','OpenTool'); |
---|
104 | |
---|
105 | uipushtool('CData',icons.saveIcon,... |
---|
106 | 'enable','on',... |
---|
107 | 'Separator','off',... |
---|
108 | 'ToolTipString','Save File',... |
---|
109 | 'ClickedCallback',{@doSaveFile,h},... |
---|
110 | 'Tag','SaveTool'); |
---|
111 | |
---|
112 | uipushtool('CData',icons.saveAsIcon,... |
---|
113 | 'enable','on',... |
---|
114 | 'Separator','off',... |
---|
115 | 'ToolTipString','Save File As',... |
---|
116 | 'ClickedCallback',{@doSaveAsFile,h},... |
---|
117 | 'Tag','SaveAsTool'); |
---|
118 | |
---|
119 | uipushtool('CData',icons.wheelIcon,... |
---|
120 | 'enable','on',... |
---|
121 | 'Separator','on',... |
---|
122 | 'ToolTipString','Save and Run M2HTML',... |
---|
123 | 'ClickedCallback',{@doRunFile,h},... |
---|
124 | 'Tag','RunTool'); |
---|
125 | |
---|
126 | uipushtool('CData',icons.webIcon,... |
---|
127 | 'enable','on',... |
---|
128 | 'Separator','on',... |
---|
129 | 'ToolTipString','Online Tutorial',... |
---|
130 | 'ClickedCallback',... |
---|
131 | 'web(''http://www.artefact.tk/software/matlab/m2html/'')',... |
---|
132 | 'Tag','WebTool'); |
---|
133 | |
---|
134 | uipushtool('CData',icons.helpIcon,... |
---|
135 | 'enable','on',... |
---|
136 | 'Separator','off',... |
---|
137 | 'ToolTipString','Help',... |
---|
138 | 'ClickedCallback',{@doHelp,h},... |
---|
139 | 'Tag','HelpTool'); |
---|
140 | |
---|
141 | %------------------------------------------------------------------------------- |
---|
142 | %- Title |
---|
143 | %------------------------------------------------------------------------------- |
---|
144 | |
---|
145 | uicontrol('Style','Frame',... |
---|
146 | 'Units','Normalized',... |
---|
147 | 'Position',[0.02,0.92,0.96,0.06],... |
---|
148 | 'BackgroundColor',wincolor.title); |
---|
149 | |
---|
150 | uicontrol('Style','Text',... |
---|
151 | 'Units','Normalized',... |
---|
152 | 'String','M2HTML Wizard',... |
---|
153 | 'FontSize',18,... |
---|
154 | 'HorizontalAlignment','center',... |
---|
155 | 'Position',[0.03,0.93,0.94,0.038],... |
---|
156 | 'BackgroundColor',wincolor.title); |
---|
157 | |
---|
158 | %------------------------------------------------------------------------------- |
---|
159 | %- Input |
---|
160 | %------------------------------------------------------------------------------- |
---|
161 | |
---|
162 | uicontrol('Style','Frame',... |
---|
163 | 'Units','Normalized',... |
---|
164 | 'Position',[0.02,0.74,0.96,0.16],... |
---|
165 | 'BackgroundColor',wincolor.fg); |
---|
166 | |
---|
167 | uicontrol('Style','Frame',... |
---|
168 | 'Units','Normalized',... |
---|
169 | 'HorizontalAlignment','center',... |
---|
170 | 'Position',[0.02,0.87,0.96,0.03],... |
---|
171 | 'BackgroundColor',wincolor.title); |
---|
172 | |
---|
173 | uicontrol('Style','Text',... |
---|
174 | 'Units','Normalized',... |
---|
175 | 'String','M-Files Input',... |
---|
176 | 'HorizontalAlignment','left',... |
---|
177 | 'Position',[0.03,0.875,0.94,0.02],... |
---|
178 | 'BackgroundColor',wincolor.title); |
---|
179 | |
---|
180 | uicontrol('Style','Text',... |
---|
181 | 'Units','Normalized',... |
---|
182 | 'String','Root directory:',... |
---|
183 | 'FontAngle','oblique',... |
---|
184 | 'HorizontalAlignment','left',... |
---|
185 | 'Position',[0.04,0.825,0.6,0.03],... |
---|
186 | 'BackgroundColor',wincolor.fg); |
---|
187 | |
---|
188 | uicontrol('Style','edit',... |
---|
189 | 'Units','Normalized',... |
---|
190 | 'Position',[0.21,0.83,0.74,0.03],... |
---|
191 | 'String',pwd,... |
---|
192 | 'Enable','inactive',... |
---|
193 | 'HorizontalAlignment','left',... |
---|
194 | 'Callback','uigetfile;',...%uigetdir |
---|
195 | 'BackgroundColor',wincolor.bg,... |
---|
196 | 'Tag','rootdir'); |
---|
197 | |
---|
198 | uicontrol('Style','Text',... |
---|
199 | 'Units','Normalized',... |
---|
200 | 'String','Relative pathes:',... |
---|
201 | 'HorizontalAlignment','left',... |
---|
202 | 'Position',[0.04,0.785,0.6,0.03],... |
---|
203 | 'BackgroundColor',wincolor.fg); |
---|
204 | |
---|
205 | uicontrol('Style','edit',... |
---|
206 | 'Units','Normalized',... |
---|
207 | 'Position',[0.21,0.79,0.74,0.03],... |
---|
208 | 'String','',... |
---|
209 | 'HorizontalAlignment','left',... |
---|
210 | 'Callback',{@doSetMfiles,h},... |
---|
211 | 'CreateFcn',{@doInitMfiles,h},... |
---|
212 | 'BackgroundColor',wincolor.bg,... |
---|
213 | 'Tag','mfiles'); |
---|
214 | |
---|
215 | uicontrol('Style','CheckBox',... |
---|
216 | 'Units','Normalized',... |
---|
217 | 'Position',[0.04,0.749,0.42,0.032],... |
---|
218 | 'String',' Recursive',... |
---|
219 | 'HorizontalAlignment','left',... |
---|
220 | 'Callback',{@doSetRecursive,h},... |
---|
221 | 'Value',0,... |
---|
222 | 'BackgroundColor',wincolor.bg,... |
---|
223 | 'Tag','recursive'); |
---|
224 | |
---|
225 | %------------------------------------------------------------------------------- |
---|
226 | %- Output |
---|
227 | %------------------------------------------------------------------------------- |
---|
228 | |
---|
229 | uicontrol('Style','Frame',... |
---|
230 | 'Units','Normalized',... |
---|
231 | 'Position',[0.02, 0.56,0.96,0.16],... |
---|
232 | 'BackgroundColor',wincolor.fg); |
---|
233 | |
---|
234 | uicontrol('Style','Frame',... |
---|
235 | 'Units','Normalized',... |
---|
236 | 'HorizontalAlignment','center',... |
---|
237 | 'Position',[0.02,0.69,0.96,0.03],... |
---|
238 | 'BackgroundColor',wincolor.title); |
---|
239 | |
---|
240 | uicontrol('Style','Text',... |
---|
241 | 'Units','Normalized',... |
---|
242 | 'String','HTML Output',... |
---|
243 | 'HorizontalAlignment','left',... |
---|
244 | 'Position',[0.03,0.695,0.94,0.02],... |
---|
245 | 'BackgroundColor',wincolor.title); |
---|
246 | |
---|
247 | uicontrol('Style','Text',... |
---|
248 | 'Units','Normalized',... |
---|
249 | 'String','Output Directory:',... |
---|
250 | 'HorizontalAlignment','left',... |
---|
251 | 'Position',[0.04,0.645,0.6,0.03],... |
---|
252 | 'BackgroundColor',wincolor.fg); |
---|
253 | |
---|
254 | uicontrol('Style','edit',... |
---|
255 | 'Units','Normalized',... |
---|
256 | 'Position',[0.21,0.65,0.74,0.03],... |
---|
257 | 'String','',... |
---|
258 | 'HorizontalAlignment','left',... |
---|
259 | 'Callback',{@doSetOutputDir,h},... |
---|
260 | 'CreateFcn',{@doInitHTMLDir,h},... |
---|
261 | 'BackgroundColor',wincolor.bg,... |
---|
262 | 'Tag','htmldir'); |
---|
263 | |
---|
264 | uicontrol('Style','Text',... |
---|
265 | 'Units','Normalized',... |
---|
266 | 'String','HTML Index:',... |
---|
267 | 'HorizontalAlignment','left',... |
---|
268 | 'Position',[0.04,0.605,0.6,0.03],... |
---|
269 | 'BackgroundColor',wincolor.fg); |
---|
270 | |
---|
271 | uicontrol('Style','edit',... |
---|
272 | 'Units','Normalized',... |
---|
273 | 'Position',[0.21,0.61,0.25,0.03],... |
---|
274 | 'String','index',... |
---|
275 | 'HorizontalAlignment','left',... |
---|
276 | 'Callback',{@doSetIndex,h},... |
---|
277 | 'BackgroundColor',wincolor.bg,... |
---|
278 | 'Tag','index'); |
---|
279 | |
---|
280 | uicontrol('Style','Text',... |
---|
281 | 'Units','Normalized',... |
---|
282 | 'String','Extension:',... |
---|
283 | 'HorizontalAlignment','left',... |
---|
284 | 'Position',[0.53,0.605,0.3,0.03],... |
---|
285 | 'BackgroundColor',wincolor.fg); |
---|
286 | |
---|
287 | uicontrol('Style','edit',... |
---|
288 | 'Units','Normalized',... |
---|
289 | 'Position',[0.70,0.61,0.25,0.03],... |
---|
290 | 'String','html',... |
---|
291 | 'HorizontalAlignment','left',... |
---|
292 | 'Callback',{@doSetExtension,h},... |
---|
293 | 'BackgroundColor',wincolor.bg,... |
---|
294 | 'Tag','extension'); |
---|
295 | |
---|
296 | uicontrol('Style','Text',... |
---|
297 | 'Units','Normalized',... |
---|
298 | 'String','Template:',... |
---|
299 | 'HorizontalAlignment','left',... |
---|
300 | 'Position',[0.04,0.565,0.3,0.03],... |
---|
301 | 'BackgroundColor',wincolor.fg); |
---|
302 | |
---|
303 | uicontrol('Style','popupmenu',... |
---|
304 | 'Units','Normalized',... |
---|
305 | 'Position',[0.21,0.57,0.25,0.03],... |
---|
306 | 'String','',... |
---|
307 | 'HorizontalAlignment','center',... |
---|
308 | 'Callback',{@doSetTemplate,h},... |
---|
309 | 'CreateFcn',{@doInitTpl,h},... |
---|
310 | 'BackgroundColor',wincolor.bg,... |
---|
311 | 'Tag','template'); |
---|
312 | |
---|
313 | %------------------------------------------------------------------------------- |
---|
314 | %- Other options |
---|
315 | %------------------------------------------------------------------------------- |
---|
316 | |
---|
317 | uicontrol('Style','Frame',... |
---|
318 | 'Units','Normalized',... |
---|
319 | 'Position',[0.02,0.24,0.96,0.30],... |
---|
320 | 'BackgroundColor',wincolor.fg); |
---|
321 | |
---|
322 | uicontrol('Style','Frame',... |
---|
323 | 'Units','Normalized',... |
---|
324 | 'HorizontalAlignment','center',... |
---|
325 | 'Position',[0.02,0.51,0.96,0.03],... |
---|
326 | 'BackgroundColor',wincolor.title); |
---|
327 | |
---|
328 | uicontrol('Style','Text',... |
---|
329 | 'Units','Normalized',... |
---|
330 | 'String','Other Options',... |
---|
331 | 'HorizontalAlignment','left',... |
---|
332 | 'Position',[0.03,0.515,0.94,0.02],... |
---|
333 | 'BackgroundColor',wincolor.title); |
---|
334 | |
---|
335 | uicontrol('Style','checkbox',... |
---|
336 | 'Units','Normalized',... |
---|
337 | 'Position',[0.04,0.464,0.42,0.032],... |
---|
338 | 'String',' Include Source Code',... |
---|
339 | 'HorizontalAlignment','left',... |
---|
340 | 'Callback',{@doSetSource,h},... |
---|
341 | 'Value',1,... |
---|
342 | 'TooltipString','Include Source Code of each M-file',... |
---|
343 | 'BackgroundColor',wincolor.bg,... |
---|
344 | 'Tag','source'); |
---|
345 | |
---|
346 | uicontrol('Style','checkbox',... |
---|
347 | 'Units','Normalized',... |
---|
348 | 'Position',[0.53,0.464,0.42,0.032],... |
---|
349 | 'String',' Syntax Highlighting',... |
---|
350 | 'HorizontalAlignment','left',... |
---|
351 | 'Callback',{@doSetHighlight,h},... |
---|
352 | 'Value',1,... |
---|
353 | 'TooltipString','Source Code Syntax Highlighting',... |
---|
354 | 'BackgroundColor',wincolor.bg,... |
---|
355 | 'Tag','highlight'); |
---|
356 | |
---|
357 | uicontrol('Style','checkbox',... |
---|
358 | 'Units','Normalized',... |
---|
359 | 'Position',[0.04,0.42,0.42,0.032],... |
---|
360 | 'String',' Create Dependency Graphs',... |
---|
361 | 'HorizontalAlignment','left',... |
---|
362 | 'Callback',{@doSetGraph,h},... |
---|
363 | 'CreateFcn',{@doInitGraphs,h},... |
---|
364 | 'Value',0,... |
---|
365 | 'TooltipString','Compute a Dependency Graph using GraphViz',... |
---|
366 | 'BackgroundColor',wincolor.bg,... |
---|
367 | 'Tag','graph'); |
---|
368 | |
---|
369 | uicontrol('Style','checkbox',... |
---|
370 | 'Units','Normalized',... |
---|
371 | 'Position',[0.53,0.42,0.42,0.032],... |
---|
372 | 'String',' PHP Search Engine',... |
---|
373 | 'HorizontalAlignment','left',... |
---|
374 | 'Callback',{@doSetSearch,h},... |
---|
375 | 'Value',0,... |
---|
376 | 'TooltipString','Create an Index for a PHP Search Engine',... |
---|
377 | 'BackgroundColor',wincolor.bg,... |
---|
378 | 'Tag','search'); |
---|
379 | |
---|
380 | uicontrol('Style','checkbox',... |
---|
381 | 'Units','Normalized',... |
---|
382 | 'Position',[0.04,0.378,0.42,0.032],... |
---|
383 | 'String',' Global Hyperlinks',... |
---|
384 | 'HorizontalAlignment','left',... |
---|
385 | 'Callback',{@doSetGlobal,1},... |
---|
386 | 'Value',0,... |
---|
387 | 'TooltipString','Hypertext links among separate Matlab Directories',... |
---|
388 | 'BackgroundColor',wincolor.bg,... |
---|
389 | 'Tag','globalhypertext'); |
---|
390 | |
---|
391 | uicontrol('Style','checkbox',... |
---|
392 | 'Units','Normalized',... |
---|
393 | 'Position',[0.53,0.378,0.42,0.032],... |
---|
394 | 'String',' Downloadable M-files',... |
---|
395 | 'HorizontalAlignment','left',... |
---|
396 | 'Callback',{@doSetDownload,h},... |
---|
397 | 'TooltipString','Add a link to download each M-file separately',... |
---|
398 | 'Value',0,... |
---|
399 | 'BackgroundColor',wincolor.bg,... |
---|
400 | 'Tag','download'); |
---|
401 | |
---|
402 | uicontrol('Style','checkbox',... |
---|
403 | 'Units','Normalized',... |
---|
404 | 'Position',[0.04,0.336,0.42,0.032],... |
---|
405 | 'String',' To Do List',... |
---|
406 | 'HorizontalAlignment','left',... |
---|
407 | 'Callback',{@doSetTodo,h},... |
---|
408 | 'TooltipString',['Create a TODO list in each directory summarizing'... |
---|
409 | ' all the ''% TODO %'' lines found in Matlab code'],... |
---|
410 | 'Value',0,... |
---|
411 | 'BackgroundColor',wincolor.bg,... |
---|
412 | 'Tag','todo'); |
---|
413 | |
---|
414 | uicontrol('Style','checkbox',... |
---|
415 | 'Units','Normalized',... |
---|
416 | 'Position',[0.53,0.336,0.42,0.032],... |
---|
417 | 'String',' Verbose Mode',... |
---|
418 | 'HorizontalAlignment','left',... |
---|
419 | 'Callback',{@doSetVerbose,h},... |
---|
420 | 'TooltipString','Verbose mode',... |
---|
421 | 'Value',1,... |
---|
422 | 'BackgroundColor',wincolor.bg,... |
---|
423 | 'Tag','verbose'); |
---|
424 | |
---|
425 | uicontrol('Style','checkbox',... |
---|
426 | 'Units','Normalized',... |
---|
427 | 'Position',[0.04,0.294,0.42,0.032],... |
---|
428 | 'String',' Save M-files Parsing',... |
---|
429 | 'HorizontalAlignment','left',... |
---|
430 | 'Callback',{@doSetSaveAsMat,h},... |
---|
431 | 'TooltipString',['Save current state after M-files parsing in '... |
---|
432 | '''m2html.mat'' in the Output directory'],... |
---|
433 | 'Value',0,... |
---|
434 | 'BackgroundColor',wincolor.bg,... |
---|
435 | 'Tag','save'); |
---|
436 | |
---|
437 | uicontrol('Style','Text',... |
---|
438 | 'Units','Normalized',... |
---|
439 | 'String','Load File:',... |
---|
440 | 'HorizontalAlignment','left',... |
---|
441 | 'Position',[0.53,0.289,0.3,0.03],... |
---|
442 | 'BackgroundColor',wincolor.fg); |
---|
443 | |
---|
444 | uicontrol('Style','edit',... |
---|
445 | 'Units','Normalized',... |
---|
446 | 'Position',[0.70,0.294,0.25,0.03],... |
---|
447 | 'String','',... |
---|
448 | 'HorizontalAlignment','left',... |
---|
449 | 'Callback',{@doSetLoadMat,h},... |
---|
450 | 'TooltipString',['Load a previously saved MAT file '... |
---|
451 | 'to generate HTML files once again'],... |
---|
452 | 'BackgroundColor',wincolor.bg,... |
---|
453 | 'Tag','load'); |
---|
454 | |
---|
455 | uicontrol('Style','Text',... |
---|
456 | 'Units','Normalized',... |
---|
457 | 'String','Tabs Length:',... |
---|
458 | 'HorizontalAlignment','left',... |
---|
459 | 'Position',[0.04,0.247,0.3,0.03],... |
---|
460 | 'BackgroundColor',wincolor.fg); |
---|
461 | |
---|
462 | uicontrol('Style','edit',... |
---|
463 | 'Units','Normalized',... |
---|
464 | 'Position',[0.21,0.252,0.25,0.03],... |
---|
465 | 'String','4',... |
---|
466 | 'HorizontalAlignment','right',... |
---|
467 | 'Callback',{@doSetTabs,h},... |
---|
468 | 'TooltipString',['Replace horizontal tabs in source code '... |
---|
469 | 'by N white space characters'],... |
---|
470 | 'BackgroundColor',wincolor.bg,... |
---|
471 | 'Tag','tabs'); |
---|
472 | |
---|
473 | uicontrol('Style','Text',... |
---|
474 | 'Units','Normalized',... |
---|
475 | 'String','Nb Columns:',... |
---|
476 | 'FontAngle','oblique',... |
---|
477 | 'HorizontalAlignment','left',... |
---|
478 | 'Position',[0.53,0.247,0.3,0.03],... |
---|
479 | 'BackgroundColor',wincolor.fg); |
---|
480 | |
---|
481 | uicontrol('Style','edit',... |
---|
482 | 'Units','Normalized',... |
---|
483 | 'Position',[0.70,0.252,0.25,0.03],... |
---|
484 | 'String','4',... |
---|
485 | 'HorizontalAlignment','right',... |
---|
486 | 'Callback',{@doSetNbColumns,h},... |
---|
487 | 'TooltipString','Number of columns for M-files output - not available',... |
---|
488 | 'Enable','inactive',... |
---|
489 | 'BackgroundColor',wincolor.bg,... |
---|
490 | 'Tag','column'); |
---|
491 | |
---|
492 | |
---|
493 | %------------------------------------------------------------------------------- |
---|
494 | %- Space available |
---|
495 | %------------------------------------------------------------------------------- |
---|
496 | |
---|
497 | % uicontrol('Style','Frame',... |
---|
498 | % 'Units','Normalized',... |
---|
499 | % 'Position',[0.02,0.07,0.96,0.14],... |
---|
500 | % 'BackgroundColor',wincolor.fg); |
---|
501 | |
---|
502 | % simulate a frame using an axes |
---|
503 | % http://www.mathworks.com/support/solutions/data/1-15P9E.html |
---|
504 | axes('Color',wincolor.fg,... |
---|
505 | 'XTick',[],'YTick',[],... |
---|
506 | 'Units','Normalized',... |
---|
507 | 'Box','on',... |
---|
508 | 'Position',[0.02,0.07,0.9585,0.14]); |
---|
509 | |
---|
510 | uicontrol('Style','Frame',... |
---|
511 | 'Units','Normalized',... |
---|
512 | 'HorizontalAlignment','center',... |
---|
513 | 'Position',[0.02,0.19,0.96,0.03],... |
---|
514 | 'BackgroundColor',wincolor.title); |
---|
515 | |
---|
516 | uicontrol('Style','Text',... |
---|
517 | 'Units','Normalized',... |
---|
518 | 'String','M2HTML status',... |
---|
519 | 'HorizontalAlignment','left',... |
---|
520 | 'Position',[0.03,0.195,0.94,0.02],... |
---|
521 | 'BackgroundColor',wincolor.title); |
---|
522 | |
---|
523 | uicontrol('Style','Text',... |
---|
524 | 'Units','Normalized',... |
---|
525 | 'String','Click on the wheel in the toolbar to launch M2HTML...',... |
---|
526 | 'HorizontalAlignment','left',... % center |
---|
527 | 'Position',[0.12,0.135,0.76,0.02],... |
---|
528 | 'Visible','on',... |
---|
529 | 'BackgroundColor',wincolor.fg,... |
---|
530 | 'Tag','textmisc'); |
---|
531 | |
---|
532 | axes('XLim',[0 100],... |
---|
533 | 'YLim',[0 1],... |
---|
534 | 'Box','on', ... |
---|
535 | 'Units','Normalized',... |
---|
536 | 'Position',[0.07,0.09,0.86,0.03],... |
---|
537 | 'XTickMode','manual',... |
---|
538 | 'YTickMode','manual',... |
---|
539 | 'layer','top',... |
---|
540 | 'XTick',[],... |
---|
541 | 'YTick',[],... |
---|
542 | 'XTickLabelMode','manual',... |
---|
543 | 'XTickLabel',[],... |
---|
544 | 'YTickLabelMode','manual',... |
---|
545 | 'Visible','on',... |
---|
546 | 'YTickLabel',[],... |
---|
547 | 'Color',wincolor.bg); |
---|
548 | |
---|
549 | x = 0; % between 0 and 100 |
---|
550 | xpatch = [0 x x 0]; |
---|
551 | ypatch = [0 0 1 1]; |
---|
552 | |
---|
553 | p = patch(xpatch,ypatch,'r',... |
---|
554 | 'EdgeColor','r',... |
---|
555 | 'Visible','on',... |
---|
556 | 'EraseMode','none',... |
---|
557 | 'Tag','waitbarmisc'); |
---|
558 | |
---|
559 | l = line([100 0 0 100 100], [0 0 1 1 0], ... |
---|
560 | 'EraseMode','none', ... |
---|
561 | 'Visible','on',... |
---|
562 | 'Color',get(gca,'XColor')); |
---|
563 | |
---|
564 | % for i=10:5:100 |
---|
565 | % set(p,'Xdata',[0 i i 0]); pause(0.02); |
---|
566 | % end |
---|
567 | % set(p,'EraseMode','normal'); |
---|
568 | % set(p,'Xdata',[0 0 0 0]); |
---|
569 | % set(p,'EraseMode','none'); |
---|
570 | |
---|
571 | %------------------------------------------------------------------------------- |
---|
572 | %- Footnote |
---|
573 | %------------------------------------------------------------------------------- |
---|
574 | |
---|
575 | uicontrol('Style','Frame',... |
---|
576 | 'Units','Normalized',... |
---|
577 | 'Position',[0.02,0.02,0.96,0.03],... |
---|
578 | 'BackgroundColor',[0.8 0.8 0.9]); |
---|
579 | |
---|
580 | uicontrol('Style','Text',... |
---|
581 | 'Units','Normalized',... |
---|
582 | 'String',['M2HTML © 2003-2005 Guillaume Flandin <Guillaume@artefact.tk>'],... |
---|
583 | 'HorizontalAlignment','right',... |
---|
584 | 'Position',[0.03,0.025,0.94,0.02],... |
---|
585 | 'BackgroundColor',[0.8 0.8 0.9]); |
---|
586 | |
---|
587 | %=============================================================================== |
---|
588 | |
---|
589 | function doClose(fig,evd,h) |
---|
590 | status = doCheckSave(h); |
---|
591 | if status |
---|
592 | delete(h); |
---|
593 | end |
---|
594 | |
---|
595 | function doNewFile(fig,evd,h) |
---|
596 | status = doCheckSave(h); |
---|
597 | if status |
---|
598 | initOptions(h); |
---|
599 | setappdata(h, 'needsave', 1); |
---|
600 | % refresh options in GUI... |
---|
601 | refreshOptions(h); |
---|
602 | end |
---|
603 | |
---|
604 | function doOpenFile(fig,evd,h) |
---|
605 | status = doCheckSave(h); |
---|
606 | if status |
---|
607 | [filename, pathname] = uigetfile('*.mat','Open File'); |
---|
608 | if ~(isequal(filename,0)|isequal(pathname,0)) |
---|
609 | opt = load(fullfile(pathname,filename),'options'); |
---|
610 | setappdata(h,'options',opt.options); |
---|
611 | setappdata(h,'file',fullfile(pathname,filename)); |
---|
612 | end |
---|
613 | end |
---|
614 | % refresh options in GUI... |
---|
615 | refreshOptions(h); |
---|
616 | |
---|
617 | function status = doSaveFile(fig,evd,h) |
---|
618 | file = getappdata(h,'file'); |
---|
619 | status = 1; |
---|
620 | if isempty(file) |
---|
621 | status = doSaveAsFile(fig,evd,h); |
---|
622 | else |
---|
623 | options = getappdata(h,'options'); |
---|
624 | save(file, 'options'); |
---|
625 | end |
---|
626 | setappdata(h,'needsave',0); |
---|
627 | |
---|
628 | function status = doSaveAsFile(fig,evd,h) |
---|
629 | [filename, pathname] = uiputfile('matlab.mat', 'Save File as'); |
---|
630 | if ~(isequal(filename,0)|isequal(pathname,0)) |
---|
631 | setappdata(h,'file',fullfile(pathname,filename)); |
---|
632 | status = doSaveFile(fig,evd,h); |
---|
633 | else |
---|
634 | status = 0; |
---|
635 | end |
---|
636 | |
---|
637 | function doRunFile(fig,evd,h) |
---|
638 | status = doSaveFile(fig,evd,h); |
---|
639 | if status |
---|
640 | opt = getappdata(h,'options'); |
---|
641 | file = getappdata(h,'file'); |
---|
642 | r = {'off' 'on'}; |
---|
643 | % opt could be directly given to m2html (no need for file saving) |
---|
644 | % just need to convert on/off using opt.param = r{opt.param+1} |
---|
645 | m2html('load',file,'recursive',r{opt.recursive+1}); |
---|
646 | % 'recursive' is specified to force m2html to parse M-files |
---|
647 | end |
---|
648 | |
---|
649 | function status = doCheckSave(h) |
---|
650 | file = getappdata(h,'file'); |
---|
651 | if isempty(file), file = 'Untitled'; end |
---|
652 | needsave = getappdata(h,'needsave'); |
---|
653 | status = 1; |
---|
654 | if needsave |
---|
655 | button = questdlg(sprintf('Save changes to %s?',file),... |
---|
656 | 'Mwizard','Yes','No','Cancel','Yes'); |
---|
657 | if strcmp(button,'Yes') |
---|
658 | status = doSaveFile([],[],h); |
---|
659 | elseif strcmp(button,'Cancel') |
---|
660 | status = 0; |
---|
661 | end |
---|
662 | end |
---|
663 | |
---|
664 | function doHelp(fig,evd,h) |
---|
665 | helpdlg(sprintf(['M2HTML by Guillaume Flandin\n'... |
---|
666 | 'Copyright © 2003-2005\nGuillaume@artefact.tk\n'... |
---|
667 | '<http://www.artefact.tk/>']),'M2HTML Wizard'); |
---|
668 | |
---|
669 | %=============================================================================== |
---|
670 | |
---|
671 | %------------------------------------------------------------------------------- |
---|
672 | %- Default parameters |
---|
673 | %------------------------------------------------------------------------------- |
---|
674 | |
---|
675 | function varargout = initOptions(h) |
---|
676 | options = struct('verbose', 1,... |
---|
677 | 'mFiles', {{''}},... |
---|
678 | 'htmlDir', 'doc',... |
---|
679 | 'recursive', 0,... |
---|
680 | 'source', 1,... |
---|
681 | 'download',0,... |
---|
682 | 'syntaxHighlighting', 1,... |
---|
683 | 'tabs', 4,... |
---|
684 | 'globalHypertextLinks', 0,... |
---|
685 | 'graph', 0,... |
---|
686 | 'todo', 0,... |
---|
687 | 'load', 0,... |
---|
688 | 'save', 0,... |
---|
689 | 'search', 0,... |
---|
690 | 'helptocxml', 0,... |
---|
691 | 'indexFile', 'index',... |
---|
692 | 'extension', '.html',... |
---|
693 | 'template', 'blue',... |
---|
694 | 'rootdir', pwd,... |
---|
695 | 'ignoredDir', {{'.svn' 'cvs'}}, ... |
---|
696 | 'language','english'); |
---|
697 | |
---|
698 | if nargin == 1, |
---|
699 | setappdata(h,'options',options); |
---|
700 | else |
---|
701 | varargout{1} = options; |
---|
702 | end |
---|
703 | |
---|
704 | function refreshOptions(h) |
---|
705 | opt = getappdata(h,'options'); |
---|
706 | handles = getappdata(h,'handles'); |
---|
707 | |
---|
708 | doInitTpl(handles.template, 0, h); |
---|
709 | doInitMfiles(handles.mfiles, 0, h); |
---|
710 | doInitHTMLDir(handles.htmldir, 0, h) |
---|
711 | |
---|
712 | set(handles.recursive, 'Value', opt.recursive); |
---|
713 | set(handles.graph, 'Value', opt.graph); %doInitGraphs(handles.graph,0,h); |
---|
714 | set(handles.save, 'Value', opt.save); |
---|
715 | set(handles.verbose, 'Value', opt.verbose); |
---|
716 | set(handles.todo, 'Value', opt.todo); |
---|
717 | set(handles.download, 'Value', opt.download); |
---|
718 | set(handles.search, 'Value', opt.search); |
---|
719 | set(handles.highlight, 'Value', opt.syntaxHighlighting); |
---|
720 | set(handles.source, 'Value', opt.source); |
---|
721 | set(handles.globalhypertext, 'Value', opt.globalHypertextLinks); |
---|
722 | |
---|
723 | set(handles.index, 'String', opt.indexFile); |
---|
724 | set(handles.extension, 'String', opt.extension(2:end)); %remove the '.' |
---|
725 | set(handles.tabs, 'String', num2str(opt.tabs)); |
---|
726 | if ~strcmp(opt.rootdir, pwd) |
---|
727 | warning('[M2HTML] You should ''cd %s'' before...',opt.rootdir); |
---|
728 | end |
---|
729 | set(handles.rootdir, 'String', opt.rootdir); % need to 'cd' if different... |
---|
730 | set(handles.column, 'String', num2str(4)); %- not saved... default here |
---|
731 | if ischar(opt.load) |
---|
732 | set(handles.load, 'String', opt.load); |
---|
733 | else |
---|
734 | set(handles.load, 'String', ''); |
---|
735 | end |
---|
736 | |
---|
737 | set(handles.textmisc, 'String', ... |
---|
738 | 'Click on the wheel in the toolbar to launch M2HTML...'); %- not saved... default here |
---|
739 | set(handles.waitbarmisc, 'EraseMode','normal'); |
---|
740 | set(handles.waitbarmisc, 'Xdata',[0 0 0 0]); |
---|
741 | set(handles.waitbarmisc, 'EraseMode','none'); |
---|
742 | |
---|
743 | |
---|
744 | %------------------------------------------------------------------------------- |
---|
745 | %- CreateFcn Callbacks |
---|
746 | %------------------------------------------------------------------------------- |
---|
747 | |
---|
748 | function doInitHTMLDir(fig,evd,h) |
---|
749 | %- problems when htmlDir is still a full path |
---|
750 | opt = getappdata(h,'options'); |
---|
751 | if isempty(strmatch(lower(pwd),lower(opt.htmlDir))) |
---|
752 | opt.htmlDir = fullfile(pwd, opt.htmlDir); |
---|
753 | end |
---|
754 | set(fig,'String',opt.htmlDir); |
---|
755 | setappdata(h,'options',opt); |
---|
756 | |
---|
757 | function doInitTpl(fig,evd,h) |
---|
758 | %- problems when templates are still in full format |
---|
759 | opt = getappdata(h,'options'); |
---|
760 | d = dir(fullfile(fileparts(which(mfilename)),'templates')); |
---|
761 | d = {d([d.isdir]).name}; |
---|
762 | d = {d{~ismember(d,{'.' '..'})}}; |
---|
763 | if ~isempty(d) |
---|
764 | tpl = sprintf('%s|',d{:}); |
---|
765 | set(fig,'String',tpl(1:end-1)); |
---|
766 | i = strmatch(opt.template,d,'exact'); |
---|
767 | if ~isempty(i) |
---|
768 | set(fig,'Value',i(1)); |
---|
769 | else |
---|
770 | %- where is the default template ? |
---|
771 | warning('[M2HTML] Default template ''%s'' not found.',opt.template); |
---|
772 | set(fig,'Value',1); |
---|
773 | opt.template = d{1}; |
---|
774 | setappdata(h,'options',opt); |
---|
775 | warning('[M2HTML] Using template ''%s'' instead.',opt.template); |
---|
776 | end |
---|
777 | else |
---|
778 | error('[M2HTML] No template found.'); |
---|
779 | end |
---|
780 | |
---|
781 | function doInitMfiles(fig,evd,h) |
---|
782 | opt = getappdata(h,'options'); |
---|
783 | if ~isempty(opt.mFiles{1}) |
---|
784 | s = sprintf('''%s'', ',opt.mFiles{:}); s = s(1:end-2); |
---|
785 | set(fig,'String',['{' s '}']); |
---|
786 | return; |
---|
787 | end |
---|
788 | d = dir(pwd); d = {d([d.isdir]).name}; |
---|
789 | d = {d{~ismember(d,{'.' '..'})}}; |
---|
790 | if length(d) == 0 |
---|
791 | warning('[M2HTML] No subsequent directory found. Check your cwd.'); |
---|
792 | set(fig,'String',''); %- maybe open a uigetdir ? |
---|
793 | opt.mFiles = {''}; |
---|
794 | elseif length(d) == 1 |
---|
795 | set(fig,'String',d{1}); |
---|
796 | opt.mFiles = d; |
---|
797 | else |
---|
798 | s = sprintf('''%s'', ',d{:}); s = s(1:end-2); |
---|
799 | set(fig,'String',['{' s '}']); |
---|
800 | opt.mFiles = d; |
---|
801 | end |
---|
802 | setappdata(h,'options',opt); |
---|
803 | |
---|
804 | function doInitGraphs(fig,evd,h) |
---|
805 | opt = getappdata(h,'options'); |
---|
806 | [s, w] = system('dot -V'); |
---|
807 | if s |
---|
808 | disp('GraphViz not installed: Generation of dependency graphs desactivated.'); |
---|
809 | disp('See http://www.graphviz.org/ to get ''dot'' tool.'); |
---|
810 | set(fig,'FontAngle','Oblique','Enable','inactive'); |
---|
811 | set(fig,'Value',0); |
---|
812 | opt.graph = 0; |
---|
813 | setappdata(h,'options',opt); |
---|
814 | else |
---|
815 | set(fig,'Value',opt.graph); |
---|
816 | end |
---|
817 | |
---|
818 | |
---|
819 | %=============================================================================== |
---|
820 | |
---|
821 | %------------------------------------------------------------------------------- |
---|
822 | %- M-Files Input Callbacks |
---|
823 | %------------------------------------------------------------------------------- |
---|
824 | |
---|
825 | function doSetMfiles(fig,evd,h) |
---|
826 | opt = getappdata(h,'options'); |
---|
827 | l = get(fig,'String'); |
---|
828 | l = fliplr(deblank(fliplr(l))); |
---|
829 | if isempty(l) | l(1) ~= '{' |
---|
830 | opt.mFiles = {l}; |
---|
831 | else |
---|
832 | try, |
---|
833 | d = eval(l); |
---|
834 | catch, |
---|
835 | disp('[M2HTML] The list of M-files is corrupted. Please check it.'); |
---|
836 | return; |
---|
837 | end |
---|
838 | [i,v] = listdlg('ListString',d,... |
---|
839 | 'PromptString','Select folder(s):',... |
---|
840 | 'Name',':: M2HTML :: M-files',... |
---|
841 | 'SelectionMode','multiple'); |
---|
842 | if v == 1 |
---|
843 | d = {d{i}}; |
---|
844 | s = sprintf('''%s'', ',d{:}); s = s(1:end-2); |
---|
845 | set(fig,'String',['{' s '}']); |
---|
846 | end |
---|
847 | opt.mFiles = d; |
---|
848 | end |
---|
849 | setappdata(h,'options',opt); |
---|
850 | |
---|
851 | function doSetRecursive(fig,evd,h) |
---|
852 | opt = getappdata(h,'options'); |
---|
853 | opt.recursive = get(fig,'Value'); |
---|
854 | setappdata(h,'options',opt); |
---|
855 | |
---|
856 | %------------------------------------------------------------------------------- |
---|
857 | %- HTML Output Callbacks |
---|
858 | %------------------------------------------------------------------------------- |
---|
859 | |
---|
860 | function doSetOutputDir(fig,evd,h) |
---|
861 | opt = getappdata(h,'options'); |
---|
862 | opt.htmlDir = get(fig,'String'); |
---|
863 | setappdata(h,'options',opt); |
---|
864 | |
---|
865 | function doSetIndex(fig,evd,h) |
---|
866 | opt = getappdata(h,'options'); |
---|
867 | opt.indexFile = get(fig,'String'); |
---|
868 | setappdata(h,'options',opt); |
---|
869 | |
---|
870 | function doSetExtension(fig,evd,h) |
---|
871 | opt = getappdata(h,'options'); |
---|
872 | e = get(fig,'String'); |
---|
873 | if ~isempty(e) & e(1) ~= '.' |
---|
874 | e = ['.' e]; |
---|
875 | end |
---|
876 | opt.extension = e; |
---|
877 | setappdata(h,'options',opt); |
---|
878 | |
---|
879 | function doSetTemplate(fig,evd,h) |
---|
880 | opt = getappdata(h,'options'); |
---|
881 | s = get(fig,'String'); |
---|
882 | v = get(fig,'Value'); |
---|
883 | opt.template = deblank(s(v,:)); |
---|
884 | setappdata(h,'options',opt); |
---|
885 | |
---|
886 | %------------------------------------------------------------------------------- |
---|
887 | %- Options Callbacks |
---|
888 | %------------------------------------------------------------------------------- |
---|
889 | |
---|
890 | function doSetSource(fig,evd,h) |
---|
891 | opt = getappdata(h,'options'); |
---|
892 | opt.source = get(fig,'Value'); |
---|
893 | setappdata(h,'options',opt); |
---|
894 | |
---|
895 | function doSetHighlight(fig,evd,h) |
---|
896 | opt = getappdata(h,'options'); |
---|
897 | opt.syntaxHighlighting = get(fig,'Value'); |
---|
898 | setappdata(h,'options',opt); |
---|
899 | |
---|
900 | function doSetGraph(fig,evd,h) |
---|
901 | opt = getappdata(h,'options'); |
---|
902 | opt.graph = get(fig,'Value'); |
---|
903 | setappdata(h,'options',opt); |
---|
904 | |
---|
905 | function doSetSearch(fig,evd,h) |
---|
906 | opt = getappdata(h,'options'); |
---|
907 | opt.search = get(fig,'Value'); |
---|
908 | setappdata(h,'options',opt); |
---|
909 | |
---|
910 | function doSetGlobal(fig,evd,h) |
---|
911 | opt = getappdata(h,'options'); |
---|
912 | opt.globalHypertextLinks = get(fig,'Value'); |
---|
913 | setappdata(h,'options',opt); |
---|
914 | |
---|
915 | function doSetDownload(fig,evd,h) |
---|
916 | opt = getappdata(h,'options'); |
---|
917 | opt.download = get(fig,'Value'); |
---|
918 | setappdata(h,'options',opt); |
---|
919 | |
---|
920 | function doSetTodo(fig,evd,h) |
---|
921 | opt = getappdata(h,'options'); |
---|
922 | opt.todo = get(fig,'Value'); |
---|
923 | setappdata(h,'options',opt); |
---|
924 | |
---|
925 | function doSetVerbose(fig,evd,h) |
---|
926 | opt = getappdata(h,'options'); |
---|
927 | opt.verbose = get(fig,'Value'); |
---|
928 | setappdata(h,'options',opt); |
---|
929 | |
---|
930 | function doSetSaveAsMat(fig,evd,h) |
---|
931 | opt = getappdata(h,'options'); |
---|
932 | opt.save = get(fig,'Value'); |
---|
933 | setappdata(h,'options',opt); |
---|
934 | |
---|
935 | function doSetLoadMat(fig,evd,h) |
---|
936 | opt = getappdata(h,'options'); |
---|
937 | [fname, pname, findex] = uigetfile('m2html.mat',... |
---|
938 | 'Load a m2html MAT-file'); |
---|
939 | if findex |
---|
940 | opt.load = fullfile(pname,fname); |
---|
941 | set(fig,'String',fullfile(pname,fname)); |
---|
942 | end |
---|
943 | setappdata(h,'options',opt); |
---|
944 | |
---|
945 | function doSetTabs(fig,evd,h) |
---|
946 | opt = getappdata(h,'options'); |
---|
947 | t = str2num(get(fig,'String')); |
---|
948 | if t >= 0 & length(t) == 1 |
---|
949 | opt.tabs = t; |
---|
950 | else |
---|
951 | set(fig,'String',num2str(opt.tabs)); |
---|
952 | end |
---|
953 | setappdata(h,'options',opt); |
---|
954 | |
---|
955 | function doSetNbColumns(fig,evd,h) |
---|
956 | opt = getappdata(h,'options'); |
---|
957 | disp 'Not available'; |
---|
958 | setappdata(h,'options',opt); |
---|
959 | |
---|
960 | %=============================================================================== |
---|
961 | |
---|
962 | function text2 = shortenText(text, l) |
---|
963 | |
---|
964 | if nargin == 1, l = 64; end |
---|
965 | m = length(text); |
---|
966 | text2 = text; |
---|
967 | if m > l |
---|
968 | s = floor((l - 3) / 2); |
---|
969 | text2 = [text(1:s) '...' text(end-(l-s-3)+1:end)]; |
---|
970 | end |
---|