xref: /trunk/main/vcl/inc/vcl/status.hxx (revision 7d6e33b2)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_STATUS_HXX
25 #define _SV_STATUS_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/dllapi.h>
29 #include <vcl/window.hxx>
30 
31 class ImplStatusItemList;
32 
33 // --------------------
34 // - Progress-Ausgabe -
35 // --------------------
36 
37 void VCL_DLLPUBLIC DrawProgress( Window* pWindow, const Point& rPos,
38                                  long nOffset, long nPrgsWidth, long nPrgsHeight,
39                                  sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
40                                  const Rectangle& rFramePosSize
41                                  );
42 
43 // ---------------------
44 // - StatusBarItemBits -
45 // ---------------------
46 
47 typedef sal_uInt16 StatusBarItemBits;
48 
49 // ----------------------------
50 // - Bits fuer StatusBarItems -
51 // ----------------------------
52 
53 #define SIB_LEFT					((StatusBarItemBits)0x0001)
54 #define SIB_CENTER					((StatusBarItemBits)0x0002)
55 #define SIB_RIGHT					((StatusBarItemBits)0x0004)
56 #define SIB_IN						((StatusBarItemBits)0x0008)
57 #define SIB_OUT 					((StatusBarItemBits)0x0010)
58 #define SIB_FLAT					((StatusBarItemBits)0x0020)
59 #define SIB_AUTOSIZE				((StatusBarItemBits)0x0040)
60 #define SIB_USERDRAW				((StatusBarItemBits)0x0080)
61 
62 // -------------------
63 // - StatusBar-Types -
64 // -------------------
65 
66 #define STATUSBAR_APPEND			((sal_uInt16)0xFFFF)
67 #define STATUSBAR_ITEM_NOTFOUND 	((sal_uInt16)0xFFFF)
68 #define STATUSBAR_OFFSET			((long)5)
69 
70 // -------------
71 // - StatusBar -
72 // -------------
73 
74 class VCL_DLLPUBLIC StatusBar : public Window
75 {
76     class   ImplData;
77 private:
78 	ImplStatusItemList* mpItemList;
79     ImplData*           mpImplData;
80 	XubString			maPrgsTxt;
81 	Point				maPrgsTxtPos;
82 	Rectangle			maPrgsFrameRect;
83 	long				mnPrgsSize;
84 	long				mnItemsWidth;
85 	long				mnDX;
86 	long				mnDY;
87 	long				mnCalcHeight;
88 	long				mnTextY;
89 	long				mnItemY;
90 	sal_uInt16				mnCurItemId;
91 	sal_uInt16				mnPercent;
92 	sal_uInt16				mnPercentCount;
93 	sal_Bool				mbVisibleItems;
94 	sal_Bool				mbFormat;
95 	sal_Bool				mbProgressMode;
96 	sal_Bool				mbInUserDraw;
97 	sal_Bool				mbBottomBorder;
98 	Link				maClickHdl;
99 	Link				maDoubleClickHdl;
100 
101     using Window::ImplInit;
102 	SAL_DLLPRIVATE void		 ImplInit( Window* pParent, WinBits nStyle );
103 	SAL_DLLPRIVATE void		 ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
104 	SAL_DLLPRIVATE void		 ImplFormat();
105 	SAL_DLLPRIVATE sal_Bool		 ImplIsItemUpdate();
106 //    #if 0 // _SOLAR__PRIVATE
107     using OutputDevice::ImplDrawText;
108 //    #endif
109 	SAL_DLLPRIVATE void		 ImplDrawText( sal_Bool bOffScreen, long nOldTextWidth );
110 	SAL_DLLPRIVATE void		 ImplDrawItem( sal_Bool bOffScreen, sal_uInt16 nPos, sal_Bool bDrawText, sal_Bool bDrawFrame );
111 	SAL_DLLPRIVATE void		 ImplDrawProgress( sal_Bool bPaint,
112                                                sal_uInt16 nOldPerc, sal_uInt16 nNewPerc );
113 	SAL_DLLPRIVATE void		 ImplCalcProgressRect();
114 	SAL_DLLPRIVATE Rectangle ImplGetItemRectPos( sal_uInt16 nPos ) const;
115     SAL_DLLPRIVATE sal_uInt16    ImplGetFirstVisiblePos() const;
116     SAL_DLLPRIVATE void      ImplCalcBorder();
117 
118 public:
119 						StatusBar( Window* pParent,
120 								   WinBits nWinStyle = WB_BORDER | WB_RIGHT );
121 						StatusBar( Window* pParent, const ResId& rResId );
122 						~StatusBar();
123 
124 	virtual void		MouseButtonDown( const MouseEvent& rMEvt );
125 	virtual void		Paint( const Rectangle& rRect );
126 	virtual void		Move();
127 	virtual void		Resize();
128 	virtual void		RequestHelp( const HelpEvent& rHEvt );
129 	virtual void		StateChanged( StateChangedType nType );
130 	virtual void		DataChanged( const DataChangedEvent& rDCEvt );
131 
132 	virtual void		Click();
133 	virtual void		DoubleClick();
134 	virtual void		UserDraw( const UserDrawEvent& rUDEvt );
135 
136 	void				InsertItem( sal_uInt16 nItemId, sal_uLong nWidth,
137 									StatusBarItemBits nBits = SIB_CENTER | SIB_IN,
138 									long nOffset = STATUSBAR_OFFSET,
139 									sal_uInt16 nPos = STATUSBAR_APPEND );
140 	void				RemoveItem( sal_uInt16 nItemId );
141 
142 	void				ShowItem( sal_uInt16 nItemId );
143 	void				HideItem( sal_uInt16 nItemId );
144 	sal_Bool				IsItemVisible( sal_uInt16 nItemId ) const;
145 
146 	void				ShowItems();
147 	void				HideItems();
AreItemsVisible() const148 	sal_Bool				AreItemsVisible() const { return mbVisibleItems; }
149 
150     void                RedrawItem( sal_uInt16 nItemId );
151 
152 	void				CopyItems( const StatusBar& rStatusBar );
153 	void				Clear();
154 
155 	sal_uInt16				GetItemCount() const;
156 	sal_uInt16				GetItemId( sal_uInt16 nPos ) const;
157 	sal_uInt16				GetItemId( const Point& rPos ) const;
158 	sal_uInt16				GetItemPos( sal_uInt16 nItemId ) const;
159 	Rectangle			GetItemRect( sal_uInt16 nItemId ) const;
160 	Point				GetItemTextPos( sal_uInt16 nItemId ) const;
GetCurItemId() const161 	sal_uInt16				GetCurItemId() const { return mnCurItemId; }
162 
163 	sal_uLong				GetItemWidth( sal_uInt16 nItemId ) const;
164 	StatusBarItemBits	GetItemBits( sal_uInt16 nItemId ) const;
165 	long				GetItemOffset( sal_uInt16 nItemId ) const;
166 
167 	void				SetItemText( sal_uInt16 nItemId, const XubString& rText );
168 	const XubString& 	GetItemText( sal_uInt16 nItemId ) const;
169 
170 	void				SetItemData( sal_uInt16 nItemId, void* pNewData );
171 	void*				GetItemData( sal_uInt16 nItemId ) const;
172 
173     void                SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand );
174     const XubString&    GetItemCommand( sal_uInt16 nItemId );
175 
176 	void				SetHelpText( sal_uInt16 nItemId, const XubString& rText );
177 	const XubString& 	GetHelpText( sal_uInt16 nItemId ) const;
178 
179     using Window::SetQuickHelpText;
180     void                SetQuickHelpText( sal_uInt16 nItemId, const XubString& rText );
181     using Window::GetQuickHelpText;
182     const XubString&    GetQuickHelpText( sal_uInt16 nItemId ) const;
183 
184 	void				SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId );
185 	rtl::OString        GetHelpId( sal_uInt16 nItemId ) const;
186 
187 	void				SetBottomBorder( sal_Bool bBottomBorder = sal_True );
IsBottomBorder() const188 	sal_Bool				IsBottomBorder() const { return mbBottomBorder; }
189 
190 	void				SetTopBorder( sal_Bool bTopBorder = sal_True );
191 	sal_Bool				IsTopBorder() const;
192 
193 	void				StartProgressMode( const XubString& rText );
194 	void				SetProgressValue( sal_uInt16 nPercent );
195 	void				EndProgressMode();
IsProgressMode() const196 	sal_Bool				IsProgressMode() const { return mbProgressMode; }
197 	void				ResetProgressMode();
198 
199 	void				SetText( const XubString& rText );
200 
SetHelpText(const XubString & rText)201 	void				SetHelpText( const XubString& rText )
202 							{ Window::SetHelpText( rText ); }
GetHelpText() const203 	const XubString& 	GetHelpText() const
204 							{ return Window::GetHelpText(); }
205 
SetHelpId(const rtl::OString & rId)206     void				SetHelpId( const rtl::OString& rId )
207 							{ Window::SetHelpId( rId ); }
GetHelpId() const208     const rtl::OString&	GetHelpId() const
209 							{ return Window::GetHelpId(); }
210 
211 	Size				CalcWindowSizePixel() const;
212 
SetClickHdl(const Link & rLink)213 	void				SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
GetClickHdl() const214 	const Link& 		GetClickHdl() const { return maClickHdl; }
SetDoubleClickHdl(const Link & rLink)215 	void				SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
GetDoubleClickHdl() const216 	const Link& 		GetDoubleClickHdl() const { return maDoubleClickHdl; }
217 
218     using Window::SetAccessibleName;
219 	void				SetAccessibleName( sal_uInt16 nItemId, const XubString& rName );
220     using Window::GetAccessibleName;
221 	const XubString& 	GetAccessibleName( sal_uInt16 nItemId ) const;
222 };
223 
224 #endif	// _SV_STATUS_HXX
225