Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_STATUS_HXX
30 : : #define _SV_STATUS_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <vcl/window.hxx>
35 : : #include <vector>
36 : :
37 : : struct ImplStatusItem;
38 : : typedef ::std::vector< ImplStatusItem* > ImplStatusItemList;
39 : :
40 : : // --------------------
41 : : // - Progress-Ausgabe -
42 : : // --------------------
43 : :
44 : : void VCL_DLLPUBLIC DrawProgress( Window* pWindow, const Point& rPos,
45 : : long nOffset, long nPrgsWidth, long nPrgsHeight,
46 : : sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
47 : : const Rectangle& rFramePosSize
48 : : );
49 : :
50 : : // ---------------------
51 : : // - StatusBarItemBits -
52 : : // ---------------------
53 : :
54 : : typedef sal_uInt16 StatusBarItemBits;
55 : :
56 : : // ----------------------------
57 : : // - Bits fuer StatusBarItems -
58 : : // ----------------------------
59 : :
60 : : #define SIB_LEFT ((StatusBarItemBits)0x0001)
61 : : #define SIB_CENTER ((StatusBarItemBits)0x0002)
62 : : #define SIB_RIGHT ((StatusBarItemBits)0x0004)
63 : : #define SIB_IN ((StatusBarItemBits)0x0008)
64 : : #define SIB_OUT ((StatusBarItemBits)0x0010)
65 : : #define SIB_FLAT ((StatusBarItemBits)0x0020)
66 : : #define SIB_AUTOSIZE ((StatusBarItemBits)0x0040)
67 : : #define SIB_USERDRAW ((StatusBarItemBits)0x0080)
68 : :
69 : : // -------------------
70 : : // - StatusBar-Types -
71 : : // -------------------
72 : :
73 : : #define STATUSBAR_APPEND ((sal_uInt16)0xFFFF)
74 : : #define STATUSBAR_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
75 : : #define STATUSBAR_OFFSET ((long)5)
76 : :
77 : : // -------------
78 : : // - StatusBar -
79 : : // -------------
80 : :
81 : : class VCL_DLLPUBLIC StatusBar : public Window
82 : : {
83 : : class ImplData;
84 : : private:
85 : : ImplStatusItemList* mpItemList;
86 : : ImplData* mpImplData;
87 : : XubString maPrgsTxt;
88 : : Point maPrgsTxtPos;
89 : : Rectangle maPrgsFrameRect;
90 : : long mnPrgsSize;
91 : : long mnItemsWidth;
92 : : long mnDX;
93 : : long mnDY;
94 : : long mnCalcHeight;
95 : : long mnTextY;
96 : : long mnItemY;
97 : : sal_uInt16 mnCurItemId;
98 : : sal_uInt16 mnPercent;
99 : : sal_uInt16 mnPercentCount;
100 : : sal_Bool mbVisibleItems;
101 : : sal_Bool mbFormat;
102 : : sal_Bool mbProgressMode;
103 : : sal_Bool mbInUserDraw;
104 : : Link maClickHdl;
105 : : Link maDoubleClickHdl;
106 : :
107 : : using Window::ImplInit;
108 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
109 : : SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
110 : : SAL_DLLPRIVATE void ImplFormat();
111 : : SAL_DLLPRIVATE sal_Bool ImplIsItemUpdate();
112 : : using OutputDevice::ImplDrawText;
113 : : SAL_DLLPRIVATE void ImplDrawText( sal_Bool bOffScreen, long nOldTextWidth );
114 : : SAL_DLLPRIVATE void ImplDrawItem( sal_Bool bOffScreen, sal_uInt16 nPos, sal_Bool bDrawText, sal_Bool bDrawFrame );
115 : : SAL_DLLPRIVATE void ImplDrawProgress( sal_Bool bPaint,
116 : : sal_uInt16 nOldPerc, sal_uInt16 nNewPerc );
117 : : SAL_DLLPRIVATE void ImplCalcProgressRect();
118 : : SAL_DLLPRIVATE Rectangle ImplGetItemRectPos( sal_uInt16 nPos ) const;
119 : : SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisiblePos() const;
120 : :
121 : : public:
122 : : StatusBar( Window* pParent,
123 : : WinBits nWinStyle = WB_BORDER | WB_RIGHT );
124 : : ~StatusBar();
125 : :
126 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
127 : : virtual void Paint( const Rectangle& rRect );
128 : : virtual void Move();
129 : : virtual void Resize();
130 : : virtual void RequestHelp( const HelpEvent& rHEvt );
131 : : virtual void StateChanged( StateChangedType nType );
132 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
133 : :
134 : : virtual void Click();
135 : : virtual void DoubleClick();
136 : : virtual void UserDraw( const UserDrawEvent& rUDEvt );
137 : :
138 : : void InsertItem( sal_uInt16 nItemId, sal_uLong nWidth,
139 : : StatusBarItemBits nBits = SIB_CENTER | SIB_IN,
140 : : long nOffset = STATUSBAR_OFFSET,
141 : : sal_uInt16 nPos = STATUSBAR_APPEND );
142 : :
143 : : sal_Bool IsItemVisible( sal_uInt16 nItemId ) const;
144 : 24840 : sal_Bool AreItemsVisible() const { return mbVisibleItems; }
145 : :
146 : : void Clear();
147 : :
148 : : sal_uInt16 GetItemCount() const;
149 : : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
150 : : sal_uInt16 GetItemId( const Point& rPos ) const;
151 : : sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const;
152 : : Rectangle GetItemRect( sal_uInt16 nItemId ) const;
153 : : Point GetItemTextPos( sal_uInt16 nItemId ) const;
154 : 0 : sal_uInt16 GetCurItemId() const { return mnCurItemId; }
155 : :
156 : : void SetItemText( sal_uInt16 nItemId, const XubString& rText );
157 : : const XubString& GetItemText( sal_uInt16 nItemId ) const;
158 : :
159 : : void SetItemData( sal_uInt16 nItemId, void* pNewData );
160 : :
161 : : void SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand );
162 : : const XubString& GetItemCommand( sal_uInt16 nItemId );
163 : :
164 : : void SetHelpText( sal_uInt16 nItemId, const XubString& rText );
165 : : const XubString& GetHelpText( sal_uInt16 nItemId ) const;
166 : :
167 : : using Window::SetQuickHelpText;
168 : : void SetQuickHelpText( sal_uInt16 nItemId, const XubString& rText );
169 : : using Window::GetQuickHelpText;
170 : : const XubString& GetQuickHelpText( sal_uInt16 nItemId ) const;
171 : :
172 : : void SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId );
173 : : rtl::OString GetHelpId( sal_uInt16 nItemId ) const;
174 : :
175 : : void StartProgressMode( const XubString& rText );
176 : : void SetProgressValue( sal_uInt16 nPercent );
177 : : void EndProgressMode();
178 : 14672 : sal_Bool IsProgressMode() const { return mbProgressMode; }
179 : :
180 : : void SetText( const XubString& rText );
181 : :
182 : : void SetHelpText( const XubString& rText )
183 : : { Window::SetHelpText( rText ); }
184 : : const XubString& GetHelpText() const
185 : : { return Window::GetHelpText(); }
186 : :
187 : : void SetHelpId( const rtl::OString& rId )
188 : : { Window::SetHelpId( rId ); }
189 : : const rtl::OString& GetHelpId() const
190 : : { return Window::GetHelpId(); }
191 : :
192 : : Size CalcWindowSizePixel() const;
193 : :
194 : 1741 : void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
195 : : const Link& GetClickHdl() const { return maClickHdl; }
196 : 1741 : void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
197 : : const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
198 : :
199 : : using Window::SetAccessibleName;
200 : : void SetAccessibleName( sal_uInt16 nItemId, const XubString& rName );
201 : : using Window::GetAccessibleName;
202 : : const XubString& GetAccessibleName( sal_uInt16 nItemId ) const;
203 : : };
204 : :
205 : : #endif // _SV_STATUS_HXX
206 : :
207 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|