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

📄 fm_choice.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
字号:
function fig = fm_choice(varargin)
% FM_CHOICE open dialog box and wait for input
%
% FM_CHOICE(TEXT)
% FM_CHOICE(TEXT,MODE)
%       TEXT = text to be displayed
%       MODE = message mode
%              1 - ask for choice (default)
%              2 - warning
%              3 - callbacks
%
% (user's preference is stored in "Settings.ok")
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Version:   1.0.0
%
%E-mail:    fmilano@thunderbox.uwaterloo.ca
%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano
%
% Copyright (C) 2002-2006 Federico Milano

global Path Theme Settings

sizes = get(0,'ScreenSize');
a = 1/3*sizes(4)/sizes(3);

text = varargin{1};
mode = 1;
if nargin == 2,
  mode = varargin{2};
end

if mode == 3
  switch text

   case 'keypress'
    key = get(gcbf,'CurrentCharacter');
    if double(key) == 13
      Settings.ok = 1;
    elseif double(key) == 27
      Settings.ok = 0;
    end,
    close(gcbf)
    return

  end
end

h0 = figure('Color',Theme.color02, ...
            'Units', 'normalized', ...
            'Colormap',[], ...
            'KeyPressFcn','fm_choice(''keypress'',3)', ...
            'MenuBar','none', ...
            'Name','PSAT Message', ...
            'NumberTitle','off', ...
            'PaperPosition',[18 180 576 432], ...
            'PaperType','A4', ...
            'PaperUnits','points', ...
            'Position',sizefig(0.4,0.13333), ...
            'RendererMode','manual', ...
            'Resize','on', ...
            'ShareColors', 'on', ...
            'ToolBar','none');
fm_set colormap

h1 = axes('Parent',h0, ...
          'CameraUpVector',[0 1 0], ...
          'CameraUpVectorMode','manual', ...
          'Box', 'on', ...
          'Color',Theme.color04, ...
          'ColorOrder',Settings.color, ...
          'Layer','top', ...
          'Position',[0.0 0.0 a 1], ...
          'Tag','Axes1', ...
          'XColor',Theme.color02, ...
          'XLim',[0.5 206.5], ...
          'XLimMode','manual', ...
          'XTick',[], ...
          'YColor',Theme.color02, ...
          'YDir','reverse', ...
          'YLim',[0.5 210.5], ...
          'YLimMode','manual', ...
          'YTick',[], ...
          'ZColor',[0 0 0]);
warn_image = fm_mat('choice_warn');
try
  warn_image = imresize(warn_image,[206 210],'bilinear');
catch
  % imresize not found...
end
h2 = image('Parent',h1, ...
           'CData',warn_image, ...
           'Tag','Axes1Image1', ...
           'XData',[1 206], ...
           'YData',[1 210]);

if mode == 1

  h1 = uicontrol('Parent',h0, ...
                 'CData', fm_mat('choice_yes'), ...
                 'Units', 'normalized', ...
                 'BackgroundColor',Theme.color02, ...
                 'Callback','Settings.ok = 1; close(gcf);', ...
                 'Position',[(a+0.075) 0.1 a 0.3], ...
                 'Tag','Pushbutton1');
  h1 = uicontrol('Parent',h0, ...
                 'CData', fm_mat('choice_no'), ...
                 'Units', 'normalized', ...
                 'BackgroundColor',Theme.color02, ...
                 'Callback','Settings.ok = 0; close(gcf);', ...
                 'Position',[(0.925-a) 0.1 a 0.3], ...
                 'Tag','Pushbutton1');

elseif mode == 2

  fm_disp(text)
  h1 = uicontrol( ...
      'Parent',h0, ...
      'Units', 'normalized', ...
      'BackgroundColor',Theme.color02, ...
      'Callback','Settings.ok = 1; close(gcf);', ...
      'Position',[(1.5*a+0.1125) 0.1 a 0.3], ...
      'String', 'OK', ...
      'Tag','Pushbutton1');
  
end

FontSize = 10;
if ~isunix
  FontSize = 8;
end

h1 = uicontrol('Parent',h0, ...
               'Units', 'normalized', ...
               'BackgroundColor',Theme.color02, ...
               'ForegroundColor',Theme.color05, ...
               'FontName', 'helvetica', ...
               'FontSize', FontSize, ...
               'Position',[a+0.05 0.5 (0.9-a) 0.3], ...
               'String', text, ...
               'Style','text', ...
               'Tag','StaticText1');

if nargout > 0, fig = h0; end

⌨️ 快捷键说明

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