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 .
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
26 #include <config_options.h>
27 #include <vcl/dllapi.h>
28 #include <vcl/toolkit/fixed.hxx>
30 class UNLESS_MERGELIBS(VCL_DLLPUBLIC
) FixedHyperlink final
: public FixedText
33 tools::Long m_nTextLen
;
34 PointerStyle m_aOldPointer
;
35 Link
<FixedHyperlink
&,void> m_aClickHdl
;
38 /** initializes the font (link color and underline).
44 /** is position X position hitting text */
45 SAL_DLLPRIVATE
bool ImplIsOverText(Point rPosition
) const;
47 DECL_DLLPRIVATE_LINK(HandleClick
, FixedHyperlink
&, void);
49 /** overwrites Window::MouseMove().
51 Changes the pointer only over the text.
53 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
55 /** overwrites Window::MouseButtonUp().
57 Calls the set link if the mouse is over the text.
59 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) override
;
61 /** overwrites Window::RequestHelp().
63 Shows tooltip only if the mouse is over the text.
65 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
72 FixedHyperlink( vcl::Window
* pParent
, WinBits nWinStyle
= 0 );
74 /** overwrites Window::GetFocus().
76 Changes the color of the text and shows a focus rectangle.
78 virtual void GetFocus() override
;
80 /** overwrites Window::LoseFocus().
82 Changes the color of the text and hides the focus rectangle.
84 virtual void LoseFocus() override
;
86 /** overwrites Window::KeyInput().
88 KEY_RETURN and KEY_SPACE calls the link handler.
90 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
92 virtual bool set_property(const OUString
&rKey
, const OUString
&rValue
) override
;
95 /** sets m_aClickHdl with rLink.
97 m_aClickHdl is called if the text is clicked.
99 void SetClickHdl( const Link
<FixedHyperlink
&,void>& rLink
) { m_aClickHdl
= rLink
; }
100 const Link
<FixedHyperlink
&,void>& GetClickHdl() const { return m_aClickHdl
; }
102 // ::FixedHyperbaseLink
104 /** sets the URL of the hyperlink and uses it as tooltip. */
105 void SetURL(const OUString
& rNewURL
);
107 /** returns the URL of the hyperlink.
112 const OUString
& GetURL() const { return m_sURL
;}
114 /** sets new text and recalculates the text length. */
115 virtual void SetText(const OUString
& rNewDescription
) override
;
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */