LibreOffice Module vcl (master) 1
hyperlabel.cxx
Go to the documentation of this file.
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#include <tools/color.hxx>
21#include <vcl/event.hxx>
22#include <vcl/settings.hxx>
23#include <vcl/ptrstyle.hxx>
24#include <hyperlabel.hxx>
25
26namespace vcl
27{
29 :FixedText( _pParent, _nWinStyle )
30 , ID(0)
31 , Index(0)
32 , bInteractive(false)
33 , m_bHyperMode(false)
34 {
35 implInit();
36 }
37
39 {
41 // the MinimumSize is used to size the FocusRectangle
42 // and for the MouseMove method
45 return m_aMinSize;
46 }
47
49 {
51
52 WinBits nWinStyle = GetStyle();
53 nWinStyle |= WB_EXTRAOFFSET;
54 SetStyle( nWinStyle );
55
56 Show();
57 }
58
60 {
61 SetControlBackground( _rGBColor );
62 }
63
64 void HyperLabel::MouseMove( const MouseEvent& rMEvt )
65 {
66 vcl::Font aFont = GetControlFont( );
67
68 bool bHyperMode = false;
69 if (!rMEvt.IsLeaveWindow() && IsEnabled() && bInteractive)
70 {
71 Point aPoint = GetPointerPosPixel();
72 if (aPoint.X() < m_aMinSize.Width())
73 bHyperMode = true;
74 }
75
76 m_bHyperMode = bHyperMode;
77 if (bHyperMode)
78 {
81 }
82 else
83 {
86 }
87 SetControlFont(aFont);
88 }
89
91 {
93 {
94 maClickHdl.Call( this );
95 }
96 }
97
99 {
100 if ( IsEnabled() && bInteractive )
101 {
102 Point aPoint(0,0);
103 tools::Rectangle rRect(aPoint, Size( m_aMinSize.Width(), GetSizePixel().Height() ) );
104 ShowFocus( rRect );
105 }
106 }
107
109 {
110 HideFocus();
111 }
112
114 {
115 disposeOnce();
116 }
117
118 void HyperLabel::SetInteractive( bool _bInteractive )
119 {
120 bInteractive = ( _bInteractive && IsEnabled() );
121 }
122
123 sal_Int16 HyperLabel::GetID() const
124 {
125 return ID;
126 }
127
128 sal_Int32 HyperLabel::GetIndex() const
129 {
130 return Index;
131 }
132
133 void HyperLabel::SetID( sal_Int16 newID )
134 {
135 this->ID = newID;
136 }
137
138 void HyperLabel::SetIndex( sal_Int32 newIndex )
139 {
140 Index = newIndex;
141 }
142
143 void HyperLabel::SetLabel( const OUString& _rText )
144 {
145 SetText(_rText);
146 }
147
149 {
150 FixedText::ApplySettings(rRenderContext);
151
152 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
154 rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
155 else
156 rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
157 }
158
160 {
161 FixedText::DataChanged( rDCEvt );
162
163 if ((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) ||
164 ( rDCEvt.GetType() == DataChangedEventType::DISPLAY )) &&
165 ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ))
166 {
167 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
169 SetControlBackground(rStyleSettings.GetHighlightColor());
170 Invalidate();
171 }
172 }
173
174} // namespace vcl
175
176/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
const StyleSettings & GetStyleSettings() const
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:96
DataChangedEventType GetType() const
Definition: event.hxx:362
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: fixed.cxx:166
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:284
Size CalcMinimumSize(tools::Long nMaxWidth=0x7fffffff) const
Definition: fixed.cxx:324
bool IsLeaveWindow() const
Definition: event.hxx:140
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:171
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
const AllSettings & GetSettings() const
Definition: outdev.hxx:289
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
const Color & GetFieldTextColor() const
const Color & GetHighlightColor() const
const Color & GetHighlightTextColor() const
void SetUnderline(FontLineStyle)
Definition: font/font.cxx:296
sal_Int16 GetID() const
Definition: hyperlabel.cxx:123
sal_Int32 GetIndex() const
Definition: hyperlabel.cxx:128
void SetIndex(sal_Int32 Index)
Definition: hyperlabel.cxx:138
virtual void GetFocus() override
Definition: hyperlabel.cxx:98
Link< HyperLabel *, void > maClickHdl
Definition: hyperlabel.hxx:30
void ToggleBackgroundColor(const Color &_rGBColor)
Definition: hyperlabel.cxx:59
sal_Int32 Index
Definition: hyperlabel.hxx:64
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: hyperlabel.cxx:148
void SetLabel(const OUString &_rText)
Definition: hyperlabel.cxx:143
HyperLabel(vcl::Window *_pParent, WinBits _nWinStyle)
Definition: hyperlabel.cxx:28
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: hyperlabel.cxx:90
Size const & CalcMinimumSize(tools::Long nMaxWidth)
Definition: hyperlabel.cxx:38
void SetInteractive(bool _bInteractive)
Definition: hyperlabel.cxx:118
sal_Int16 ID
Definition: hyperlabel.hxx:63
void SetID(sal_Int16 ID)
Definition: hyperlabel.cxx:133
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: hyperlabel.cxx:159
virtual void LoseFocus() override
Definition: hyperlabel.cxx:108
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: hyperlabel.cxx:64
virtual ~HyperLabel() override
Definition: hyperlabel.cxx:113
void SetStyle(WinBits nStyle)
Definition: window.cxx:1964
void SetControlFont()
Definition: window2.cxx:433
void HideFocus()
Definition: window2.cxx:95
void SetControlBackground()
Definition: window2.cxx:521
WinBits GetStyle() const
Definition: window2.cxx:977
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2189
vcl::Font GetControlFont() const
Definition: window2.cxx:462
virtual void ShowFocus(const tools::Rectangle &rRect)
Definition: window2.cxx:53
virtual Size GetSizePixel() const
Definition: window.cxx:2404
Point GetPointerPosPixel()
Definition: mouse.cxx:564
const Color & GetControlBackground() const
Definition: window2.cxx:1106
void SetPointer(PointerStyle)
Definition: mouse.cxx:486
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
bool IsEnabled() const
Definition: window2.cxx:1146
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
LINESTYLE_SINGLE
LINESTYLE_NONE
long Long
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_EXTRAOFFSET
Definition: wintypes.hxx:191