⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resizefcn52fix.m

📁 很多matlab的源代码
💻 M
字号:
function resizefcn52fix(hFig,oldPos,newPos)%RESIZEFCN52FIX Fixes normalized fontunits bug in Matlab 5.2%   RESIZEFCN52FIX(hFig,oldPos,newPos) fixes the normalized fontunits bug in Matlab 5.2.%   In that version of Matlab (and earlier versions) setting the 'fontunits' of UICONTROLS%   to 'normalized' does not work.  This function, which should be called from the 'ResizeFcn'%   callback of a figure, correctly changes the font size of UIControls according to the change%   in the figure size.%%   hFig is the handle of the figure being resized.  oldPos and newPos correspond to the position%   vectors of the figure before and after resizing.%%   Example:%%      function figresizetest(action)%      % Run this function without any arguments and then resize the figure.%      if nargin==0%         figure('ResizeFcn','figresizetest ResizeFcn');%         Pos = get(gcf,'Pos');%         set(gcf,'UserData',Pos);%      else%         Pos = get(gcbo,'UserData');%         Pos = resizefcn52fix(gcbo,Pos,get(gcbo,'Pos'));%         set(gcbo,'UserData',Pos);%      end%%   As normalized fontunits should work, this function changes the fontsize depending on the height%   change of the figure.  Width changes do not affect the fontsize.%%   See also CONFIGRESIZE, RESIZEFCN% Jordan Rosenthal, 22-Jun-99hUIControls = findall(hFig,'type','uicontrol');         % Get handles to all UIControlsOldFontUnits = get(hUIControls,'FontUnits');            % Save the current font unitsset(hUIControls,'FontUnits','Pixels');                  % Set all font units to pixelsrelHeightChange = newPos(4)/oldPos(4);                  % Calculate relative height changefor i = 1:length(hUIControls)    set(hUIControls(i),'FontSize',relHeightChange*get(hUIControls(i),'FontSize'));  % Change font sizeend%  Restore previous font unitsif iscell(OldFontUnits)    set(hUIControls,{'FontUnits'},OldFontUnits);else    set(hUIControls,'FontUnits',OldFontUnits);end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -