Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_FIXEDHYPER_HXX
21 : #define INCLUDED_VCL_FIXEDHYPER_HXX
22 :
23 : #include <vcl/dllapi.h>
24 : #include <vcl/fixed.hxx>
25 :
26 : class VCL_DLLPUBLIC FixedHyperlink : public FixedText
27 : {
28 : private:
29 : long m_nTextLen;
30 : Pointer m_aOldPointer;
31 : Link m_aClickHdl;
32 : OUString m_sURL;
33 :
34 : /** initializes the font (link color and underline).
35 :
36 : Called by the Ctors.
37 : */
38 : void Initialize();
39 :
40 : /** is position X positon hitting text */
41 : SAL_DLLPRIVATE bool ImplIsOverText(Point rPosition);
42 :
43 : protected:
44 : /** overwrites Window::MouseMove().
45 :
46 : Changes the pointer only over the text.
47 : */
48 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
49 :
50 : /** overwrites Window::MouseButtonUp().
51 :
52 : Calls the set link if the mouse is over the text.
53 : */
54 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
55 :
56 : /** overwrites Window::RequestHelp().
57 :
58 : Shows tooltip only if the mouse is over the text.
59 : */
60 : virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
61 :
62 : public:
63 : /** ctors
64 :
65 : With ResId or WinBits.
66 : */
67 : FixedHyperlink( Window* pParent, const ResId& rId );
68 : FixedHyperlink( Window* pParent, WinBits nWinStyle = 0 );
69 :
70 : /** dtor
71 :
72 : */
73 : virtual ~FixedHyperlink();
74 :
75 : /** overwrites Window::GetFocus().
76 :
77 : Changes the color of the text and shows a focus rectangle.
78 : */
79 : virtual void GetFocus() SAL_OVERRIDE;
80 :
81 : /** overwrites Window::LoseFocus().
82 :
83 : Changes the color of the text and hides the focus rectangle.
84 : */
85 : virtual void LoseFocus() SAL_OVERRIDE;
86 :
87 : /** overwrites Window::KeyInput().
88 :
89 : KEY_RETURN and KEY_SPACE calls the link handler.
90 : */
91 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
92 :
93 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
94 :
95 :
96 : /** sets m_aClickHdl with rLink.
97 :
98 : m_aClickHdl is called if the text is clicked.
99 : */
100 0 : inline void SetClickHdl( const Link& rLink ) { m_aClickHdl = rLink; }
101 :
102 : /** returns m_aClickHdl.
103 :
104 : @return
105 : m_aClickHdl
106 : */
107 : inline const Link& GetClickHdl() const { return m_aClickHdl; }
108 :
109 : // ::FixedHyperbaseLink
110 :
111 : /** sets the URL of the hyperlink and uses it as tooltip. */
112 : void SetURL(const OUString& rNewURL);
113 :
114 : /** returns the URL of the hyperlink.
115 :
116 : @return
117 : m_sURL
118 : */
119 : OUString GetURL() const;
120 :
121 : /** sets new text and recalculates the text length. */
122 : virtual void SetText(const OUString& rNewDescription) SAL_OVERRIDE;
123 : };
124 :
125 : #endif
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|