xref: /aoo42x/main/svtools/inc/svtools/fixedhyper.hxx (revision 01aa44aa)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef SVTOOLS_FIXEDHYPER_HXX
24 #define SVTOOLS_FIXEDHYPER_HXX
25 
26 #include "svtools/svtdllapi.h"
27 
28 #include <toolkit/helper/fixedhyperbase.hxx>
29 
30 //.........................................................................
31 namespace svt
32 {
33 //.........................................................................
34 
35     //=====================================================================
36     //= FixedHyperlink
37     //=====================================================================
38     class SVT_DLLPUBLIC FixedHyperlink : public ::toolkit::FixedHyperlinkBase
39 	{
40     private:
41         long                m_nTextLen;
42         Pointer             m_aOldPointer;
43         Link                m_aClickHdl;
44         String              m_sURL;
45 
46         /** initializes the font (link color and underline).
47 
48             Called by the Ctors.
49         */
50         void                Initialize();
51 
52     protected:
53         /** overwrites Window::MouseMove().
54 
55             Changes the pointer only over the text.
56         */
57         virtual void        MouseMove( const MouseEvent& rMEvt );
58 
59         /** overwrites Window::MouseButtonUp().
60 
61             Calls the set link if the mouse is over the text.
62         */
63         virtual void        MouseButtonUp( const MouseEvent& rMEvt );
64 
65         /** overwrites Window::RequestHelp().
66 
67             Shows tooltip only if the mouse is over the text.
68         */
69         virtual void        RequestHelp( const HelpEvent& rHEvt );
70 
71     public:
72         /** ctors
73 
74             With ResId or WinBits.
75         */
76         FixedHyperlink( Window* pParent, const ResId& rId );
77         FixedHyperlink( Window* pParent, WinBits nWinStyle = 0 );
78 
79         /** dtor
80 
81         */
82         virtual ~FixedHyperlink();
83 
84         /** overwrites Window::GetFocus().
85 
86             Changes the color of the text and shows a focus rectangle.
87         */
88         virtual void        GetFocus();
89 
90         /** overwrites Window::LoseFocus().
91 
92             Changes the color of the text and hides the focus rectangle.
93         */
94         virtual void        LoseFocus();
95 
96         /** overwrites Window::KeyInput().
97 
98             KEY_RETURN and KEY_SPACE calls the link handler.
99         */
100         virtual void        KeyInput( const KeyEvent& rKEvt );
101 
102         /** sets <member>m_aClickHdl</member> with <arg>rLink</arg>.
103 
104             <member>m_aClickHdl</member> is called if the text is clicked.
105         */
SetClickHdl(const Link & rLink)106         inline void         SetClickHdl( const Link& rLink ) { m_aClickHdl = rLink; }
107 
108         /** returns <member>m_aClickHdl</member>.
109 
110             @return
111                 <member>m_aClickHdl</member>
112         */
GetClickHdl() const113         inline const Link&  GetClickHdl() const { return m_aClickHdl; }
114 
115         // ::toolkit::FixedHyperbaseLink
116 
117         /** sets the URL of the hyperlink and uses it as tooltip. */
118         virtual void        SetURL( const String& rNewURL );
119 
120         /** returns the URL of the hyperlink.
121 
122             @return
123                 <member>m_sURL</member>
124         */
125         virtual String      GetURL() const;
126 
127         /** sets new text and recalculates the text length. */
128         virtual void        SetDescription( const String& rNewDescription );
129     };
130 
131     //=====================================================================
132     //= FixedHyperlinkImage
133     //=====================================================================
134     class SVT_DLLPUBLIC FixedHyperlinkImage : public FixedImage
135     {
136     private:
137         Pointer             m_aOldPointer;
138         Link                m_aClickHdl;
139         String              m_sURL;
140 
141         /** initializes the font (link color and underline).
142 
143             Called by the Ctors.
144         */
145         void                Initialize();
146 
147     protected:
148         /** overwrites Window::MouseMove().
149 
150             Changes the pointer only over the text.
151         */
152         virtual void        MouseMove( const MouseEvent& rMEvt );
153 
154         /** overwrites Window::MouseButtonUp().
155 
156             Calls the set link if the mouse is over the text.
157         */
158         virtual void        MouseButtonUp( const MouseEvent& rMEvt );
159 
160         /** overwrites Window::RequestHelp().
161 
162             Shows tooltip only if the mouse is over the text.
163         */
164         virtual void        RequestHelp( const HelpEvent& rHEvt );
165 
166     public:
167         /** ctors
168 
169             With ResId or WinBits.
170         */
171         FixedHyperlinkImage( Window* pParent, const ResId& rId );
172         FixedHyperlinkImage( Window* pParent, WinBits nWinStyle = 0 );
173 
174         /** dtor
175 
176         */
177         virtual ~FixedHyperlinkImage();
178 
179         /** overwrites Window::GetFocus().
180 
181             Changes the color of the text and shows a focus rectangle.
182         */
183         virtual void        GetFocus();
184 
185         /** overwrites Window::LoseFocus().
186 
187             Changes the color of the text and hides the focus rectangle.
188         */
189         virtual void        LoseFocus();
190 
191         /** overwrites Window::KeyInput().
192 
193             KEY_RETURN and KEY_SPACE calls the link handler.
194         */
195         virtual void        KeyInput( const KeyEvent& rKEvt );
196 
197         /** sets <member>m_aClickHdl</member> with <arg>rLink</arg>.
198 
199             <member>m_aClickHdl</member> is called if the text is clicked.
200         */
SetClickHdl(const Link & rLink)201         inline void         SetClickHdl( const Link& rLink ) { m_aClickHdl = rLink; }
202 
203         /** returns <member>m_aClickHdl</member>.
204 
205             @return
206                 <member>m_aClickHdl</member>
207         */
GetClickHdl() const208         inline const Link&  GetClickHdl() const { return m_aClickHdl; }
209 
210         // ::toolkit::FixedHyperbaseLink
211 
212         /** sets the URL of the hyperlink and uses it as tooltip. */
213         virtual void        SetURL( const String& rNewURL );
214 
215         /** returns the URL of the hyperlink.
216 
217             @return
218                 <member>m_sURL</member>
219         */
220         virtual String      GetURL() const;
221     };
222 //.........................................................................
223 } // namespace svt
224 //.........................................................................
225 
226 #endif
227 
228