1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef SVTOOLS_FIXEDHYPER_HXX 28 #define SVTOOLS_FIXEDHYPER_HXX 29 30 #include "svtools/svtdllapi.h" 31 32 #include <toolkit/helper/fixedhyperbase.hxx> 33 34 //......................................................................... 35 namespace svt 36 { 37 //......................................................................... 38 39 //===================================================================== 40 //= FixedHyperlink 41 //===================================================================== 42 class SVT_DLLPUBLIC FixedHyperlink : public ::toolkit::FixedHyperlinkBase 43 { 44 private: 45 long m_nTextLen; 46 Pointer m_aOldPointer; 47 Link m_aClickHdl; 48 String m_sURL; 49 50 /** initializes the font (link color and underline). 51 52 Called by the Ctors. 53 */ 54 void Initialize(); 55 56 protected: 57 /** overwrites Window::MouseMove(). 58 59 Changes the pointer only over the text. 60 */ 61 virtual void MouseMove( const MouseEvent& rMEvt ); 62 63 /** overwrites Window::MouseButtonUp(). 64 65 Calls the set link if the mouse is over the text. 66 */ 67 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 68 69 /** overwrites Window::RequestHelp(). 70 71 Shows tooltip only if the mouse is over the text. 72 */ 73 virtual void RequestHelp( const HelpEvent& rHEvt ); 74 75 public: 76 /** ctors 77 78 With ResId or WinBits. 79 */ 80 FixedHyperlink( Window* pParent, const ResId& rId ); 81 FixedHyperlink( Window* pParent, WinBits nWinStyle = 0 ); 82 83 /** dtor 84 85 */ 86 virtual ~FixedHyperlink(); 87 88 /** overwrites Window::GetFocus(). 89 90 Changes the color of the text and shows a focus rectangle. 91 */ 92 virtual void GetFocus(); 93 94 /** overwrites Window::LoseFocus(). 95 96 Changes the color of the text and hides the focus rectangle. 97 */ 98 virtual void LoseFocus(); 99 100 /** overwrites Window::KeyInput(). 101 102 KEY_RETURN and KEY_SPACE calls the link handler. 103 */ 104 virtual void KeyInput( const KeyEvent& rKEvt ); 105 106 /** sets <member>m_aClickHdl</member> with <arg>rLink</arg>. 107 108 <member>m_aClickHdl</member> is called if the text is clicked. 109 */ 110 inline void SetClickHdl( const Link& rLink ) { m_aClickHdl = rLink; } 111 112 /** returns <member>m_aClickHdl</member>. 113 114 @return 115 <member>m_aClickHdl</member> 116 */ 117 inline const Link& GetClickHdl() const { return m_aClickHdl; } 118 119 // ::toolkit::FixedHyperbaseLink 120 121 /** sets the URL of the hyperlink and uses it as tooltip. */ 122 virtual void SetURL( const String& rNewURL ); 123 124 /** returns the URL of the hyperlink. 125 126 @return 127 <member>m_sURL</member> 128 */ 129 virtual String GetURL() const; 130 131 /** sets new text and recalculates the text length. */ 132 virtual void SetDescription( const String& rNewDescription ); 133 }; 134 135 //===================================================================== 136 //= FixedHyperlinkImage 137 //===================================================================== 138 class SVT_DLLPUBLIC FixedHyperlinkImage : public FixedImage 139 { 140 private: 141 Pointer m_aOldPointer; 142 Link m_aClickHdl; 143 String m_sURL; 144 145 /** initializes the font (link color and underline). 146 147 Called by the Ctors. 148 */ 149 void Initialize(); 150 151 protected: 152 /** overwrites Window::MouseMove(). 153 154 Changes the pointer only over the text. 155 */ 156 virtual void MouseMove( const MouseEvent& rMEvt ); 157 158 /** overwrites Window::MouseButtonUp(). 159 160 Calls the set link if the mouse is over the text. 161 */ 162 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 163 164 /** overwrites Window::RequestHelp(). 165 166 Shows tooltip only if the mouse is over the text. 167 */ 168 virtual void RequestHelp( const HelpEvent& rHEvt ); 169 170 public: 171 /** ctors 172 173 With ResId or WinBits. 174 */ 175 FixedHyperlinkImage( Window* pParent, const ResId& rId ); 176 FixedHyperlinkImage( Window* pParent, WinBits nWinStyle = 0 ); 177 178 /** dtor 179 180 */ 181 virtual ~FixedHyperlinkImage(); 182 183 /** overwrites Window::GetFocus(). 184 185 Changes the color of the text and shows a focus rectangle. 186 */ 187 virtual void GetFocus(); 188 189 /** overwrites Window::LoseFocus(). 190 191 Changes the color of the text and hides the focus rectangle. 192 */ 193 virtual void LoseFocus(); 194 195 /** overwrites Window::KeyInput(). 196 197 KEY_RETURN and KEY_SPACE calls the link handler. 198 */ 199 virtual void KeyInput( const KeyEvent& rKEvt ); 200 201 /** sets <member>m_aClickHdl</member> with <arg>rLink</arg>. 202 203 <member>m_aClickHdl</member> is called if the text is clicked. 204 */ 205 inline void SetClickHdl( const Link& rLink ) { m_aClickHdl = rLink; } 206 207 /** returns <member>m_aClickHdl</member>. 208 209 @return 210 <member>m_aClickHdl</member> 211 */ 212 inline const Link& GetClickHdl() const { return m_aClickHdl; } 213 214 // ::toolkit::FixedHyperbaseLink 215 216 /** sets the URL of the hyperlink and uses it as tooltip. */ 217 virtual void SetURL( const String& rNewURL ); 218 219 /** returns the URL of the hyperlink. 220 221 @return 222 <member>m_sURL</member> 223 */ 224 virtual String GetURL() const; 225 }; 226 //......................................................................... 227 } // namespace svt 228 //......................................................................... 229 230 #endif 231 232