Ignore:
Timestamp:
Nov 19, 2011, 10:40:00 AM (12 years ago)
Author:
sommeria
Message:

further cleaning after new GUI civ. The function mouse_alt_gui allows to zoom out a uicontrol and edit it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_alt_gui.m

    r252 r287  
    11%'mouse_alt_gui': function activated when the right mouse button is pressed on a GUI (callback for 'WindowButtonDownFcn')
    2 % it displays a msg box with zoom of the current uicontrol display
     2% it displays an editable msg box with zoom of the current uicontrol display
    33%------------------------------------------------------------------------
    44function mouse_alt_gui(hObject,eventdata,handles)
     
    66if isequal(get(hObject,'SelectionType'),'alt')
    77    set(hObject,'Units','pixels')
    8     series_pos=get(hObject,'Position');%position of the current GUI  (in pixels), as selected by the mouse
     8    GUI_pos=get(hObject,'Position');%position on the screen  (in pixels)  of the GUI selected by the mouse
    99    set(hObject,'Units','normalized')
    10     xy_fig=get(hObject,'CurrentPoint');% current point of the current GUI 
    11     hchild=get(hObject,'Children');%handles of all objects in the current GUI
     10    xy_fig=get(hObject,'CurrentPoint');% current point of the current GUI
     11    hchildren=get(hObject,'Children');%handles of all objects in the current GUI
    1212    %% loop on all the objects in the current figure (selected by the last mouse click)
    13     for ichild=1:length(hchild)
    14         obj_pos=get(hchild(ichild),'Position');%position of the object       
    15         if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);         
    16             htype=get(hchild(ichild),'Type');%type of object child of the current figure
    17             %if the mouse is over a uicontrol, look at the data
    18             if isequal(htype,'uicontrol') && isequal(get(hchild(ichild),'Visible'),'on')
    19                 msg_pos(1:2)=series_pos(1:2)+obj_pos(1:2).*series_pos(3:4);
    20                 msgbox_uvmat(['uicontrol: ' get(hchild(ichild),'Tag')],'',get(hchild(ichild),'String'),msg_pos)
    21                 break
     13    for ichild=1:length(hchildren)
     14        hchild=hchildren(ichild);
     15        obj_pos=get(hchild,'Position');%position of the object
     16        if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
     17            htype=get(hchild,'Type');%type of object child of the current figure
     18            switch htype
     19                case 'uicontrol'
     20                    %if the mouse is over a uicontrol, look at the data
     21                    if strcmp(get(hchild,'Visible'),'on')
     22                        msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
     23                        output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos);
     24                        break
     25                    end
     26                case 'uipanel'
     27                    panel_pos=obj_pos;%position of the panel
     28                    hhchildren=get(hchild,'Children');%handles of all objects in the current GUI
     29                    %% loop on all the objects in the current figure (selected by the last mouse click)
     30                    for iichild=1:length(hhchildren)
     31                        hchild=hhchildren(iichild);
     32                        rel_pos=get(hchild,'Position');%position of the object relative to the uipanel
     33                        obj_pos(1:2)=panel_pos(1:2)+rel_pos(1:2).*panel_pos(3:4);
     34                        obj_pos(3:4)=panel_pos(3:4).*rel_pos(3:4);
     35                        if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
     36                            htype=get(hchild,'Type');%type of object child of the current figure
     37                            %if the mouse is over a uicontrol, look at the data
     38                            if strcmp(htype,'uicontrol') && strcmp(get(hchild,'Visible'),'on')
     39                                msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
     40                                output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos);
     41                                break
     42                            end
     43                        end
     44                    end
    2245            end
     46           
    2347        end
    2448    end
    2549    set(hObject,'Units','pixels')
     50    set(hchild,'String',output_str)
    2651end
Note: See TracChangeset for help on using the changeset viewer.