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

Contents 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.3 - (show annotations) (download)
Mon Mar 14 15:56:49 2016 UTC (9 years, 4 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.2: +34 -27 lines
- diags_display.m: set addToTex=1 but fileTex='' to go through write2tex
  but simply to add figure captions (when using diags_display directly).
- write2tex.m: add call to gcmfaces_caption (also when fileTex='') and
  save figures (atfter print to eps and activation of caption).
- gcmfaces_caption.m: output captionHandle; include 'Children' in
  visibility switch; rename temporary variables as gfCapTmp and gfCapTmppp;
  revise uipanel aspect and position.

1 function [captionHandle]=gcmfaces_caption(myCaption);
2 % [captionHandle]=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 %
6 % Notes:
7 % 1) the added menu functionalities only support one
8 % caption per figure.
9 % 2) the added menu functionalities operate with two
10 % temporary variables (gfCapTmp, gfCapTmppp) that get
11 % deleted after each callback.
12
13 gcmfaces_global;
14
15 %the on/off button callback in text form
16 capOnOff=[...
17 'gfCapTmp.h=findall(gcf,''type'',''uipanel'');' ...
18 'gfCapTmp.nh=length(gfCapTmp.h);' ...
19 'gfCapTmp.captionHandle=[];' ...
20 'for gfCapTmppp=1:length(gfCapTmp.h);' ...
21 ' gfCapTmp.tag=get(gfCapTmp.h(gfCapTmppp),''Tag'');' ...
22 ' if ~isempty(strfind(gfCapTmp.tag,''gfCap''));' ...
23 ' gfCapTmp.captionHandle=gfCapTmp.h(gfCapTmppp);' ...
24 ' end;' ...
25 'end;' ...
26 'gfCapTmp.tmp1=get(gfCapTmp.captionHandle,''Visible'');' ...
27 'if strcmp(gfCapTmp.tmp1,''on'');' ...
28 ' gfCapTmp.tmp1=''off'';' ...
29 'else;' ...
30 ' gfCapTmp.tmp1=''on''; ' ...
31 'end;' ...
32 'set(gfCapTmp.captionHandle,''Visible'',gfCapTmp.tmp1);' ...
33 'set(get(gfCapTmp.captionHandle,''Children''),''Visible'',gfCapTmp.tmp1);'...
34 'clear gfCapTmp gfCapTmppp;' ...
35 ];
36
37 capHandle=[...
38 'gfCapTmp.h=findall(gcf,''type'',''uipanel'');' ...
39 'gfCapTmp.nh=length(gfCapTmp.h);' ...
40 'captionHandle=[];' ...
41 'for gfCapTmppp=1:length(gfCapTmp.h);' ...
42 ' gfCapTmp.tag=get(gfCapTmp.h(gfCapTmppp),''Tag'');' ...
43 ' if ~isempty(strfind(gfCapTmp.tag,''gfCap''));' ...
44 ' captionHandle=gfCapTmp.h(gfCapTmppp);' ...
45 ' end;' ...
46 'end;' ...
47 'clear gfCapTmp gfCapTmppp;' ...
48 'evalin(''base'',''captionHandle'');' ...
49 ];
50
51 %use call back for example:
52 if isempty(who('myCaption'));
53 myCaption='';
54 %use call back for example:
55 %myCaption=['example: ' capOnOff];
56 end;
57
58 %create and tag panel:
59 %hp = uipanel('Title','Caption','FontSize',12,...
60 hp = uipanel('FontSize',12,...
61 'BackgroundColor','white',...
62 'Position',[.2 0.05 .6 .1]);
63 set(hp,'Tag','gfCap');
64
65 %add the caption text in panel:
66 txt = uicontrol('Parent',hp,'Style', 'edit',...
67 'BackgroundColor','white','FontSize',12,...
68 'Max',2,'Min',0, 'String', ['Caption: ' myCaption]);
69 set(txt,'units','normalized');
70 set(txt,'Position',[0.05 0.1 0.9 0.8])
71
72 %add menu button:
73 mn=uimenu('Label','Caption');
74 uimenu(mn,'Label','Hide/Show','Callback',capOnOff);
75 uimenu(mn,'Label','captionHandle','Callback',capHandle);
76
77 %output caption handle:
78 captionHandle=hp;
79

  ViewVC Help
Powered by ViewVC 1.1.22