% Installer: "filepick_install.m" % Created: 19-Jun-2001 10:25:40. function bund_driver % bund_driver -- Driver for "bund" bundles. % bund_driver (no arguments) contains Matlab commands % to inflate the instructions and files that are % encoded into the "bund_data" function of this package. % Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. % All Rights Reserved. % Disclosure without explicit written consent from the % copyright owner does not constitute publication. % Version of 14-Jun-2001 10:54:16. % Updated 19-Jun-2001 09:33:22. help(mfilename) BINARY_TAG = '?'; CR = sprintf('\n'); LF = sprintf('\r'); c = zeros(1, 256); c(abs('0'):abs('9')) = 0:9; c(abs('a'):abs('f')) = 10:15; disp([' ']) disp([' ## This installer is ready to expand its contents,']) disp([' ## starting in the present directory: "' pwd '"']) disp([' ## To abort, execute an interruption now.']) disp([' ## Otherwise, to continue, press any key.']) disp([' ']) try pause catch disp([' ## Installation interrupted.']) disp([' ']) return end tic w = which(mfilename); fin = fopen(w, 'r'); if fin < 0, return, end found = ~~0; while ~found s = fgetl(fin); if isequal(s, -1) fclose(fin); return end s = strrep(s, LF, ''); % Not necessary? s = strrep(s, CR, ''); % Not necessary? if isequal(s, 'function bund_data') found = ~~1; end end fout = -1; done = ~~0; while ~done s = fgetl(fin); if isequal(s, -1) fclose(fin); return end if length(s) > 0 if s(1) ~= '%' f = findstr(s, 'bund_setdir'); if any(f) theDir = eval(strrep(s, 'bund_setdir', '')); status = mkdir(theDir); switch status case 1 disp([' ## Directory created: "' theDir '"']) case 2 disp([' ## Directory exists: "' theDir '"']) otherwise disp([' ## Error while making new directory.']) end try cd(theDir) catch error([' ## Unable to go to directory: "' theDir '"']) end else eval(s); end elseif length(s) > 1 & s(2) == BINARY_TAG hx = double(s(3:end)); % Assume hex data. bin = 16*c(hx(1:2:end)) + c(hx(2:2:end)); fwrite(fout, bin, 'uchar'); else fprintf(fout, '%s\n', s(2:end)); end end end fclose(fin); disp([' ## Elapsed time: ' num2str(fix(10*toc)/10) ' s.']) function bund_data bund_setdir('filepick') bund_setdir('@filepick') disp(' ## Installing: "event.m" (text)') fout = fopen('event.m', 'w'); %function theResult = Event(self, theMode) % %% filepick/event -- Event handler. %% Event(self) handles mouse events associated %% with self, a "filepick" object. % %% Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 13-Jun-2001 15:21:01. %% Updated 14-Jun-2001 15:49:21. % %if nargin < 1, help(mfilename), return, end %if nargin < 2, theMode = 'normal'; end % %theFigure = self.itSelf; % %theDirectory = findobj(theFigure, 'Tag', 'Directory'); %theSource = findobj(theFigure, 'Tag', 'Source'); %theDestination = findobj(theFigure, 'Tag', 'Destination'); %theOkay = findobj(theFigure, 'Tag', 'Okay'); % %theSourceString = get(theSource, 'String'); %theDestinationString = get(theDestination, 'String'); % %theDirectoryString = get(theDirectory, 'String'); %theDirectoryValue = get(theDirectory, 'Value'); % %theTag = get(gcbo, 'Tag'); %theValue = get(gcbo, 'Value'); %theOldValue = get(gcbo, 'UserData'); % %% Update the GUI. % %switch theMode %case 'update' % filterspec = self.itsFilterSpec; % p = pwd; % if p(end) ~= filesep, p(end+1) = filesep; end % f = find(p == filesep); % theDirectoryString = cell(length(f), 1); % k = 0; % for i = 1:length(f) % theDirectoryString{i} = p(k+1:f(i)-1); % k = f(i); % end % set(theDirectory, 'String', theDirectoryString, ... % 'Value', length(theDirectoryString)) % theTag = ''; % files = dir; % theSourceString = cell(length(files), 1); % for i = length(files):-1:1 % name = files(i).name; % theSourceString{i} = name; % if files(i).isdir % name = ['<' name '>']; % theSourceString{i} = name; % elseif ~isempty(filterspec) % okay = ~~0; % for j = 1:length(filterspec) % f = findstr1(name, filterspec{j}); % if any(f), okay = ~~1; break, end % end % if ~okay, theSourceString(i) = []; end % end % end % if isempty(theSourceString) % theSourceString = {'(no files)'}; % end % set(theSource, 'String', theSourceString, 'Value', 1, 'UserData', files) % return %otherwise %end % %% Process mouse action. % %switch lower(theTag) %case 'directory' % k = length(theDirectoryString) - theDirectoryValue; % for i = 1:k, cd .., end % event(self, 'update') % return %case 'source' % Not correct. % name = theSourceString{theValue}; % if name(1) == '<' & name(end) == '>' % Directory. % name = name(2:end-1); % cd(name) % event(self, 'update') % return % elseif ~isequal(name, '(no files)') % theSrc = theSource; % theDst = theDestination; % theTag = 'Move'; % end %case 'destination' % theSrc = theDestination; % theDst = theSource; % theTag = 'Move'; %otherwise %end % %% Transfer a string. % %switch lower(theTag) %case 'move' % theSrcList = get(theSrc, 'String'); % theDstList = get(theDst, 'String'); % theSrcValue = get(theSrc, 'Value'); % theDstValue = get(theDst, 'Value'); % s = theSrcList{theSrcValue}; % d = theDirectoryString; % p = ''; % for i = 1:length(d) % p = [p d{i} filesep]; % end % s = [p s]; % switch lower(theMode) % case 'unique' % theDstList = [theDstList; {s}]; % theSrcList(theSrcValue) = []; % theSrcValue = min(theSrcValue, length(theSrcList)); % theDstValue = length(theDstList); % case 'multiple' % if theDst == theDestination % theDstList = [theDstList; {s}]; % theDstValue = length(theDstList); % elseif theDst == theSource % theSrcList(theSrcValue) = []; % theSrcValue = min(theSrcValue, length(theSrcList)); % end % otherwise % end % set(theSrc, 'String', theSrcList, 'UserData', theSrcValue) % set(theDst, 'String', theDstList, 'UserData', theDstValue) % if length(theSrcList) > 0, set(theSrc, 'Value', theSrcValue), end % if length(theDstList) > 0, set(theDst, 'Value', theDstValue), end % set(theOkay, 'UserData', get(theDestination, 'String')) %case {'cancel', 'okay'} % set(theFigure, 'UserData', []) %otherwise %end fclose(fout); disp(' ## Installing: "filepick.m" (text)') fout = fopen('filepick.m', 'w'); %function [p, f] = filepick(theFilterSpec, theDialogTitle, x, y, varargin) % %% filepick/filepick -- Pick one or more files. %% filepick(filterSpec, dialogTitle, x, y) presents a dialog for %% selecting one or more files, the full-path names of which are %% returned in a cell-array. To remove an unwanted selection, %% click on it. In the directories are marked by <...> triangular %% brackets. If "Cancel" is chosen, the result will be empty. %% Several file-filters can be specified as a compact comma-separated %% list, or as a cell-array of the individual filters, as in: %% '*.dat,*.nc', or {'*.dat, '*.nc'}. %% [p, f] = filepick(...) returns the paths and filenames in separate %% cell-arrays. % %% Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 13-Jun-2001 15:21:01. %% Updated 14-Jun-2001 15:56:23. % %if nargin < 1, theFilterSpec = ''; end %if nargin < 2, theDialogTitle = 'File Picker'; end % %theName = theDialogTitle; %theMode = 'multiple'; % %thePrompt{1} = {'<== Select Files By Single Click ==>'}; %thePrompt{2} = 'Directory'; %thePrompt{3} = 'Selected'; % %theDirectory = pwd; %cd(theDirectory) % %oldPWD = pwd; % %files = dir; %theSourceList = cell(length(files), 1); %for i = 1:length(files) % theSourceList{i} = files(i).name; %end % %theSourceList = [theSourceList(:)]; %theDestinationList = cell(0, 1); % %if nargout > 1, theResult = cell(0, 1); end % %theFigure = figure('Name', theName, 'NumberTitle', 'off', ... % 'WindowStyle', 'modal', 'Visible', 'off', 'Resize', 'off'); %thePosition = get(theFigure, 'Position'); %thePosition(2) = thePosition(2) + 0.10 .* thePosition(4); %thePosition(3) = 0.5 .* thePosition(3); %thePosition(4) = 0.80 .* thePosition(4); % %thePosition(3) = thePosition(3) * 2; % %if nargin > 2, thePosition(1) = x; end %if nargin > 3, thePosition(2) = y; end % %set(theFigure, 'Position', thePosition) % %fs = theFilterSpec; %if ~iscell(fs) % if any(fs) % if fs(end) ~= ',', fs(end+1) = ','; end % f = find(fs == ','); % theFilterSpec = cell(1, length(f)); % k = 0; % for i = 1:length(f) % theFilterSpec{i} = fs(k+1:f(i)-1); % k = f(i); % end % else % theFilterSpec = []; % end %end % %theStruct.itSelf = theFigure; %theStruct.itsFilterSpec = theFilterSpec; %self = class(theStruct, 'filepick'); %set(theFigure, 'UserData', self) % %if isempty(self), return, end % %theFrame = uicontrol('Style', 'frame', 'Visible', 'on', ... % 'Units', 'normalized', 'Position', [0 0 1 1], ... % 'BackgroundColor', [0.5 1 1]); % %theControls = zeros(7, 1); %theControls(1) = uicontrol('Style', 'text', 'Tag', 'Label', ... % 'String', thePrompt{1}, 'HorizontalAlignment', 'center'); %theControls(2) = uicontrol('Style', 'text', 'Tag', 'Label', ... % 'String', thePrompt{2}, 'HorizontalAlignment', 'center'); %theControls(3) = uicontrol('Style', 'text', 'Tag', 'Label', ... % 'String', thePrompt{3}, 'HorizontalAlignment', 'center'); %theControls(4) = uicontrol('Style', 'listbox', 'Tag', 'Source', ... % 'String', theSourceList); %theControls(5) = uicontrol('Style', 'listbox', 'Tag', 'Destination', ... % 'String', theDestinationList); %theControls(6) = uicontrol('Style', 'pushbutton', 'Tag', 'Cancel', ... % 'String', 'Cancel', 'UserData', []); %theControls(7) = uicontrol('Style', 'pushbutton', 'Tag', 'Okay', ... % 'String', 'Okay', 'UserData', theDestinationList); % %p = pwd; %if(p(end) ~= filesep), p(end+1) = filesep; end %f = find(p == filesep); %d = cell(length(f), 1); %k = 0; %for i = 1:length(d) % d{i} = p(k+1:f(i)-1); % k = f(i); %end % %theControls(8) = uicontrol('Style', 'popupmenu', 'Tag', 'Directory', ... % 'String', d, 'Value', length(d), 'UserData', []); % %xx = Inf; % %theLayout = [ ... % 10 10 10 10 10 10 10 10 10 % 20 20 20 30 30 30 30 30 30 % 80 80 80 xx xx xx xx xx xx % 40 40 40 50 50 50 50 50 50 % 40 40 40 50 50 50 50 50 50 % 40 40 40 50 50 50 50 50 50 % 40 40 40 50 50 50 50 50 50 % 40 40 40 50 50 50 50 50 50 % 40 40 40 50 50 50 50 50 50 % 40 40 40 50 50 50 50 50 50 % xx 60 60 xx xx xx 70 70 xx]; % %uilayout(theControls, theLayout, [2 2 96 92]./100) %set(theFrame, 'UserData', theControls) % %theCallback = ['event(get(gcf, ''UserData''), ''' theMode ''')']; %set(theControls(4:8), 'Callback', theCallback) %set(theControls(1:3), 'BackgroundColor', [0.5 1 1]); % %if any(findstr(computer, 'MAC')) % set(theControls(4:5), 'FontName', 'Monaco', ... % 'FontSize', 12, ... % 'FontAngle', 'normal', ... % 'FontWeight', 'normal') %end % %if length(varargin) > 0 % set(theControls(4:5), varargin{:}) %end % %event(self, 'update') % %set(theFigure, 'Visible', 'on') %waitfor(theFigure, 'UserData', []) % %result = get(gco, 'UserData'); % %cd(oldPWD) % %delete(theFigure) % %if nargout < 2 % p = result; %else % p = cell(size(result)); % f = cell(size(result)); % for i = 1:length(result) % [p{i}, f{i}] = fileparts(result{i}); % end %end fclose(fout); disp(' ## Installing: "version.m" (text)') fout = fopen('version.m', 'w'); %function version(self) % %% Version of 31-May-2001 15:27:27. % %helpdlg(help(mfilename), 'listpick') fclose(fout); cd ('..') disp(' ## Installing: "uilayout.m" (text)') fout = fopen('uilayout.m', 'w'); %function theResult = uilayout(theControls, theLayout, ... % thePosition, theMargin) % %% uilayout -- Layout for ui controls. %% uilayout(theControls, theLayout) positions theControls %% according to theLayout, an array whose entries, taken %% in sorted order, define the rectangular extents occupied %% by each control. TheLayout defaults to the shape of %% theControls array. A one-percent margin is %% imposed between controls. To define a layout region %% containing no control, use Inf. %% uilayout(..., thePosition) confines the controls to the %% given normalized position of the figure. This syntax %% is useful for embedding controls within a frame. %% uilayout(....., theMargin) allows the default margin %% of 0.01 (normalized units) between controls to be %% set to another value. %% uilayout (no argument) demonstrates itself. % %% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 18-Apr-1997 08:07:54. %% Updated 27-Jan-2000 23:05:13. % %if nargin < 1, theControls = 'demo'; help(mfilename), end % %if strcmp(theControls, 'demo') % theLayout = [1 2; % 3 4; % 5 Inf; % 5 6; % 5 Inf; % 7 8; % 9 10; % 11 12; % 13 14]; % [m, n] = size(theLayout); % thePos = get(0, 'DefaultUIControlPosition'); % theSize = [n+2 m+2] .* thePos(3:4); % theFigure = figure('Name', 'UILayout', ... % 'NumberTitle', 'off', ... % 'Resize', 'off', ... % 'Units', 'pixels'); % thePos = get(theFigure, 'Position'); % theTop = thePos(2) + thePos(4); % thePos = thePos .* [1 1 0 0] + [0 0 theSize]; % thePos(2) = theTop - (thePos(2) + thePos(4)); % set(theFigure, 'Position', thePos); % theFrame = uicontrol('Style', 'frame', ... % 'Units', 'normalized', ... % 'Position', [0 0 1 1], ... % 'BackgroundColor', [0.5 1 1]); % theStyles = {'checkbox'; 'text'; ... % 'edit'; 'text'; ... % 'listbox'; 'text'; ... % 'popupmenu'; 'text'; ... % 'pushbutton'; 'text'; ... % 'radiobutton'; 'text'; ... % 'text'; 'text'}; % theStrings = {'Anchovies?', '<-- CheckBox --', ... % 'Hello World!', '<-- Edit --', ... % {'Now', 'Is', 'The' 'Time' 'For' 'All' 'Good', ... % 'Men', 'To', 'Come' 'To' 'The' 'Aid' 'Of', ... % 'Their' 'Country'}, ... % '<-- ListBox --', ... % {'Cheetah', 'Leopard', 'Lion', 'Tiger', 'Wildcat'}, ... % '<-- PopupMenu --', ... % 'Okay', '<-- PushButton --', ... % 'Cream?', '<-- RadioButton --', ... % 'UILayout', '<-- Text --'}; % theControls = zeros(size(theStyles)); % for i = 1:length(theStyles) % theControls(i) = uicontrol('Style', theStyles{i}, ... % 'String', theStrings{i}, ... % 'Callback', ... % 'disp(int2str(get(gcbo, ''Value'')))'); % end % set(theControls(1:2:length(theControls)), 'BackGroundColor', [1 1 0.5]) % set(theControls(2:2:length(theControls)), 'BackGroundColor', [0.5 1 1]) % thePosition = [1 1 98 98] ./ 100; % feval(mfilename, theControls, theLayout, thePosition) % set(theFrame, 'UserData', theControls) % theStyles, theLayout, thePosition % if nargout > 0, theResult = theFrame; end % return %end % %if nargin < 2 % theLayout = zeros(size(theControls)); % theLayout(:) = 1:prod(size(theControls)); %end %if nargin < 3, thePosition = [0 0 1 1]; end %if nargin < 4, theMargin = 1/100; end % %a = theLayout(:); %a = a(finite(a)); %a = sort(a); %a(diff(a) == 0) = []; % %b = zeros(size(theLayout)); % %for k = 1:length(a) % b(theLayout == a(k)) = k; %end % %[m, n] = size(theLayout); % %set(theControls, 'Units', 'Normalized') %theMargin = [1 1 -2 -2] * theMargin; %for k = 1:min(length(theControls), length(a)) % [i, j] = find(b == k); % xmin = (min(j) - 1) ./ n; % xmax = max(j) ./ n; % ymin = 1 - max(i) ./ m; % ymax = 1 - (min(i) - 1) ./ m; % thePos = [xmin ymin (xmax-xmin) (ymax-ymin)] + theMargin; %if (1) % thePos = thePos .* thePosition([3 4 3 4]); % thePos(1:2) = thePos(1:2) + thePosition(1:2); %end % set(theControls(k), 'Position', thePos); %end % %if nargout > 0, theResult = theControls; end fclose(fout); cd ('..')