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