1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_BRDWIN_HXX
21 #define INCLUDED_VCL_INC_BRDWIN_HXX
23 #include <vcl/window.hxx>
25 class ImplBorderWindowView
;
26 enum class DrawButtonFlags
;
28 #define BORDERWINDOW_STYLE_OVERLAP ((sal_uInt16)0x0001)
29 #define BORDERWINDOW_STYLE_BORDER ((sal_uInt16)0x0002)
30 #define BORDERWINDOW_STYLE_FLOAT ((sal_uInt16)0x0004)
31 #define BORDERWINDOW_STYLE_FRAME ((sal_uInt16)0x0008)
32 #define BORDERWINDOW_STYLE_APP ((sal_uInt16)0x0010)
34 #define BORDERWINDOW_HITTEST_TITLE ((sal_uInt16)0x0001)
35 #define BORDERWINDOW_HITTEST_LEFT ((sal_uInt16)0x0002)
36 #define BORDERWINDOW_HITTEST_MENU ((sal_uInt16)0x0004)
37 #define BORDERWINDOW_HITTEST_TOP ((sal_uInt16)0x0008)
38 #define BORDERWINDOW_HITTEST_RIGHT ((sal_uInt16)0x0010)
39 #define BORDERWINDOW_HITTEST_BOTTOM ((sal_uInt16)0x0020)
40 #define BORDERWINDOW_HITTEST_TOPLEFT ((sal_uInt16)0x0040)
41 #define BORDERWINDOW_HITTEST_TOPRIGHT ((sal_uInt16)0x0080)
42 #define BORDERWINDOW_HITTEST_BOTTOMLEFT ((sal_uInt16)0x0100)
43 #define BORDERWINDOW_HITTEST_BOTTOMRIGHT ((sal_uInt16)0x0200)
44 #define BORDERWINDOW_HITTEST_CLOSE ((sal_uInt16)0x0400)
45 #define BORDERWINDOW_HITTEST_ROLL ((sal_uInt16)0x0800)
46 #define BORDERWINDOW_HITTEST_DOCK ((sal_uInt16)0x1000)
47 #define BORDERWINDOW_HITTEST_HIDE ((sal_uInt16)0x2000)
48 #define BORDERWINDOW_HITTEST_HELP ((sal_uInt16)0x4000)
49 #define BORDERWINDOW_HITTEST_PIN ((sal_uInt16)0x8000)
51 #define BORDERWINDOW_DRAW_TITLE ((sal_uInt16)0x0001)
52 #define BORDERWINDOW_DRAW_BORDER ((sal_uInt16)0x0002)
53 #define BORDERWINDOW_DRAW_FRAME ((sal_uInt16)0x0004)
54 #define BORDERWINDOW_DRAW_CLOSE ((sal_uInt16)0x0008)
55 #define BORDERWINDOW_DRAW_ROLL ((sal_uInt16)0x0010)
56 #define BORDERWINDOW_DRAW_DOCK ((sal_uInt16)0x0020)
57 #define BORDERWINDOW_DRAW_HIDE ((sal_uInt16)0x0040)
58 #define BORDERWINDOW_DRAW_HELP ((sal_uInt16)0x0080)
59 #define BORDERWINDOW_DRAW_PIN ((sal_uInt16)0x0100)
60 #define BORDERWINDOW_DRAW_MENU ((sal_uInt16)0x0200)
61 #define BORDERWINDOW_DRAW_ALL (BORDERWINDOW_DRAW_TITLE | \
62 BORDERWINDOW_DRAW_BORDER | \
63 BORDERWINDOW_DRAW_FRAME | \
64 BORDERWINDOW_DRAW_CLOSE | \
65 BORDERWINDOW_DRAW_ROLL | \
66 BORDERWINDOW_DRAW_DOCK | \
67 BORDERWINDOW_DRAW_HIDE | \
68 BORDERWINDOW_DRAW_HELP | \
69 BORDERWINDOW_DRAW_PIN | \
70 BORDERWINDOW_DRAW_MENU)
72 #define BORDERWINDOW_TITLE_NORMAL ((sal_uInt16)0x0001)
73 #define BORDERWINDOW_TITLE_SMALL ((sal_uInt16)0x0002)
74 #define BORDERWINDOW_TITLE_TEAROFF ((sal_uInt16)0x0004)
75 #define BORDERWINDOW_TITLE_POPUP ((sal_uInt16)0x0008)
76 #define BORDERWINDOW_TITLE_NONE ((sal_uInt16)0x0010)
78 class ImplBorderWindow
: public vcl::Window
80 friend class vcl::Window
;
81 friend class ImplBorderWindowView
;
82 friend class ImplSmallBorderWindowView
;
83 friend class ImplStdBorderWindowView
;
86 ImplBorderWindowView
* mpBorderView
;
87 VclPtr
<vcl::Window
> mpMenuBarWindow
;
94 sal_uInt16 mnTitleType
;
95 WindowBorderStyle mnBorderStyle
;
97 bool mbSmallOutBorder
;
105 bool mbDisplayActive
;
107 using Window::ImplInit
;
108 void ImplInit( vcl::Window
* pParent
,
109 WinBits nStyle
, sal_uInt16 nTypeStyle
,
110 SystemParentData
* pParentData
);
111 void ImplInit( vcl::Window
* pParent
,
112 WinBits nStyle
, sal_uInt16 nTypeStyle
,
113 const ::com::sun::star::uno::Any
& );
115 ImplBorderWindow (const ImplBorderWindow
&) SAL_DELETED_FUNCTION
;
116 ImplBorderWindow
& operator= (const ImplBorderWindow
&) SAL_DELETED_FUNCTION
;
119 ImplBorderWindow( vcl::Window
* pParent
,
120 SystemParentData
* pParentData
,
122 sal_uInt16 nTypeStyle
= 0 );
123 ImplBorderWindow( vcl::Window
* pParent
, WinBits nStyle
= 0,
124 sal_uInt16 nTypeStyle
= 0 );
125 virtual ~ImplBorderWindow();
126 virtual void dispose() SAL_OVERRIDE
;
128 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
129 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
130 virtual void Tracking( const TrackingEvent
& rTEvt
) SAL_OVERRIDE
;
131 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
132 virtual void Activate() SAL_OVERRIDE
;
133 virtual void Deactivate() SAL_OVERRIDE
;
134 virtual void Resize() SAL_OVERRIDE
;
135 virtual void RequestHelp( const HelpEvent
& rHEvt
) SAL_OVERRIDE
;
136 virtual void StateChanged( StateChangedType nType
) SAL_OVERRIDE
;
137 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
140 void UpdateView( bool bNewView
, const Size
& rNewOutSize
);
141 void InvalidateBorder();
144 void Draw( const Rectangle
& rRect
, OutputDevice
* pDev
, const Point
& rPos
);
146 void SetDisplayActive( bool bActive
);
147 bool IsDisplayActive() const { return mbDisplayActive
; }
148 void SetTitleType( sal_uInt16 nTitleType
, const Size
& rSize
);
149 void SetBorderStyle( WindowBorderStyle nStyle
);
150 WindowBorderStyle
GetBorderStyle() const { return mnBorderStyle
; }
151 void SetPin( bool bPin
);
152 void SetRollUp( bool bRollUp
, const Size
& rSize
);
153 void SetCloseButton();
154 void SetDockButton( bool bDockButton
);
155 void SetHideButton( bool bHideButton
);
156 void SetMenuButton( bool bMenuButton
);
158 void UpdateMenuHeight();
159 void SetMenuBarWindow( vcl::Window
* pWindow
);
160 void SetMenuBarMode( bool bHide
);
162 void SetMinOutputSize( long nWidth
, long nHeight
)
163 { mnMinWidth
= nWidth
; mnMinHeight
= nHeight
; }
164 void SetMaxOutputSize( long nWidth
, long nHeight
)
165 { mnMaxWidth
= nWidth
; mnMaxHeight
= nHeight
; }
167 void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
168 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const;
169 long CalcTitleWidth() const;
171 Rectangle
GetMenuRect() const;
173 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
176 struct ImplBorderFrameData
178 VclPtr
<ImplBorderWindow
> mpBorderWindow
;
179 VclPtr
<OutputDevice
> mpOutDev
;
180 Rectangle maTitleRect
;
182 Rectangle maCloseRect
;
183 Rectangle maRollRect
;
184 Rectangle maDockRect
;
185 Rectangle maMenuRect
;
186 Rectangle maHideRect
;
187 Rectangle maHelpRect
;
195 sal_Int32 mnLeftBorder
;
196 sal_Int32 mnTopBorder
;
197 sal_Int32 mnRightBorder
;
198 sal_Int32 mnBottomBorder
;
203 sal_uInt16 mnHitTest
;
204 DrawButtonFlags mnPinState
;
205 DrawButtonFlags mnCloseState
;
206 DrawButtonFlags mnRollState
;
207 DrawButtonFlags mnDockState
;
208 DrawButtonFlags mnMenuState
;
209 DrawButtonFlags mnHideState
;
210 DrawButtonFlags mnHelpState
;
211 sal_uInt16 mnTitleType
;
217 class ImplBorderWindowView
220 virtual ~ImplBorderWindowView();
222 virtual bool MouseMove( const MouseEvent
& rMEvt
);
223 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
);
224 virtual bool Tracking( const TrackingEvent
& rTEvt
);
225 virtual OUString
RequestHelp( const Point
& rPos
, Rectangle
& rHelpRect
);
227 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) = 0;
228 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
229 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const = 0;
230 virtual long CalcTitleWidth() const = 0;
231 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, sal_uInt16 nDrawFlags
, const Point
* pOffset
= NULL
) = 0;
232 virtual Rectangle
GetMenuRect() const;
234 static void ImplInitTitle( ImplBorderFrameData
* pData
);
235 static sal_uInt16
ImplHitTest( ImplBorderFrameData
* pData
, const Point
& rPos
);
236 static bool ImplMouseMove( ImplBorderFrameData
* pData
, const MouseEvent
& rMEvt
);
237 bool ImplMouseButtonDown( ImplBorderFrameData
* pData
, const MouseEvent
& rMEvt
);
238 static OUString
ImplRequestHelp( ImplBorderFrameData
* pData
, const Point
& rPos
, Rectangle
& rHelpRect
);
239 static long ImplCalcTitleWidth( const ImplBorderFrameData
* pData
);
242 class ImplNoBorderWindowView
: public ImplBorderWindowView
245 ImplNoBorderWindowView( ImplBorderWindow
* pBorderWindow
);
247 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) SAL_OVERRIDE
;
248 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
249 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const SAL_OVERRIDE
;
250 virtual long CalcTitleWidth() const SAL_OVERRIDE
;
251 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, sal_uInt16 nDrawFlags
, const Point
* pOffset
) SAL_OVERRIDE
;
254 class ImplSmallBorderWindowView
: public ImplBorderWindowView
256 VclPtr
<ImplBorderWindow
> mpBorderWindow
;
257 VclPtr
<OutputDevice
> mpOutDev
;
260 sal_Int32 mnLeftBorder
;
261 sal_Int32 mnTopBorder
;
262 sal_Int32 mnRightBorder
;
263 sal_Int32 mnBottomBorder
;
267 ImplSmallBorderWindowView( ImplBorderWindow
* pBorderWindow
);
269 virtual void Init( OutputDevice
* pOutDev
, long nWidth
, long nHeight
) SAL_OVERRIDE
;
270 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
271 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const SAL_OVERRIDE
;
272 virtual long CalcTitleWidth() const SAL_OVERRIDE
;
273 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, sal_uInt16 nDrawFlags
, const Point
* pOffset
) SAL_OVERRIDE
;
276 class ImplStdBorderWindowView
: public ImplBorderWindowView
278 ImplBorderFrameData maFrameData
;
279 VclPtr
<VirtualDevice
> mpATitleVirDev
;
280 VclPtr
<VirtualDevice
> mpDTitleVirDev
;
283 ImplStdBorderWindowView( ImplBorderWindow
* pBorderWindow
);
284 virtual ~ImplStdBorderWindowView();
286 virtual bool MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
287 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
288 virtual bool Tracking( const TrackingEvent
& rTEvt
) SAL_OVERRIDE
;
289 virtual OUString
RequestHelp( const Point
& rPos
, Rectangle
& rHelpRect
) SAL_OVERRIDE
;
290 virtual Rectangle
GetMenuRect() const SAL_OVERRIDE
;
292 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) SAL_OVERRIDE
;
293 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
294 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const SAL_OVERRIDE
;
295 virtual long CalcTitleWidth() const SAL_OVERRIDE
;
296 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, sal_uInt16 nDrawFlags
, const Point
* pOffset
) SAL_OVERRIDE
;
299 #endif // INCLUDED_VCL_INC_BRDWIN_HXX
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */