xref: /aoo41x/main/vcl/inc/brdwin.hxx (revision ebfcd9af)
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_BRDWIN_HXX
25 #define _SV_BRDWIN_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/window.hxx>
29 
30 class ImplBorderWindowView;
31 
32 // --------------------------
33 // - ImplBorderWindow-Types -
34 // --------------------------
35 
36 #define BORDERWINDOW_STYLE_OVERLAP			((sal_uInt16)0x0001)
37 #define BORDERWINDOW_STYLE_BORDER			((sal_uInt16)0x0002)
38 #define BORDERWINDOW_STYLE_FLOAT			((sal_uInt16)0x0004)
39 #define BORDERWINDOW_STYLE_FRAME			((sal_uInt16)0x0008)
40 #define BORDERWINDOW_STYLE_APP				((sal_uInt16)0x0010)
41 
42 #define BORDERWINDOW_HITTEST_TITLE			((sal_uInt16)0x0001)
43 #define BORDERWINDOW_HITTEST_LEFT			((sal_uInt16)0x0002)
44 #define BORDERWINDOW_HITTEST_MENU			((sal_uInt16)0x0004)
45 #define BORDERWINDOW_HITTEST_TOP			((sal_uInt16)0x0008)
46 #define BORDERWINDOW_HITTEST_RIGHT			((sal_uInt16)0x0010)
47 #define BORDERWINDOW_HITTEST_BOTTOM 		((sal_uInt16)0x0020)
48 #define BORDERWINDOW_HITTEST_TOPLEFT		((sal_uInt16)0x0040)
49 #define BORDERWINDOW_HITTEST_TOPRIGHT		((sal_uInt16)0x0080)
50 #define BORDERWINDOW_HITTEST_BOTTOMLEFT 	((sal_uInt16)0x0100)
51 #define BORDERWINDOW_HITTEST_BOTTOMRIGHT	((sal_uInt16)0x0200)
52 #define BORDERWINDOW_HITTEST_CLOSE			((sal_uInt16)0x0400)
53 #define BORDERWINDOW_HITTEST_ROLL			((sal_uInt16)0x0800)
54 #define BORDERWINDOW_HITTEST_DOCK			((sal_uInt16)0x1000)
55 #define BORDERWINDOW_HITTEST_HIDE			((sal_uInt16)0x2000)
56 #define BORDERWINDOW_HITTEST_HELP			((sal_uInt16)0x4000)
57 #define BORDERWINDOW_HITTEST_PIN			((sal_uInt16)0x8000)
58 
59 #define BORDERWINDOW_DRAW_TITLE 			((sal_uInt16)0x0001)
60 #define BORDERWINDOW_DRAW_BORDER			((sal_uInt16)0x0002)
61 #define BORDERWINDOW_DRAW_FRAME 			((sal_uInt16)0x0004)
62 #define BORDERWINDOW_DRAW_CLOSE 			((sal_uInt16)0x0008)
63 #define BORDERWINDOW_DRAW_ROLL				((sal_uInt16)0x0010)
64 #define BORDERWINDOW_DRAW_DOCK				((sal_uInt16)0x0020)
65 #define BORDERWINDOW_DRAW_HIDE				((sal_uInt16)0x0040)
66 #define BORDERWINDOW_DRAW_HELP				((sal_uInt16)0x0080)
67 #define BORDERWINDOW_DRAW_PIN				((sal_uInt16)0x0100)
68 #define BORDERWINDOW_DRAW_MENU				((sal_uInt16)0x0200)
69 #define BORDERWINDOW_DRAW_ALL				(BORDERWINDOW_DRAW_TITLE |		\
70 											 BORDERWINDOW_DRAW_BORDER | 	\
71 											 BORDERWINDOW_DRAW_FRAME |		\
72 											 BORDERWINDOW_DRAW_CLOSE |		\
73 											 BORDERWINDOW_DRAW_ROLL |		\
74 											 BORDERWINDOW_DRAW_DOCK |		\
75 											 BORDERWINDOW_DRAW_HIDE |		\
76 											 BORDERWINDOW_DRAW_HELP |		\
77 											 BORDERWINDOW_DRAW_PIN  |		\
78 											 BORDERWINDOW_DRAW_MENU)
79 
80 #define BORDERWINDOW_TITLE_NORMAL			((sal_uInt16)0x0001)
81 #define BORDERWINDOW_TITLE_SMALL			((sal_uInt16)0x0002)
82 #define BORDERWINDOW_TITLE_TEAROFF			((sal_uInt16)0x0004)
83 #define BORDERWINDOW_TITLE_NONE 			((sal_uInt16)0x0008)
84 
85 // --------------------
86 // - ImplBorderWindow -
87 // --------------------
88 
89 class ImplBorderWindow : public Window
90 {
91 	friend class Window;
92 	friend class ImplBorderWindowView;
93 	friend class ImplSmallBorderWindowView;
94 	friend class ImplStdBorderWindowView;
95 
96 private:
97 	ImplBorderWindowView*	mpBorderView;
98 	Window* 				mpMenuBarWindow;
99 	long					mnMinWidth;
100 	long					mnMinHeight;
101 	long					mnMaxWidth;
102 	long					mnMaxHeight;
103 	long					mnRollHeight;
104 	long					mnOrgMenuHeight;
105 	sal_uInt16					mnTitleType;
106 	sal_uInt16					mnBorderStyle;
107 	sal_Bool					mbFloatWindow;
108 	sal_Bool					mbSmallOutBorder;
109 	sal_Bool					mbFrameBorder;
110 	sal_Bool					mbPined;
111 	sal_Bool					mbRollUp;
112 	sal_Bool					mbMenuHide;
113 	sal_Bool					mbDockBtn;
114 	sal_Bool					mbHideBtn;
115 	sal_Bool					mbHelpBtn;
116     sal_Bool                    mbMenuBtn;
117 	sal_Bool					mbDisplayActive;
118 
119     using Window::ImplInit;
120 	void					ImplInit( Window* pParent,
121 									  WinBits nStyle, sal_uInt16 nTypeStyle,
122 									  SystemParentData* pParentData );
123 	void					ImplInit( Window* pParent,
124 									  WinBits nStyle, sal_uInt16 nTypeStyle,
125 									  const ::com::sun::star::uno::Any& );
126 
127                             // Copy assignment is forbidden and not implemented.
128 	                        ImplBorderWindow (const ImplBorderWindow &);
129                             ImplBorderWindow& operator= (const ImplBorderWindow &);
130 
131 public:
132 							ImplBorderWindow( Window* pParent,
133 											  SystemParentData* pParentData,
134 											  WinBits nStyle = 0,
135 											  sal_uInt16 nTypeStyle = 0 );
136 							ImplBorderWindow( Window* pParent, WinBits nStyle = 0,
137 											  sal_uInt16 nTypeStyle = 0 );
138 							ImplBorderWindow( Window* pParent,
139 											  WinBits nStyle, sal_uInt16 nTypeStyle,
140 											  const ::com::sun::star::uno::Any& );
141 							~ImplBorderWindow();
142 
143 	virtual void			MouseMove( const MouseEvent& rMEvt );
144 	virtual void			MouseButtonDown( const MouseEvent& rMEvt );
145 	virtual void			Tracking( const TrackingEvent& rTEvt );
146 	virtual void			Paint( const Rectangle& rRect );
147 	virtual void			Activate();
148 	virtual void			Deactivate();
149 	virtual void			Resize();
150 	virtual void			RequestHelp( const HelpEvent& rHEvt );
151 	virtual void			StateChanged( StateChangedType nType );
152 	virtual void			DataChanged( const DataChangedEvent& rDCEvt );
153 
154 	void					InitView();
155 	void					UpdateView( sal_Bool bNewView, const Size& rNewOutSize );
156 	void					InvalidateBorder();
157 
158     using Window::Draw;
159 	void					Draw( const Rectangle& rRect, OutputDevice* pDev, const Point& rPos );
160 
161 	void					SetDisplayActive( sal_Bool bActive );
IsDisplayActive() const162 	sal_Bool					IsDisplayActive() const { return mbDisplayActive; }
163 	void					SetTitleType( sal_uInt16 nTitleType, const Size& rSize );
164 	void					SetBorderStyle( sal_uInt16 nStyle );
GetBorderStyle() const165 	sal_uInt16					GetBorderStyle() const { return mnBorderStyle; }
166 	void					SetPin( sal_Bool bPin );
167 	void					SetRollUp( sal_Bool bRollUp, const Size& rSize );
168 	void					SetCloser();
169 	void					SetDockButton( sal_Bool bDockButton );
170 	void					SetHideButton( sal_Bool bHideButton );
171 	void					SetHelpButton( sal_Bool bHelpButton );
172 	void					SetMenuButton( sal_Bool bMenuButton );
173 
174 	void					UpdateMenuHeight();
175 	void					SetMenuBarWindow( Window* pWindow );
176 	void					SetMenuBarMode( sal_Bool bHide );
177 
SetMinOutputSize(long nWidth,long nHeight)178 	void					SetMinOutputSize( long nWidth, long nHeight )
179 								{ mnMinWidth = nWidth; mnMinHeight = nHeight; }
SetMaxOutputSize(long nWidth,long nHeight)180 	void					SetMaxOutputSize( long nWidth, long nHeight )
181 								{ mnMaxWidth = nWidth; mnMaxHeight = nHeight; }
182 
183 	void					GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
184 									   sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
185 	long					CalcTitleWidth() const;
186 
187     Rectangle               GetMenuRect() const;
188 };
189 
190 // =======================================================================
191 
192 // -----------------------
193 // - ImplBorderFrameData -
194 // -----------------------
195 
196 struct ImplBorderFrameData
197 {
198 	ImplBorderWindow*		mpBorderWindow;
199 	OutputDevice*			mpOutDev;
200 	Rectangle				maTitleRect;
201 	Rectangle				maPinRect;
202 	Rectangle				maCloseRect;
203 	Rectangle				maRollRect;
204 	Rectangle				maDockRect;
205 	Rectangle				maMenuRect;
206 	Rectangle				maHideRect;
207 	Rectangle				maHelpRect;
208 	Point					maMouseOff;
209 	long					mnWidth;
210 	long					mnHeight;
211 	long					mnTrackX;
212 	long					mnTrackY;
213 	long					mnTrackWidth;
214 	long					mnTrackHeight;
215 	sal_Int32				mnLeftBorder;
216 	sal_Int32				mnTopBorder;
217 	sal_Int32				mnRightBorder;
218 	sal_Int32				mnBottomBorder;
219 	long					mnNoTitleTop;
220 	long					mnBorderSize;
221 	long					mnTitleHeight;
222 	long					mnTitleOff;
223 	sal_uInt16					mnHitTest;
224 	sal_uInt16					mnPinState;
225 	sal_uInt16					mnCloseState;
226 	sal_uInt16					mnRollState;
227 	sal_uInt16					mnDockState;
228 	sal_uInt16					mnMenuState;
229 	sal_uInt16					mnHideState;
230 	sal_uInt16					mnHelpState;
231 	sal_uInt16					mnTitleType;
232 	sal_Bool					mbFloatWindow;
233 	sal_Bool					mbDragFull;
234     sal_Bool                    mbTitleClipped;
235 };
236 
237 // =======================================================================
238 
239 // ------------------------
240 // - ImplBorderWindowView -
241 // ------------------------
242 
243 class ImplBorderWindowView
244 {
245 public:
246 	virtual 				~ImplBorderWindowView();
247 
248 	virtual sal_Bool			MouseMove( const MouseEvent& rMEvt );
249 	virtual sal_Bool			MouseButtonDown( const MouseEvent& rMEvt );
250 	virtual sal_Bool			Tracking( const TrackingEvent& rTEvt );
251 	virtual String  		RequestHelp( const Point& rPos, Rectangle& rHelpRect );
252 
253 	virtual void			Init( OutputDevice* pDev, long nWidth, long nHeight ) = 0;
254 	virtual void			GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
255 									   sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0;
256 	virtual long			CalcTitleWidth() const = 0;
257 	virtual void			DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev = NULL, const Point* pOffset = NULL ) = 0;
258 	virtual Rectangle       GetMenuRect() const;
259 
260 	void					ImplInitTitle( ImplBorderFrameData* pData );
261 	sal_uInt16					ImplHitTest( ImplBorderFrameData* pData, const Point& rPos );
262 	sal_Bool					ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
263 	sal_Bool					ImplMouseButtonDown( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
264 	sal_Bool					ImplTracking( ImplBorderFrameData* pData, const TrackingEvent& rTEvt );
265 	String					ImplRequestHelp( ImplBorderFrameData* pData, const Point& rPos, Rectangle& rHelpRect );
266 	long					ImplCalcTitleWidth( const ImplBorderFrameData* pData ) const;
267 };
268 
269 // =======================================================================
270 
271 // --------------------------
272 // - ImplNoBorderWindowView -
273 // --------------------------
274 
275 class ImplNoBorderWindowView : public ImplBorderWindowView
276 {
277 public:
278 							ImplNoBorderWindowView( ImplBorderWindow* pBorderWindow );
279 
280 	virtual void			Init( OutputDevice* pDev, long nWidth, long nHeight );
281 	virtual void			GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
282 									   sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
283 	virtual long			CalcTitleWidth() const;
284 	virtual void			DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset );
285 };
286 
287 
288 // =======================================================================
289 
290 // -----------------------------
291 // - ImplSmallBorderWindowView -
292 // -----------------------------
293 
294 class ImplSmallBorderWindowView : public ImplBorderWindowView
295 {
296 	ImplBorderWindow*		mpBorderWindow;
297 	OutputDevice*			mpOutDev;
298 	long					mnWidth;
299 	long					mnHeight;
300 	sal_Int32				mnLeftBorder;
301 	sal_Int32				mnTopBorder;
302 	sal_Int32				mnRightBorder;
303 	sal_Int32				mnBottomBorder;
304     bool                    mbNWFBorder;
305 
306 public:
307 							ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow );
308 
309 	virtual void			Init( OutputDevice* pOutDev, long nWidth, long nHeight );
310 	virtual void			GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
311 									   sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
312 	virtual long			CalcTitleWidth() const;
313 	virtual void			DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset );
314 };
315 
316 
317 // =======================================================================
318 
319 // ---------------------------
320 // - ImplStdBorderWindowView -
321 // ---------------------------
322 
323 
324 class ImplStdBorderWindowView : public ImplBorderWindowView
325 {
326 	ImplBorderFrameData 	maFrameData;
327 	VirtualDevice*			mpATitleVirDev;
328 	VirtualDevice*			mpDTitleVirDev;
329 
330 public:
331 							ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow );
332 							~ImplStdBorderWindowView();
333 
334 	virtual sal_Bool			MouseMove( const MouseEvent& rMEvt );
335 	virtual sal_Bool			MouseButtonDown( const MouseEvent& rMEvt );
336 	virtual sal_Bool			Tracking( const TrackingEvent& rTEvt );
337 	virtual String  		RequestHelp( const Point& rPos, Rectangle& rHelpRect );
338 	virtual Rectangle       GetMenuRect() const;
339 
340 	virtual void			Init( OutputDevice* pDev, long nWidth, long nHeight );
341 	virtual void			GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
342 									   sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
343 	virtual long			CalcTitleWidth() const;
344 	virtual void			DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset );
345 };
346 
347 
348 #endif	// _SV_BRDWIN_HXX
349