1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Description of makeurl</title> |
---|
6 | <meta name="keywords" content="makeurl"> |
---|
7 | <meta name="description" content="MAKEURL Make a URL from a uicontrol of style text."> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
10 | <meta name="robots" content="index, follow"> |
---|
11 | <link type="text/css" rel="stylesheet" href="../../m2html.css"> |
---|
12 | </head> |
---|
13 | <body> |
---|
14 | <a name="_top"></a> |
---|
15 | <div><a href="../../index.html">Home</a> > <a href="#">applications</a> > <a href="index.html">common</a> > makeurl.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for applications/common <img alt=">" border="0" src="../../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>makeurl |
---|
21 | </h1> |
---|
22 | |
---|
23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
24 | <div class="box"><strong>MAKEURL Make a URL from a uicontrol of style text.</strong></div> |
---|
25 | |
---|
26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
27 | <div class="box"><strong>function makeurl(h,url,varargin) </strong></div> |
---|
28 | |
---|
29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
30 | <div class="fragment"><pre class="comment">MAKEURL Make a URL from a uicontrol of style text. |
---|
31 | MAKEURL(h,url) adjusts the properties of the text style UICONTROL |
---|
32 | object to make it act like a typical URL hyperlink. The hyperlink's |
---|
33 | target is given by the string url. |
---|
34 | |
---|
35 | MAKEURL(...,'ForeGroundColor',C1,'ClickedColor',C2) will set the |
---|
36 | unclicked text color to C1 and the clicked text color to C2 where |
---|
37 | C1 and C2 are valid colorspecs. The default values are C1 = 'b' |
---|
38 | and C2 = 'm'. |
---|
39 | |
---|
40 | Ex. |
---|
41 | |
---|
42 | h = uicontrol('style','text','string','MathWorks'); |
---|
43 | makeurl(h,'http://www.mathworks.com');</pre></div> |
---|
44 | |
---|
45 | <!-- crossreference --> |
---|
46 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
47 | This function calls: |
---|
48 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
49 | </ul> |
---|
50 | This function is called by: |
---|
51 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
52 | </ul> |
---|
53 | <!-- crossreference --> |
---|
54 | |
---|
55 | |
---|
56 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
57 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function makeurl(h,url,varargin)</a> |
---|
58 | 0002 <span class="comment">%MAKEURL Make a URL from a uicontrol of style text.</span> |
---|
59 | 0003 <span class="comment">% MAKEURL(h,url) adjusts the properties of the text style UICONTROL</span> |
---|
60 | 0004 <span class="comment">% object to make it act like a typical URL hyperlink. The hyperlink's</span> |
---|
61 | 0005 <span class="comment">% target is given by the string url.</span> |
---|
62 | 0006 <span class="comment">%</span> |
---|
63 | 0007 <span class="comment">% MAKEURL(...,'ForeGroundColor',C1,'ClickedColor',C2) will set the</span> |
---|
64 | 0008 <span class="comment">% unclicked text color to C1 and the clicked text color to C2 where</span> |
---|
65 | 0009 <span class="comment">% C1 and C2 are valid colorspecs. The default values are C1 = 'b'</span> |
---|
66 | 0010 <span class="comment">% and C2 = 'm'.</span> |
---|
67 | 0011 <span class="comment">%</span> |
---|
68 | 0012 <span class="comment">% Ex.</span> |
---|
69 | 0013 <span class="comment">%</span> |
---|
70 | 0014 <span class="comment">% h = uicontrol('style','text','string','MathWorks');</span> |
---|
71 | 0015 <span class="comment">% makeurl(h,'http://www.mathworks.com');</span> |
---|
72 | 0016 |
---|
73 | 0017 <span class="comment">% Jordan Rosenthal, jr@ll.mit.edu</span> |
---|
74 | 0018 <span class="comment">% Initial Version, 08-Dec-1999</span> |
---|
75 | 0019 <span class="comment">% Rev., 18-Dec-2001 Added -browser switch and changed email contact.</span> |
---|
76 | 0020 |
---|
77 | 0021 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
78 | 0022 <span class="comment">% Default Parameters</span> |
---|
79 | 0023 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
80 | 0024 FOREGROUNDCOLOR = <span class="string">'b'</span>; |
---|
81 | 0025 CLICKEDCOLOR = <span class="string">'m'</span>; |
---|
82 | 0026 |
---|
83 | 0027 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
84 | 0028 <span class="comment">% Parse Inputs</span> |
---|
85 | 0029 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
86 | 0030 <span class="keyword">if</span> nargin < 2, error(<span class="string">'Not enough input arguments.'</span>); <span class="keyword">end</span> |
---|
87 | 0031 <span class="keyword">if</span> ~strcmp(get(h,<span class="string">'style'</span>),<span class="string">'text'</span>), error(<span class="string">'The UICONTROL h must be of style text.'</span>); <span class="keyword">end</span> |
---|
88 | 0032 <span class="keyword">if</span> exist(<span class="string">'varargin'</span>,<span class="string">'var'</span>) |
---|
89 | 0033 L = length(varargin); |
---|
90 | 0034 <span class="keyword">if</span> rem(L,2) ~= 0, error(<span class="string">'Parameters/Values must come in pairs.'</span>); <span class="keyword">end</span> |
---|
91 | 0035 <span class="keyword">for</span> i = 1:2:L |
---|
92 | 0036 <span class="keyword">switch</span> lower(varargin{i}(1)) |
---|
93 | 0037 <span class="keyword">case</span> <span class="string">'f'</span>, FOREGROUNDCOLOR = varargin{i+1}; |
---|
94 | 0038 <span class="keyword">case</span> <span class="string">'c'</span>, CLICKEDCOLOR = varargin{i+1}; |
---|
95 | 0039 <span class="keyword">end</span> |
---|
96 | 0040 <span class="keyword">end</span> |
---|
97 | 0041 <span class="keyword">end</span> |
---|
98 | 0042 <span class="comment">%--- Add quotes around the color if given as a character ---%</span> |
---|
99 | 0043 <span class="keyword">if</span> ischar(CLICKEDCOLOR), CLICKEDCOLOR = [<span class="string">''''</span> CLICKEDCOLOR <span class="string">''''</span>]; <span class="keyword">end</span> |
---|
100 | 0044 |
---|
101 | 0045 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
102 | 0046 <span class="comment">% Swicth units and get the pertinent parameters</span> |
---|
103 | 0047 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
104 | 0048 OldUnits = get(h,<span class="string">'Units'</span>); set(h,<span class="string">'Units'</span>,<span class="string">'pixels'</span>); |
---|
105 | 0049 Ext = get(h,<span class="string">'Extent'</span>); |
---|
106 | 0050 Pos = get(h,<span class="string">'Pos'</span>); |
---|
107 | 0051 Horiz = get(h,<span class="string">'HorizontalAlignment'</span>); |
---|
108 | 0052 |
---|
109 | 0053 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
110 | 0054 <span class="comment">% Add an underline by creating a 1 pixel high frame</span> |
---|
111 | 0055 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
112 | 0056 Bottom = Pos(2) + Pos(4) - Ext(4) + 2; |
---|
113 | 0057 Width = Ext(3); |
---|
114 | 0058 Height = 1; |
---|
115 | 0059 <span class="keyword">switch</span> lower(Horiz) |
---|
116 | 0060 <span class="keyword">case</span> <span class="string">'left'</span> |
---|
117 | 0061 Left = Pos(1); |
---|
118 | 0062 <span class="keyword">case</span> <span class="string">'center'</span> |
---|
119 | 0063 Left = Pos(1) + Pos(3)/2 - Ext(3)/2; |
---|
120 | 0064 <span class="keyword">case</span> <span class="string">'right'</span> |
---|
121 | 0065 Left = Pos(1) + Pos(3) - Ext(3); |
---|
122 | 0066 <span class="keyword">end</span> |
---|
123 | 0067 fPos = [Left Bottom Width Height]; |
---|
124 | 0068 hFrame = uicontrol(<span class="string">'style'</span>,<span class="string">'Frame'</span>,<span class="string">'pos'</span>,fPos,<span class="string">'ForegroundColor'</span>,FOREGROUNDCOLOR); |
---|
125 | 0069 setappdata(h,<span class="string">'hFrame'</span>,hFrame); |
---|
126 | 0070 |
---|
127 | 0071 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
128 | 0072 <span class="comment">% Setup callback</span> |
---|
129 | 0073 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
130 | 0074 ButtonDownFcn = <span class="keyword">...</span> |
---|
131 | 0075 [<span class="string">'set([gcbo getappdata(gcbo,''hFrame'')],''ForeGroundColor'', '</span> CLICKEDCOLOR <span class="string">');'</span>]; |
---|
132 | 0076 ButtonDownFcn = [ ButtonDownFcn <span class="string">'web('''</span> url <span class="string">''',''-browser'');'</span> ]; |
---|
133 | 0077 |
---|
134 | 0078 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
135 | 0079 <span class="comment">% Adjust the properties and restore units</span> |
---|
136 | 0080 <span class="comment">%----------------------------------------------------------------------------</span> |
---|
137 | 0081 set(h,<span class="string">'ForegroundColor'</span>,FOREGROUNDCOLOR, <span class="keyword">...</span> |
---|
138 | 0082 <span class="string">'ButtonDownFcn'</span>,ButtonDownFcn,<span class="string">'Enable'</span>,<span class="string">'Inactive'</span>,<span class="string">'Units'</span>,OldUnits);</pre></div> |
---|
139 | <hr><address>Generated on Mon 21-May-2007 15:32:41 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
140 | </body> |
---|
141 | </html> |
---|