Ignore:
Timestamp:
Mar 12, 2013, 12:52:13 PM (11 years ago)
Author:
sommeria
Message:

clean the transform field functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/msgbox_uvmat.m

    r507 r581  
    77%INPUT:
    88% title: string indicating the type of message box:
    9 %          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N', default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).
     9%          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N','INPUT_MENU' default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).
    1010%          if title='INPUT_TXT', input data is asked in an edit box
    1111%          if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains  opened until a button 'OK' is pressed
     
    3737% End initialization code - DO NOT EDIT
    3838
     39%------------------------------------------------------------------------
    3940% --- Executes just before msgbox_uvmat is made visible.
    4041function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display_str,default_answer,Position)
     42%------------------------------------------------------------------------
    4143% This function has no output args, see OutputFcn.
    4244
     
    8991            testinputstring=1;
    9092            testCancel=1; %no cancel button
     93        case 'INPUT_MENU'
     94            testinputstring=2;
     95            testCancel=1; %no cancel button
    9196        otherwise
    9297          %  testinputstring=1;
     
    98103    set(handles.text1, 'String', display_str);
    99104end
    100 % if testinputstring
    101 %     set(handles.edit_box, 'Visible', 'on');
    102 % else
    103 %     set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
    104 % end
    105 if testinputstring
    106     % set(handles.figure1,'Position',[40,80,20*length(default_answer),50])
     105
     106if testinputstring==1
    107107    set(handles.edit_box, 'Visible', 'on');
    108108    if ~exist('default_answer','var');
     
    111111    set(handles.edit_box, 'String', default_answer);
    112112    if exist('Position','var')
    113     if iscell(default_answer)
    114         widthstring=max(max(cellfun('length',default_answer)),length(display_str));
    115         heightstring=size(default_answer,1);%nbre of expected lines
    116         set(handles.edit_box,'Max',2);
    117     else
    118         widthstring=max(length(default_answer),length(display_str));
    119         heightstring=1;
    120     end
    121     widthstring=max(widthstring,length(title)+20);
    122     boxsize=[10*widthstring 20*heightstring];%size of the display edit box
    123     set(handles.edit_box,'Units','pixels')
    124     set(handles.edit_box,'FontUnits','pixels')
    125     set(handles.edit_box,'FontSize',12) 
    126    set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)])
    127    FigPos(3)=10+boxsize(1);
    128    FigPos(4)=56+boxsize(2);
    129    FigPos(2)=Position(2)-FigPos(4)-25;
    130    set(handles.figure1,'Position',FigPos)
    131     end
    132 %     set(handles.figure1,'Position',[40,40,20*length(default_answer),50])
     113        if iscell(default_answer)
     114            widthstring=max(max(cellfun('length',default_answer)),length(display_str));
     115            heightstring=size(default_answer,1);%nbre of expected lines
     116            set(handles.edit_box,'Max',2);
     117        else
     118            widthstring=max(length(default_answer),length(display_str));
     119            heightstring=1;
     120        end
     121        widthstring=max(widthstring,length(title)+20);
     122        boxsize=[10*widthstring 20*heightstring];%size of the display edit box
     123        set(handles.edit_box,'Units','pixels')
     124        set(handles.edit_box,'FontUnits','pixels')
     125        set(handles.edit_box,'FontSize',12)
     126        set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)])
     127        FigPos(3)=10+boxsize(1);
     128        FigPos(4)=56+boxsize(2);
     129        FigPos(2)=Position(2)-FigPos(4)-25;
     130        set(handles.figure1,'Position',FigPos)
     131    end
     132elseif testinputstring==2
     133    set(handles.edit_box,'style','listbox')
     134    set(handles.edit_box, 'Visible', 'on');
     135    set(handles.edit_box,'String', default_answer)
    133136else
    134137    set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
     
    189192uiwait(handles.figure1);
    190193
    191 
     194%------------------------------------------------------------------------
    192195% --- Outputs from this function are returned to the command line.
    193196function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles)
     197%------------------------------------------------------------------------
    194198
    195199% Get default command line output from handles structure
     
    200204        varargout{1}='No';
    201205    else
     206        if strcmp(get(handles.edit_box,'Style'),'listbox')
     207             varargout{1}=get(handles.edit_box,'Value');
     208        else
    202209        varargout{1}=get(handles.edit_box,'String');
    203         if isempty(varargout{1}) || isequal(varargout{1},'')
     210        end
     211        if isempty(varargout{1})
    204212            varargout{1}='Yes';
    205213        end
     
    208216end
    209217 delete(handles.figure1);
    210  
     218
     219%------------------------------------------------------------------------
    211220% --- Executes on button press in OK.
    212221function OK_Callback(hObject, eventdata, handles)
     222%------------------------------------------------------------------------
    213223handles.output = get(hObject,'String');
    214224guidata(hObject, handles);% Update handles structure
    215225uiresume(handles.figure1);
    216226
     227%------------------------------------------------------------------------
    217228% --- Executes on button press in No.
    218229function No_Callback(hObject, eventdata, handles)
     230%------------------------------------------------------------------------
    219231handles.output='No';
    220232guidata(hObject, handles);
    221233uiresume(handles.figure1);
    222234
     235%------------------------------------------------------------------------
    223236% --- Executes on button press in Cancel.
    224237function Cancel_Callback(hObject, eventdata, handles)
     238%------------------------------------------------------------------------
    225239handles.output = get(hObject,'String');
    226240%handles.output = 'Cancel'
     
    230244uiresume(handles.figure1);
    231245
    232 
     246%------------------------------------------------------------------------
    233247% --- Executes when user attempts to close figure1.
    234248function figure1_CloseRequestFcn(hObject, eventdata, handles)
     249%------------------------------------------------------------------------
    235250if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
    236251    % The GUI is still in UIWAIT, us UIRESUME
     
    241256end
    242257
     258%------------------------------------------------------------------------
    243259% --- Executes on key press over figure1 with no controls selected.
    244260function figure1_KeyPressFcn(hObject, eventdata, handles)
     261%------------------------------------------------------------------------
    245262% Check for "enter" or "escape"
    246263if isequal(get(hObject,'CurrentKey'),'escape')
Note: See TracChangeset for help on using the changeset viewer.