MAXIMIZEFIGS Maximize figure(s) window size CALL: maximizefigs(hfigs, taskbar_position) hfigs = handle(s) of figure(s) you wish to resize (Default = 'all') taskbar_position = Position of the Windows taskbar Allowed values: 'bottom', 'left' (Default = 'bottom') Note: Inputs may be given in any order. Examples: % Windows taskbar at bottom of screen maximizefigs('all') %Maximizes all unhidden figures maximizefigs %same as maxwindow('all') maximizefigs(gcf) %Maximizes the current figure maximizefigs(3) %Maximizes figure 3 maximizefigs([2 4]) %Maximizes figures 2 and 4 maximizefigs(gcf,'left') %Windows taskbar at left of screen %or alternatively maximizefigs 2 4 See also restorefigs
Convert to double precision. | |
Find objects with specified property values. | |
Get object properties. | |
True for numeric arrays. | |
Convert string to lowercase. | |
Set object properties. | |
Compare strings ignoring case. |
001 function maximizefigs(varargin) 002 %MAXIMIZEFIGS Maximize figure(s) window size 003 % 004 % CALL: maximizefigs(hfigs, taskbar_position) 005 % 006 % hfigs = handle(s) of figure(s) you wish to resize (Default = 'all') 007 % taskbar_position = Position of the Windows taskbar 008 % Allowed values: 'bottom', 'left' 009 % (Default = 'bottom') 010 % 011 % Note: Inputs may be given in any order. 012 % 013 %Examples: % Windows taskbar at bottom of screen 014 % 015 % maximizefigs('all') %Maximizes all unhidden figures 016 % maximizefigs %same as maxwindow('all') 017 % maximizefigs(gcf) %Maximizes the current figure 018 % maximizefigs(3) %Maximizes figure 3 019 % maximizefigs([2 4]) %Maximizes figures 2 and 4 020 % maximizefigs(gcf,'left') %Windows taskbar at left of screen 021 % %or alternatively 022 % maximizefigs 2 4 023 % 024 % See also restorefigs 025 026 027 % revised pab 05.03.2003 028 % renamed from maxwindow to maximizefigs 029 % changed default from gcf to 'all' 030 031 %Author: Denis Gilbert, Ph.D., physical oceanography 032 %Maurice Lamontagne Institute, Dept. of Fisheries and Oceans Canada 033 %email: gilbertd@dfo-mpo.gc.ca Web: http://www.qc.dfo-mpo.gc.ca/iml/ 034 %October 1998; Last revision: 18-Feb-2002 035 036 taskbar_position = 'bottom'; % default 037 038 figs = []; 039 for ix=1:nargin 040 currArg = varargin{ix}; 041 if isnumeric(currArg) 042 figs = [figs,currArg]; 043 else 044 tmp = double(currArg); 045 try, 046 if any( double('0')<= tmp & tmp<= double('9') ) | strcmpi(currArg,'gcf') 047 figs = [figs, eval(currArg)]; 048 else 049 switch lower(currArg(1)) 050 case 'b', taskbar_position = 'bottom'; 051 case 'l', taskbar_position = 'left'; 052 end 053 end 054 end 055 end 056 end 057 if isempty(figs) 058 % Find all figure handles, sort them and count them. 059 %figs = get(0,'children'); 060 figs = findobj('Type', 'figure'); 061 figs = sort(figs); 062 end 063 064 if isempty(figs) 065 disp('No open figures or no figures specified.'); 066 return 067 end 068 069 070 rootUnits = get(0, 'Units'); 071 set(0, 'Units', 'pixels'); % Set root units. 072 screensize=get(0,'screensize'); 073 074 switch lower(taskbar_position) 075 %Other cases could easily be added for other positions of the Windows 076 %taskbar or in cases where one also chooses to display the Microsoft 077 %Office taskbar 078 079 case 'bottom' 080 offset1 = 34; 081 offset2 = 111; 082 newPosition =[1 offset1 screensize(3) screensize(4)-offset2]; 083 case 'left' 084 offset1 = 84; 085 offset2 = 78; 086 newPosition = [1+offset1 1 screensize(3)-offset1 screensize(4)-offset2]; 087 end 088 set(figs,'units','pixels','Position',newPosition ) 089 set(0, 'Units', rootUnits); % reset root units 090 return
Comments or corrections to the WAFO group