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_STATUS_HXX
21 #define INCLUDED_VCL_STATUS_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/window.hxx>
26 #include <o3tl/typed_flags_set.hxx>
29 struct ImplStatusItem
;
31 void VCL_DLLPUBLIC
DrawProgress(vcl::Window
* pWindow
, vcl::RenderContext
& rRenderContext
, const Point
& rPos
,
32 long nOffset
, long nPrgsWidth
, long nPrgsHeight
,
33 sal_uInt16 nPercent1
, sal_uInt16 nPercent2
, sal_uInt16 nPercentCount
,
34 const tools::Rectangle
& rFramePosSize
);
37 enum class StatusBarItemBits
{
50 template<> struct typed_flags
<StatusBarItemBits
> : is_typed_flags
<StatusBarItemBits
, 0x00ff> {};
53 #define STATUSBAR_APPEND ((sal_uInt16)0xFFFF)
54 #define STATUSBAR_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
55 #define STATUSBAR_OFFSET ((long)5)
58 class VCL_DLLPUBLIC StatusBar
: public vcl::Window
62 std::vector
<ImplStatusItem
*> mpItemList
;
66 tools::Rectangle maPrgsFrameRect
;
73 sal_uInt16 mnCurItemId
;
75 sal_uInt16 mnPercentCount
;
81 Link
<StatusBar
*,void> maClickHdl
;
82 Link
<StatusBar
*,void> maDoubleClickHdl
;
84 using Window::ImplInit
;
85 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
86 SAL_DLLPRIVATE
void ImplInitSettings();
87 SAL_DLLPRIVATE
void ImplFormat();
88 SAL_DLLPRIVATE
bool ImplIsItemUpdate();
90 SAL_DLLPRIVATE
void ImplDrawText(vcl::RenderContext
& rRenderContext
);
91 SAL_DLLPRIVATE
void ImplDrawItem(vcl::RenderContext
& rRenderContext
, bool bOffScreen
,
93 SAL_DLLPRIVATE
void ImplDrawProgress(vcl::RenderContext
& rRenderContext
, sal_uInt16 nNewPerc
);
94 SAL_DLLPRIVATE
void ImplCalcProgressRect();
95 SAL_DLLPRIVATE
tools::Rectangle
ImplGetItemRectPos( sal_uInt16 nPos
) const;
96 SAL_DLLPRIVATE sal_uInt16
ImplGetFirstVisiblePos() const;
99 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
102 StatusBar( vcl::Window
* pParent
,
103 WinBits nWinStyle
= WB_BORDER
| WB_RIGHT
);
104 virtual ~StatusBar() override
;
105 virtual void dispose() override
;
107 void AdjustItemWidthsForHiDPI();
109 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
110 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
111 virtual void Resize() override
;
112 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
113 virtual void StateChanged( StateChangedType nType
) override
;
114 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
118 virtual void UserDraw( const UserDrawEvent
& rUDEvt
);
120 void InsertItem( sal_uInt16 nItemId
, sal_uLong nWidth
,
121 StatusBarItemBits nBits
= StatusBarItemBits::Center
| StatusBarItemBits::In
,
122 long nOffset
= STATUSBAR_OFFSET
,
123 sal_uInt16 nPos
= STATUSBAR_APPEND
);
124 void RemoveItem( sal_uInt16 nItemId
);
126 void ShowItem( sal_uInt16 nItemId
);
127 void HideItem( sal_uInt16 nItemId
);
128 bool IsItemVisible( sal_uInt16 nItemId
) const;
130 bool AreItemsVisible() const { return mbVisibleItems
; }
132 void RedrawItem( sal_uInt16 nItemId
);
136 sal_uInt16
GetItemCount() const;
137 sal_uInt16
GetItemId( sal_uInt16 nPos
) const;
138 sal_uInt16
GetItemId( const Point
& rPos
) const;
139 sal_uInt16
GetItemPos( sal_uInt16 nItemId
) const;
140 tools::Rectangle
GetItemRect( sal_uInt16 nItemId
) const;
141 Point
GetItemTextPos( sal_uInt16 nItemId
) const;
142 sal_uInt16
GetCurItemId() const { return mnCurItemId
; }
144 sal_uLong
GetItemWidth( sal_uInt16 nItemId
) const;
145 StatusBarItemBits
GetItemBits( sal_uInt16 nItemId
) const;
147 long GetItemOffset( sal_uInt16 nItemId
) const;
149 void SetItemText( sal_uInt16 nItemId
, const OUString
& rText
);
150 const OUString
& GetItemText( sal_uInt16 nItemId
) const;
152 void SetItemData( sal_uInt16 nItemId
, void* pNewData
);
153 void* GetItemData( sal_uInt16 nItemId
) const;
155 void SetItemCommand( sal_uInt16 nItemId
, const OUString
& rCommand
);
156 const OUString
GetItemCommand( sal_uInt16 nItemId
);
158 void SetHelpText( sal_uInt16 nItemId
, const OUString
& rText
);
159 const OUString
& GetHelpText( sal_uInt16 nItemId
) const;
161 using Window::SetQuickHelpText
;
162 void SetQuickHelpText( sal_uInt16 nItemId
, const OUString
& rText
);
163 using Window::GetQuickHelpText
;
164 const OUString
& GetQuickHelpText( sal_uInt16 nItemId
) const;
166 void SetHelpId( sal_uInt16 nItemId
, const OString
& rHelpId
);
167 OString
GetHelpId( sal_uInt16 nItemId
) const;
169 void StartProgressMode( const OUString
& rText
);
170 void SetProgressValue( sal_uInt16 nPercent
);
171 void EndProgressMode();
172 bool IsProgressMode() const { return mbProgressMode
; }
174 void SetText( const OUString
& rText
) override
;
176 Size
CalcWindowSizePixel() const;
178 void SetClickHdl( const Link
<StatusBar
*,void>& rLink
) { maClickHdl
= rLink
; }
179 void SetDoubleClickHdl( const Link
<StatusBar
*,void>& rLink
) { maDoubleClickHdl
= rLink
; }
181 using Window::SetAccessibleName
;
182 void SetAccessibleName( sal_uInt16 nItemId
, const OUString
& rName
);
183 using Window::GetAccessibleName
;
184 const OUString
& GetAccessibleName( sal_uInt16 nItemId
) const;
187 #endif // INCLUDED_VCL_STATUS_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */