1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_FIXEDHYPER_HXX
21 #define INCLUDED_VCL_FIXEDHYPER_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/fixed.hxx>
26 class VCL_DLLPUBLIC FixedHyperlink
: public FixedText
30 Pointer m_aOldPointer
;
31 Link
<FixedHyperlink
&,void> m_aClickHdl
;
34 /** initializes the font (link color and underline).
40 /** is position X position hitting text */
41 SAL_DLLPRIVATE
bool ImplIsOverText(Point rPosition
);
43 DECL_STATIC_LINK(FixedHyperlink
, HandleClick
, FixedHyperlink
&, void);
46 /** overwrites Window::MouseMove().
48 Changes the pointer only over the text.
50 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
52 /** overwrites Window::MouseButtonUp().
54 Calls the set link if the mouse is over the text.
56 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) override
;
58 /** overwrites Window::RequestHelp().
60 Shows tooltip only if the mouse is over the text.
62 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
69 FixedHyperlink( vcl::Window
* pParent
, WinBits nWinStyle
= 0 );
71 /** overwrites Window::GetFocus().
73 Changes the color of the text and shows a focus rectangle.
75 virtual void GetFocus() override
;
77 /** overwrites Window::LoseFocus().
79 Changes the color of the text and hides the focus rectangle.
81 virtual void LoseFocus() override
;
83 /** overwrites Window::KeyInput().
85 KEY_RETURN and KEY_SPACE calls the link handler.
87 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
89 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
92 /** sets m_aClickHdl with rLink.
94 m_aClickHdl is called if the text is clicked.
96 void SetClickHdl( const Link
<FixedHyperlink
&,void>& rLink
) { m_aClickHdl
= rLink
; }
98 // ::FixedHyperbaseLink
100 /** sets the URL of the hyperlink and uses it as tooltip. */
101 void SetURL(const OUString
& rNewURL
);
103 /** returns the URL of the hyperlink.
108 const OUString
& GetURL() const { return m_sURL
;}
110 /** sets new text and recalculates the text length. */
111 virtual void SetText(const OUString
& rNewDescription
) override
;
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */