source: trunk/src/read_GUI.m @ 295

Last change on this file since 295 was 295, checked in by sommeria, 12 years ago

plotting functions debugged and checked after the introduction of uipanels

File size: 2.5 KB
Line 
1% --------------------------------------------------------------------
2% --- read a GUI with handle 'handle' producing a structure 'struct'
3function struct=read_GUI(handle)
4struct=[];%default
5hchild=get(handle,'children');
6for ichild=1:numel(hchild)
7    if strcmp(get(hchild(ichild),'Visible'),'on')
8        object_type=get(hchild(ichild),'Type');
9        tag=get(hchild(ichild),'tag');
10        switch object_type
11            case 'uipanel'
12                eval(['struct.' tag '=read_GUI(hchild(ichild));'])
13            case 'uicontrol'
14                object_style=get(hchild(ichild),'Style');
15                check_input=1;%default
16                switch object_style
17                    case {'checkbox','pushbutton','radiobutton','togglebutton'}
18                        input=get(hchild(ichild),'Value');
19                    case 'edit'
20                        separator=regexp(tag,'_');
21                        if isempty(separator)
22                            input=get(hchild(ichild),'Value');
23                        else
24                            switch(tag(1:separator))
25                                case 'num_'
26                                    input=str2double(get(hchild(ichild),'String'));
27                                    tag=tag(separator+1:end);
28                                    %deal with undefined input: retrieve the default value stored as UserData
29                                    if isnan(input)
30                                        input=get(hchild(ichild),'UserData');
31                                        set(hchild(ichild),'String',num2str(input))
32                                    end
33                                case 'txt_'
34                                    input=get(hchild(ichild),'String');
35                                    tag=tag(separator+1:end);
36                                otherwise
37                                    input=get(hchild(ichild),'String');
38                            end
39                        end
40
41                        %                         key=tag(7:end);
42                    case{'Listbox','popupmenu'}
43                        listinput=get(hchild(ichild),'String');
44                        value=get(hchild(ichild),'Value');
45                        input=listinput(value);       
46                    otherwise
47                        check_input=0;
48                end
49                if check_input
50                    struct.(tag)=input;
51                  %  eval(['struct.' tag '=input;'])
52                end
53        end
54    end
55end
Note: See TracBrowser for help on using the repository browser.