LibreOffice Module vcl (master) 1
status.hxx
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#ifndef INCLUDED_VCL_STATUS_HXX
21#define INCLUDED_VCL_STATUS_HXX
22
23#include <tools/solar.h>
24#include <vcl/dllapi.h>
25#include <vcl/window.hxx>
27#include <memory>
28#include <vector>
29
31class HelpEvent;
32class MouseEvent;
33class UserDrawEvent;
34struct ImplStatusItem;
35
36void DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos,
37 tools::Long nOffset, tools::Long nPrgsWidth, tools::Long nPrgsHeight,
38 sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
39 const tools::Rectangle& rFramePosSize);
40
41
43 NONE = 0x0000,
44 Left = 0x0001,
45 Center = 0x0002,
46 Right = 0x0004,
47 In = 0x0008,
48 Out = 0x0010,
49 Flat = 0x0020,
50 AutoSize = 0x0040,
51 UserDraw = 0x0080,
52 Mandatory = 0x0100,
53};
54namespace o3tl
55{
56 template<> struct typed_flags<StatusBarItemBits> : is_typed_flags<StatusBarItemBits, 0x01ff> {};
57}
58
59#define STATUSBAR_APPEND (sal_uInt16(0xFFFF))
60#define STATUSBAR_ITEM_NOTFOUND (sal_uInt16(0xFFFF))
61#define STATUSBAR_OFFSET (tools::Long(5))
62
63
65{
66 class SAL_DLLPRIVATE ImplData;
67private:
68 std::vector<std::unique_ptr<ImplStatusItem>> mvItemList;
69 std::unique_ptr<ImplData> mpImplData;
70 OUString maPrgsTxt;
79 sal_uInt16 mnCurItemId;
80 sal_uInt16 mnPercent;
81 sal_uInt16 mnPercentCount;
89
90 using Window::ImplInit;
91 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
92 SAL_DLLPRIVATE void ImplInitSettings();
93 SAL_DLLPRIVATE void ImplFormat();
94 SAL_DLLPRIVATE bool ImplIsItemUpdate() const;
95
96 SAL_DLLPRIVATE void ImplDrawText(vcl::RenderContext& rRenderContext);
97 SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen,
98 sal_uInt16 nPos);
99 SAL_DLLPRIVATE void ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt16 nNewPerc);
100 SAL_DLLPRIVATE void ImplCalcProgressRect();
101 SAL_DLLPRIVATE tools::Rectangle ImplGetItemRectPos( sal_uInt16 nPos ) const;
102 SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisiblePos() const;
103
104 SAL_DLLPRIVATE void PaintSelfAndChildrenImmediately();
105
106protected:
107 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
108
109public:
110 StatusBar( vcl::Window* pParent,
111 WinBits nWinStyle = WB_BORDER | WB_RIGHT );
112 virtual ~StatusBar() override;
113 virtual void dispose() override;
114
115 void AdjustItemWidthsForHiDPI();
116
117 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
118 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
119 virtual void Resize() override;
120 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
121 virtual void StateChanged( StateChangedType nType ) override;
122 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
123
124 void Click();
125 void DoubleClick();
126 virtual void UserDraw( const UserDrawEvent& rUDEvt );
127
128 void InsertItem( sal_uInt16 nItemId, sal_uLong nWidth,
131 sal_uInt16 nPos = STATUSBAR_APPEND );
132 void RemoveItem( sal_uInt16 nItemId );
133
134 void ShowItem( sal_uInt16 nItemId );
135 void HideItem( sal_uInt16 nItemId );
136 bool IsItemVisible( sal_uInt16 nItemId ) const;
137
138 void RedrawItem( sal_uInt16 nItemId );
139
140 void Clear();
141
142 sal_uInt16 GetItemCount() const;
143 sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
144 sal_uInt16 GetItemId( const Point& rPos ) const;
145 sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const;
146 tools::Rectangle GetItemRect( sal_uInt16 nItemId ) const;
147 Point GetItemTextPos( sal_uInt16 nItemId ) const;
148 sal_uInt16 GetCurItemId() const { return mnCurItemId; }
149
150 sal_uLong GetItemWidth( sal_uInt16 nItemId ) const;
151 StatusBarItemBits GetItemBits( sal_uInt16 nItemId ) const;
152
153 tools::Long GetItemOffset( sal_uInt16 nItemId ) const;
154
156 void SetItemText( sal_uInt16 nItemId, const OUString& rText, int nCharsWidth = -1 );
157 const OUString& GetItemText( sal_uInt16 nItemId ) const;
158
159 void SetItemData( sal_uInt16 nItemId, void* pNewData );
160 void* GetItemData( sal_uInt16 nItemId ) const;
161
162 void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand );
163 OUString GetItemCommand( sal_uInt16 nItemId );
164
165 void SetHelpText( sal_uInt16 nItemId, const OUString& rText );
166 const OUString& GetHelpText( sal_uInt16 nItemId ) const;
167
169 void SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText );
171 const OUString& GetQuickHelpText( sal_uInt16 nItemId ) const;
172
173 void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId );
174
175 void StartProgressMode( const OUString& rText );
176 void SetProgressValue( sal_uInt16 nPercent );
177 void EndProgressMode();
178 bool IsProgressMode() const { return mbProgressMode; }
179
180 void SetText( const OUString& rText ) override;
181
182 Size CalcWindowSizePixel() const;
183
184 void SetClickHdl( const Link<StatusBar*,void>& rLink ) { maClickHdl = rLink; }
185 void SetDoubleClickHdl( const Link<StatusBar*,void>& rLink ) { maDoubleClickHdl = rLink; }
186
188 void SetAccessibleName( sal_uInt16 nItemId, const OUString& rName );
190 const OUString& GetAccessibleName( sal_uInt16 nItemId ) const;
191};
192
193#endif // INCLUDED_VCL_STATUS_HXX
194
195/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:171
Point maPrgsTxtPos
Definition: status.hxx:71
bool mbFormat
Definition: status.hxx:83
bool mbInUserDraw
Definition: status.hxx:85
void SetDoubleClickHdl(const Link< StatusBar *, void > &rLink)
Definition: status.hxx:185
bool mbProgressMode
Definition: status.hxx:84
tools::Long mnPrgsSize
Definition: status.hxx:73
sal_uInt16 mnPercent
Definition: status.hxx:80
tools::Long mnDX
Definition: status.hxx:75
tools::Long mnTextY
Definition: status.hxx:78
tools::Rectangle maPrgsFrameRect
Definition: status.hxx:72
void SetClickHdl(const Link< StatusBar *, void > &rLink)
Definition: status.hxx:184
tools::Long mnItemsWidth
Definition: status.hxx:74
OUString maPrgsTxt
Definition: status.hxx:70
sal_uInt16 mnCurItemId
Definition: status.hxx:79
std::unique_ptr< ImplData > mpImplData
Definition: status.hxx:69
sal_uInt32 mnLastProgressPaint_ms
Definition: status.hxx:82
sal_uInt16 mnPercentCount
Definition: status.hxx:81
sal_uInt16 GetCurItemId() const
Definition: status.hxx:148
std::vector< std::unique_ptr< ImplStatusItem > > mvItemList
Definition: status.hxx:68
Link< StatusBar *, void > maClickHdl
Definition: status.hxx:87
tools::Long mnCalcHeight
Definition: status.hxx:77
tools::Long mnDY
Definition: status.hxx:76
Link< StatusBar *, void > maDoubleClickHdl
Definition: status.hxx:88
bool IsProgressMode() const
Definition: status.hxx:178
bool mbAdjustHiDPI
Definition: status.hxx:86
Event to pass information for UserDraw() handling eg. in comboboxes.
Definition: event.hxx:222
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: window.cxx:140
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1873
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1944
void SetHelpText(const OUString &rHelpText)
Definition: window2.cxx:1251
virtual void Resize()
Definition: window.cxx:1839
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:420
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1020
void SetAccessibleName(const OUString &rName)
void SetHelpId(const OString &)
Definition: window2.cxx:849
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
OUString GetAccessibleName() const
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3851
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1257
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3033
const OUString & GetQuickHelpText() const
Definition: window2.cxx:1263
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:942
const OUString & GetHelpText() const
Definition: window.cxx:3097
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void Clear(EHistoryType eHistory)
NONE
long Long
sal_uIntPtr sal_uLong
#define STATUSBAR_APPEND
Definition: status.hxx:59
void DrawProgress(vcl::Window *pWindow, vcl::RenderContext &rRenderContext, const Point &rPos, tools::Long nOffset, tools::Long nPrgsWidth, tools::Long nPrgsHeight, sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount, const tools::Rectangle &rFramePosSize)
Definition: status.cxx:472
#define STATUSBAR_OFFSET
Definition: status.hxx:61
StatusBarItemBits
Definition: status.hxx:42
Left
Center
Right
StateChangedType
Definition: window.hxx:291
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_RIGHT
Definition: wintypes.hxx:148
WinBits const WB_BORDER
Definition: wintypes.hxx:115