Line data Source code
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 _SV_STATUS_HXX
21 : #define _SV_STATUS_HXX
22 :
23 : #include <tools/solar.h>
24 : #include <vcl/dllapi.h>
25 : #include <vcl/window.hxx>
26 : #include <vector>
27 :
28 : struct ImplStatusItem;
29 : typedef ::std::vector< ImplStatusItem* > ImplStatusItemList;
30 :
31 : // --------------------
32 : // - Progress-Ausgabe -
33 : // --------------------
34 :
35 : void VCL_DLLPUBLIC DrawProgress( Window* pWindow, const Point& rPos,
36 : long nOffset, long nPrgsWidth, long nPrgsHeight,
37 : sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
38 : const Rectangle& rFramePosSize
39 : );
40 :
41 : // ---------------------
42 : // - StatusBarItemBits -
43 : // ---------------------
44 :
45 : typedef sal_uInt16 StatusBarItemBits;
46 :
47 : // ----------------------------
48 : // - Bits fuer StatusBarItems -
49 : // ----------------------------
50 :
51 : #define SIB_LEFT ((StatusBarItemBits)0x0001)
52 : #define SIB_CENTER ((StatusBarItemBits)0x0002)
53 : #define SIB_RIGHT ((StatusBarItemBits)0x0004)
54 : #define SIB_IN ((StatusBarItemBits)0x0008)
55 : #define SIB_OUT ((StatusBarItemBits)0x0010)
56 : #define SIB_FLAT ((StatusBarItemBits)0x0020)
57 : #define SIB_AUTOSIZE ((StatusBarItemBits)0x0040)
58 : #define SIB_USERDRAW ((StatusBarItemBits)0x0080)
59 :
60 : // -------------------
61 : // - StatusBar-Types -
62 : // -------------------
63 :
64 : #define STATUSBAR_APPEND ((sal_uInt16)0xFFFF)
65 : #define STATUSBAR_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
66 : #define STATUSBAR_OFFSET ((long)5)
67 :
68 : // -------------
69 : // - StatusBar -
70 : // -------------
71 :
72 : class VCL_DLLPUBLIC StatusBar : public Window
73 : {
74 : class ImplData;
75 : private:
76 : ImplStatusItemList* mpItemList;
77 : ImplData* mpImplData;
78 : XubString maPrgsTxt;
79 : Point maPrgsTxtPos;
80 : Rectangle maPrgsFrameRect;
81 : long mnPrgsSize;
82 : long mnItemsWidth;
83 : long mnDX;
84 : long mnDY;
85 : long mnCalcHeight;
86 : long mnTextY;
87 : long mnItemY;
88 : sal_uInt16 mnCurItemId;
89 : sal_uInt16 mnPercent;
90 : sal_uInt16 mnPercentCount;
91 : sal_Bool mbVisibleItems;
92 : sal_Bool mbFormat;
93 : sal_Bool mbProgressMode;
94 : sal_Bool mbInUserDraw;
95 : Link maClickHdl;
96 : Link maDoubleClickHdl;
97 :
98 : using Window::ImplInit;
99 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
100 : SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
101 : SAL_DLLPRIVATE void ImplFormat();
102 : SAL_DLLPRIVATE sal_Bool ImplIsItemUpdate();
103 : using OutputDevice::ImplDrawText;
104 : SAL_DLLPRIVATE void ImplDrawText( sal_Bool bOffScreen, long nOldTextWidth );
105 : SAL_DLLPRIVATE void ImplDrawItem( sal_Bool bOffScreen, sal_uInt16 nPos, sal_Bool bDrawText, sal_Bool bDrawFrame );
106 : SAL_DLLPRIVATE void ImplDrawProgress( sal_Bool bPaint,
107 : sal_uInt16 nOldPerc, sal_uInt16 nNewPerc );
108 : SAL_DLLPRIVATE void ImplCalcProgressRect();
109 : SAL_DLLPRIVATE Rectangle ImplGetItemRectPos( sal_uInt16 nPos ) const;
110 : SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisiblePos() const;
111 :
112 : public:
113 : StatusBar( Window* pParent,
114 : WinBits nWinStyle = WB_BORDER | WB_RIGHT );
115 : ~StatusBar();
116 :
117 : virtual void MouseButtonDown( const MouseEvent& rMEvt );
118 : virtual void Paint( const Rectangle& rRect );
119 : virtual void Move();
120 : virtual void Resize();
121 : virtual void RequestHelp( const HelpEvent& rHEvt );
122 : virtual void StateChanged( StateChangedType nType );
123 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
124 :
125 : virtual void Click();
126 : virtual void DoubleClick();
127 : virtual void UserDraw( const UserDrawEvent& rUDEvt );
128 :
129 : void InsertItem( sal_uInt16 nItemId, sal_uLong nWidth,
130 : StatusBarItemBits nBits = SIB_CENTER | SIB_IN,
131 : long nOffset = STATUSBAR_OFFSET,
132 : sal_uInt16 nPos = STATUSBAR_APPEND );
133 :
134 : sal_Bool IsItemVisible( sal_uInt16 nItemId ) const;
135 0 : sal_Bool AreItemsVisible() const { return mbVisibleItems; }
136 :
137 : void Clear();
138 :
139 : sal_uInt16 GetItemCount() const;
140 : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
141 : sal_uInt16 GetItemId( const Point& rPos ) const;
142 : sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const;
143 : Rectangle GetItemRect( sal_uInt16 nItemId ) const;
144 : Point GetItemTextPos( sal_uInt16 nItemId ) const;
145 0 : sal_uInt16 GetCurItemId() const { return mnCurItemId; }
146 :
147 : void SetItemText( sal_uInt16 nItemId, const XubString& rText );
148 : const XubString& GetItemText( sal_uInt16 nItemId ) const;
149 :
150 : void SetItemData( sal_uInt16 nItemId, void* pNewData );
151 :
152 : void SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand );
153 : const XubString& GetItemCommand( sal_uInt16 nItemId );
154 :
155 : void SetHelpText( sal_uInt16 nItemId, const XubString& rText );
156 : const XubString& GetHelpText( sal_uInt16 nItemId ) const;
157 :
158 : using Window::SetQuickHelpText;
159 : void SetQuickHelpText( sal_uInt16 nItemId, const XubString& rText );
160 : using Window::GetQuickHelpText;
161 : const XubString& GetQuickHelpText( sal_uInt16 nItemId ) const;
162 :
163 : void SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId );
164 : rtl::OString GetHelpId( sal_uInt16 nItemId ) const;
165 :
166 : void StartProgressMode( const XubString& rText );
167 : void SetProgressValue( sal_uInt16 nPercent );
168 : void EndProgressMode();
169 5493 : sal_Bool IsProgressMode() const { return mbProgressMode; }
170 :
171 : void SetText( const XubString& rText );
172 :
173 : void SetHelpText( const XubString& rText )
174 : { Window::SetHelpText( rText ); }
175 : const XubString& GetHelpText() const
176 : { return Window::GetHelpText(); }
177 :
178 : void SetHelpId( const rtl::OString& rId )
179 : { Window::SetHelpId( rId ); }
180 : const rtl::OString& GetHelpId() const
181 : { return Window::GetHelpId(); }
182 :
183 : Size CalcWindowSizePixel() const;
184 :
185 236 : void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
186 : const Link& GetClickHdl() const { return maClickHdl; }
187 236 : void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
188 : const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
189 :
190 : using Window::SetAccessibleName;
191 : void SetAccessibleName( sal_uInt16 nItemId, const XubString& rName );
192 : using Window::GetAccessibleName;
193 : const XubString& GetAccessibleName( sal_uInt16 nItemId ) const;
194 : };
195 :
196 : #endif // _SV_STATUS_HXX
197 :
198 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|