/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_misc/gcmfaces_caption.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_misc/gcmfaces_caption.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Sun Mar 13 15:07:51 2016 UTC (9 years, 4 months ago) by gforget
Branch: MAIN
- gcmfaces_caption (new) adds an editable figure caption.

1 gforget 1.1 function []=gcmfaces_caption(myCaption);
2     % GCMFACES_CAPTION(myCaption) adds an editable
3     % caption to the current figure and menu buttons
4     % to show or hide it, or return its handle.
5     % Assumption: only one caption per figure.
6    
7     gcmfaces_global;
8    
9     %the on/off button callback in text form
10     capOnOff=[...
11     'h=findall(gcf,''type'',''uipanel'');' ...
12     'nh=length(h);' ...
13     'captionHandle=[];' ...
14     'for pp=1:length(h);' ...
15     ' tag=get(h(pp),''Tag'');' ...
16     ' if ~isempty(strfind(tag,''gfCap''));' ...
17     ' captionHandle=h(pp);' ...
18     ' end;' ...
19     'end;' ...
20     'tmp1=get(captionHandle,''Visible'');' ...
21     'if strcmp(tmp1,''on'');' ...
22     ' tmp1=''off'';' ...
23     'else;' ...
24     ' tmp1=''on''; ' ...
25     'end;' ...
26     'set(captionHandle,''Visible'',tmp1);' ...
27     ];
28    
29     capHandle=[...
30     'h=findall(gcf,''type'',''uipanel'');' ...
31     'nh=length(h);' ...
32     'captionHandle=[];' ...
33     'for pp=1:length(h);' ...
34     ' tag=get(h(pp),''Tag'');' ...
35     ' if ~isempty(strfind(tag,''gfCap''));' ...
36     ' captionHandle=h(pp);' ...
37     ' end;' ...
38     'end;' ...
39     'evalin(''base'',''captionHandle'');' ...
40     ];
41    
42     %use call back for example:
43     if isempty(who('myCaption'));
44     myCaption='';
45     %use call back for example:
46     %myCaption=['example: ' capOnOff];
47     end;
48    
49     %create and tag panel:
50     hp = uipanel('Title','Caption','FontSize',12,...
51     'BackgroundColor','white',...
52     'Position',[.05 0.85 .9 .1]);
53     set(hp,'Tag','gfCap');
54    
55     %add the caption text in panel:
56     txt = uicontrol('Parent',hp,'Style', 'edit','Max',2,'Min',0, 'String', myCaption);
57     set(txt,'FontSize',14,'units','normalized');
58     set(txt,'Position',[0.05 0.1 0.9 0.8])
59    
60     %add menu button:
61     mn=uimenu('Label','Caption');
62     uimenu(mn,'Label','Hide/Show','Callback',capOnOff);
63     uimenu(mn,'Label','captionHandle','Callback',capHandle);
64    

  ViewVC Help
Powered by ViewVC 1.1.22