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