Code covered by the BSD License  

Highlights from
Icons Toolbox

image thumbnail
from Icons Toolbox by Thomas Montagnon
Set of tool for GUI icons/images manipulation

ico_main_gui
function fig_hdl = ico_main_gui
% ICO_MAIN_GUI
%-------------------------------------------------------------------------------
% File name   : ico_main_gui.m
% Generated on: 21-Mar-2007 17:14:15
% Description : Main interface of the Icons Toolbox.
%               You will find here a couple of useful tools for those who create
%               GUIs with icons on pushbuttons.
%-------------------------------------------------------------------------------


% --- FIGURE -------------------------------------
handles.FgIcoMain = figure(	'Tag', 'FgIcoMain', ...
  'Units', 'pixels', ...
  'Position', [520 380 715 420], ...
  'Name', 'Icons Toolbox', ...
  'MenuBar', 'none', ...
  'NumberTitle', 'off', ...
  'Color', [0.878 0.875 0.89]);

% --- PANELS -------------------------------------
handles.PaContent = uipanel(	'Parent', handles.FgIcoMain, ...
  'Tag', 'PaContent', ...
  'Units', 'pixels', ...
  'Position', [155 0 560 420], ...
  'Title', '', ...
  'BorderType', 'none');

handles.uipanel2 = uipanel(	'Parent', handles.FgIcoMain, ...
  'Tag', 'uipanel2', ...
  'Units', 'pixels', ...
  'Position', [10 10 145 400], ...
  'BackgroundColor', [0.937 0.937 0.937], ...
  'Title', '');

% --- STATIC TEXTS -------------------------------------
handles.StGenereBg = uicontrol(	'Parent', handles.uipanel2, ...
  'Tag', 'StGenereBg', ...
  'Style', 'text', ...
  'Units', 'pixels', ...
  'Position', [0 318 142 25], ...
  'FontWeight', 'bold', ...
  'ForegroundColor', [0 0.251 0.502], ...
  'BackgroundColor', [0.824 0.914 1], ...
  'String', '');

handles.StDispBg = uicontrol(	'Parent', handles.uipanel2, ...
  'Tag', 'StDispBg', ...
  'Style', 'text', ...
  'Units', 'pixels', ...
  'Position', [0 345 142 25], ...
  'FontWeight', 'bold', ...
  'ForegroundColor', [0 0.251 0.502], ...
  'BackgroundColor', [0.824 0.914 1], ...
  'String', '');

handles.StRedimBg = uicontrol(	'Parent', handles.uipanel2, ...
  'Tag', 'StRedimBg', ...
  'Style', 'text', ...
  'Units', 'pixels', ...
  'Position', [0 372 142 25], ...
  'FontWeight', 'bold', ...
  'BackgroundColor', [0 0.251 0.502], ...
  'String', '');

handles.StRedim = uicontrol(	'Parent', handles.uipanel2, ...
  'Tag', 'StRedim', ...
  'Style', 'text', ...
  'Units', 'pixels', ...
  'Position', [0 376 142 15], ...
  'FontWeight', 'bold', ...
  'ForegroundColor', [1 1 1], ...
  'BackgroundColor', [0 0.251 0.502], ...
  'String', 'Dimensionning Tool', ...
  'Enable', 'inactive', ...
  'ButtonDownFcn',@StRedim_ButtonDownFcn);

handles.StDisp = uicontrol(	'Parent', handles.uipanel2, ...
  'Tag', 'StDisp', ...
  'Style', 'text', ...
  'Units', 'pixels', ...
  'Position', [0 349 142 17], ...
  'FontWeight', 'bold', ...
  'ForegroundColor', [0 0.251 0.502], ...
  'BackgroundColor', [0.824 0.914 1], ...
  'String', 'Display Tool', ...
  'Enable', 'inactive', ...
  'ButtonDownFcn',@StDisp_ButtonDownFcn);

handles.StGenere = uicontrol(	'Parent', handles.uipanel2, ...
  'Tag', 'StGenere', ...
  'Style', 'text', ...
  'Units', 'pixels', ...
  'Position', [0 322 142 17], ...
  'FontWeight', 'bold', ...
  'ForegroundColor', [0 0.251 0.502], ...
  'BackgroundColor', [0.824 0.914 1], ...
  'String', 'Icons Generation', ...
  'Enable', 'inactive', ...
  'ButtonDownFcn',@StGenere_ButtonDownFcn);

% Save handles structure
guidata(handles.FgIcoMain,handles);

% Init appdata
setappdata(handles.FgIcoMain,'hg2del',struct('f',[]));

% Display Redimensionning Tool by default
StRedim_ButtonDownFcn(handles.StRedim, '');

% Assign function output
fig_hdl = handles.FgIcoMain;


%-------------------------------------------------------------------------------
  function StRedim_ButtonDownFcn(hObject, eventdata)

    % Update Colors of the Menu
    hdRedim  = [handles.StRedim , handles.StRedimBg];
    hdDisp   = [handles.StDisp  , handles.StDispBg];
    hdGenere = [handles.StGenere, handles.StGenereBg];
    set(hdRedim, 'BackgroundColor', [.00 .25 .50], 'ForegroundColor',[1 1 1])
    set(hdDisp,  'BackgroundColor', [.82 .91 1.0], 'ForegroundColor',[.00 .25 .50])
    set(hdGenere,'BackgroundColor', [.82 .91 1.0], 'ForegroundColor',[.00 .25 .50])

    hg2del = cell2mat(struct2cell(getappdata(handles.FgIcoMain,'hg2del')));
    
    delete(hg2del);

    setappdata(handles.FgIcoMain,'hg2del',ico_redim_build(handles.PaContent));

  end


%-------------------------------------------------------------------------------
  function StDisp_ButtonDownFcn(hObject, eventdata)

    % Update Colors of the Menu
    hdRedim  = [handles.StRedim , handles.StRedimBg];
    hdDisp   = [handles.StDisp  , handles.StDispBg];
    hdGenere = [handles.StGenere, handles.StGenereBg];
    set(hdRedim, 'BackgroundColor', [.82 .91 1.0], 'ForegroundColor',[.00 .25 .50])
    set(hdDisp,  'BackgroundColor', [.00 .25 .50], 'ForegroundColor',[1 1 1])
    set(hdGenere,'BackgroundColor', [.82 .91 1.0], 'ForegroundColor',[.00 .25 .50])

    hg2del = cell2mat(struct2cell(getappdata(handles.FgIcoMain,'hg2del')));
    
    delete(hg2del);

    setappdata(handles.FgIcoMain,'hg2del',ico_disp_gui_build(handles.PaContent));

  end


%-------------------------------------------------------------------------------
  function StGenere_ButtonDownFcn(hObject, eventdata)

    % Update Colors of the Menu
    hdRedim  = [handles.StRedim , handles.StRedimBg];
    hdDisp   = [handles.StDisp  , handles.StDispBg];
    hdGenere = [handles.StGenere, handles.StGenereBg];
    set(hdRedim, 'BackgroundColor', [.82 .91 1.0], 'ForegroundColor',[.00 .25 .50])
    set(hdDisp,  'BackgroundColor', [.82 .91 1.0], 'ForegroundColor',[.00 .25 .50])
    set(hdGenere,'BackgroundColor', [.00 .25 .50], 'ForegroundColor',[1 1 1])

    hg2del = cell2mat(struct2cell(getappdata(handles.FgIcoMain,'hg2del')));
    
    delete(hg2del);

    setappdata(handles.FgIcoMain,'hg2del',ico_genere_gui_build(handles.PaContent));

  end

end

Contact us at files@mathworks.com