source: MML/trunk/applications/doc_html/applications/common/makeurl.html @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 9.1 KB
Line 
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 &copy; 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> &gt;  <a href="#">applications</a> &gt; <a href="index.html">common</a> &gt; makeurl.m</div>
16
17<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
18<td align="right"><a href="index.html">Index for applications/common&nbsp;<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>
47This function calls:
48<ul style="list-style-image:url(../../matlabicon.gif)">
49</ul>
50This 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>
580002 <span class="comment">%MAKEURL Make a URL from a uicontrol of style text.</span>
590003 <span class="comment">%   MAKEURL(h,url) adjusts the properties of the text style UICONTROL</span>
600004 <span class="comment">%   object to make it act like a typical URL hyperlink.  The hyperlink's</span>
610005 <span class="comment">%   target is given by the string url.</span>
620006 <span class="comment">%</span>
630007 <span class="comment">%   MAKEURL(...,'ForeGroundColor',C1,'ClickedColor',C2) will set the</span>
640008 <span class="comment">%   unclicked text color to C1 and the clicked text color to C2 where</span>
650009 <span class="comment">%   C1 and C2 are valid colorspecs.  The default values are C1 = 'b'</span>
660010 <span class="comment">%   and C2 = 'm'.</span>
670011 <span class="comment">%</span>
680012 <span class="comment">%   Ex.</span>
690013 <span class="comment">%</span>
700014 <span class="comment">%      h = uicontrol('style','text','string','MathWorks');</span>
710015 <span class="comment">%      makeurl(h,'http://www.mathworks.com');</span>
720016
730017 <span class="comment">% Jordan Rosenthal, jr@ll.mit.edu</span>
740018 <span class="comment">% Initial Version, 08-Dec-1999</span>
750019 <span class="comment">%            Rev., 18-Dec-2001 Added -browser switch and changed email contact.</span>
760020
770021 <span class="comment">%----------------------------------------------------------------------------</span>
780022 <span class="comment">% Default Parameters</span>
790023 <span class="comment">%----------------------------------------------------------------------------</span>
800024 FOREGROUNDCOLOR = <span class="string">'b'</span>;
810025 CLICKEDCOLOR    = <span class="string">'m'</span>;
820026
830027 <span class="comment">%----------------------------------------------------------------------------</span>
840028 <span class="comment">% Parse Inputs</span>
850029 <span class="comment">%----------------------------------------------------------------------------</span>
860030 <span class="keyword">if</span> nargin &lt; 2, error(<span class="string">'Not enough input arguments.'</span>); <span class="keyword">end</span>
870031 <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>
880032 <span class="keyword">if</span> exist(<span class="string">'varargin'</span>,<span class="string">'var'</span>)
890033    L = length(varargin);
900034    <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>
910035    <span class="keyword">for</span> i = 1:2:L
920036       <span class="keyword">switch</span> lower(varargin{i}(1))
930037       <span class="keyword">case</span> <span class="string">'f'</span>, FOREGROUNDCOLOR = varargin{i+1};
940038       <span class="keyword">case</span> <span class="string">'c'</span>,    CLICKEDCOLOR = varargin{i+1};
950039       <span class="keyword">end</span>
960040    <span class="keyword">end</span>
970041 <span class="keyword">end</span>
980042 <span class="comment">%---  Add quotes around the color if given as a character  ---%</span>
990043 <span class="keyword">if</span> ischar(CLICKEDCOLOR), CLICKEDCOLOR = [<span class="string">''''</span> CLICKEDCOLOR <span class="string">''''</span>]; <span class="keyword">end</span>
1000044
1010045 <span class="comment">%----------------------------------------------------------------------------</span>
1020046 <span class="comment">% Swicth units and get the pertinent parameters</span>
1030047 <span class="comment">%----------------------------------------------------------------------------</span>
1040048 OldUnits = get(h,<span class="string">'Units'</span>); set(h,<span class="string">'Units'</span>,<span class="string">'pixels'</span>);
1050049 Ext   = get(h,<span class="string">'Extent'</span>);
1060050 Pos   = get(h,<span class="string">'Pos'</span>);
1070051 Horiz = get(h,<span class="string">'HorizontalAlignment'</span>);
1080052
1090053 <span class="comment">%----------------------------------------------------------------------------</span>
1100054 <span class="comment">% Add an underline by creating a 1 pixel high frame</span>
1110055 <span class="comment">%----------------------------------------------------------------------------</span>
1120056 Bottom = Pos(2) + Pos(4) - Ext(4) + 2;
1130057 Width  = Ext(3);
1140058 Height = 1;
1150059 <span class="keyword">switch</span> lower(Horiz)
1160060 <span class="keyword">case</span> <span class="string">'left'</span>
1170061    Left = Pos(1);
1180062 <span class="keyword">case</span> <span class="string">'center'</span>
1190063    Left = Pos(1) + Pos(3)/2 - Ext(3)/2;
1200064 <span class="keyword">case</span> <span class="string">'right'</span>
1210065    Left = Pos(1) + Pos(3) - Ext(3);
1220066 <span class="keyword">end</span>
1230067 fPos = [Left Bottom Width Height];
1240068 hFrame = uicontrol(<span class="string">'style'</span>,<span class="string">'Frame'</span>,<span class="string">'pos'</span>,fPos,<span class="string">'ForegroundColor'</span>,FOREGROUNDCOLOR);
1250069 setappdata(h,<span class="string">'hFrame'</span>,hFrame);
1260070
1270071 <span class="comment">%----------------------------------------------------------------------------</span>
1280072 <span class="comment">% Setup callback</span>
1290073 <span class="comment">%----------------------------------------------------------------------------</span>
1300074 ButtonDownFcn =  <span class="keyword">...</span>
1310075    [<span class="string">'set([gcbo getappdata(gcbo,''hFrame'')],''ForeGroundColor'', '</span> CLICKEDCOLOR <span class="string">');'</span>];
1320076 ButtonDownFcn = [ ButtonDownFcn <span class="string">'web('''</span> url <span class="string">''',''-browser'');'</span> ];
1330077
1340078 <span class="comment">%----------------------------------------------------------------------------</span>
1350079 <span class="comment">% Adjust the properties and restore units</span>
1360080 <span class="comment">%----------------------------------------------------------------------------</span>
1370081 set(h,<span class="string">'ForegroundColor'</span>,FOREGROUNDCOLOR, <span class="keyword">...</span>
1380082    <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> &copy; 2003</address>
140</body>
141</html>
Note: See TracBrowser for help on using the repository browser.