?? gui_scripter.m
字號:
% GUI_Scripter: A utility that creates an m-script for a GUI interface
% from a Visual Basic 6.0 project. There are certain limitations and guidlines
% which MUST be followed in the creation of the VB User Interface.
% These are documented in the instruction document.
% Martin Dale, July 2002
% Copyright 2002 All Rights Reserved.
% Version 1.00 9 June 2002
% Contact Martin.Dale@Physics.org
clear all;
[f p]=uigetfile('*.vbp','Select Visual Basic 6.0 Project');
eval(['cd ',p])
projectlist=textread([p f],'%s','delimiter','\n','whitespace','');
projectlist=strjust(char(projectlist),'left');
projectlist=cellstr(projectlist);
projectlist=lower(projectlist);
form_no=0;
completed=[];
!md matlab_gui;
for projtext=1:length(projectlist)
[param, value]=strtok(projectlist{projtext},'=');
if strcmpi(param,'form')
form_no=form_no+1;
inputfile=value(2:end);
outputfile=inputfile;
outputfile(end-1:end)=[];
outputfile(end)='m';
%start of processing for each form - this is within the for & if statements
formlist=textread([p inputfile],'%s','delimiter','\n','whitespace','');
formlist=strjust(char(formlist),'left');
formlist=cellstr(formlist);
formlist=lower(formlist);
for i=1:length(formlist)
[formlist{i},comments]=strtok(formlist{i},'''');
formlist{i}=strrep(formlist{i},'"','''');
indice=findstr('&h',formlist{i});
if ~isempty(indice)
formlist{i}(indice)='''';
formlist{i}(indice+10)='''';
end
[formlist{i},offset{i}]=strtok(formlist{i},':');
end
virtualparent{1}='0'; %defined for root object
for i=1:length(formlist)
[word1, rest]=strtok(formlist{i});
if (strcmpi(word1,'begin'))
[controltype,other1]=strtok(rest);
[controlname,other2]=strtok(other1);
controlname=[controlname,'_',num2str(form_no)];
j=i+1;
count=0; % counter for number of properties per object
[word1,rest]=strtok(formlist{j});
while (~strcmpi(word1,'begin') &j<=length(formlist)-1 & ~strcmpi(word1,'end'))
count=count+1;
props{count}=formlist{j};
j=j+1;
[word1,rest]=strtok(formlist{j});
if strcmpi(word1,'beginproperty')
proptype=rest;
count2=0; % counter for number of font properties
j=j+1;
while (~strcmpi(word1,'endproperty'))
count2=count2+1;
fontprops{count2}=formlist{j};
j=j+1;
[word1,rest]=strtok(formlist{j});
end
j=j+1;
end
if ~isempty(offset{j})
count=count+1;
props{count}=['binary_offset=''',offset{j}(2:end),''';'];
end
end
eval([controltype,'.',controlname,'.','handle=''',controlname,''';']);
for a=1:length(props)
eval([controltype,'.',controlname,'.',props{a},';']);
if exist('fontprops')
for b=1:length(fontprops)
eval([controltype,'.',controlname,'.',fontprops{b},';']);
end
end
end
eval([controltype,'.',controlname,'.virtualparent=''',virtualparent{end},''';'])
virtualparent{end+1}=controlname;
if (strcmpi(word1,'end'))
virtualparent(end)=[];
k=j+1;
[word1,rest]=strtok(formlist{k});
while strcmpi(word1,'end')
virtualparent(end)=[];
k=k+1;
[word1,rest]=strtok(formlist{k});
end
end
clear props;
clear fontprops;
end
end
%open file for output
p2=[p,'matlab_gui\'];
fid=fopen([p2 outputfile],'w');
%script in text for some overall requirements
str='set(0,''Units'',''Points'');';
fprintf(fid,[str,'\n']);
str='screen=20*get(0,''screensize'');';
fprintf(fid,[str,'\n']);
%Switch case here to create formatted text strings from structure "vb."
%Write form script - send file ID and VB. structure and controltype
if isfield(vb,'form')
scriptform(vb, fid);
end
if isfield(vb,'frame')
scriptcontrol(vb, fid, 'frame');
end
if isfield(vb,'optionbutton')
scriptcontrol(vb, fid, 'radiobutton');
end
if isfield(vb,'commandbutton')
scriptcontrol(vb, fid, 'pushbutton');
end
if isfield(vb,'checkbox')
scriptcontrol(vb, fid, 'checkbox');
end
if isfield(vb,'textbox')
scriptcontrol(vb, fid, 'edit');
end
if (isfield(vb,'vscrollbar') | isfield(vb,'hscrollbar'))
scriptcontrol(vb, fid, 'slider');
end
if isfield(vb,'listbox')
scriptcontrol(vb, fid, 'listbox');
end
if isfield(vb,'combobox')
scriptcontrol(vb, fid, 'popupmenu');
end
if isfield(vb,'label')
scriptcontrol(vb, fid, 'text');
end
if isfield(vb,'picturebox')
scriptcontrol(vb, fid, 'axes');
end
if isfield(vb,'menu')
scriptmenu(vb, fid);
end
fprintf(fid,'set(0,''userdata'',handlelist);\n');
fprintf(fid,'clear all;\n');
fprintf(fid,'%%Run a script here to set callbacks for your objects');
fclose(fid);
% end of individual form processing, close initial for and if statement
completed=[completed,outputfile,', '];
end
clear vb;
end
%eval(['dos(''copy gui_scripter\script_resize.m ',p2,''');']); %HARD CODE THESE PATHS IF YOU WANT TO.
%eval(['dos(''copy gui_scripter\script_radiogroup.m ',p2,''');']);
eval(['cd ',p2]);
msgbox(['Files Created - ',completed], 'GUI Scripter');
clear all
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -