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