LibreOffice Module vcl (master)  1
brdwin.hxx
Go to the documentation of this file.
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 INCLUDED_VCL_INC_BRDWIN_HXX
21 #define INCLUDED_VCL_INC_BRDWIN_HXX
22 
23 #include <vcl/notebookbar.hxx>
24 #include <vcl/window.hxx>
25 #include <o3tl/typed_flags_set.hxx>
27 
28 #include <com/sun/star/frame/XFrame.hpp>
29 
31 enum class DrawButtonFlags;
32 
33 enum class BorderWindowStyle {
34  NONE = 0x0000,
35  Overlap = 0x0001,
36  Float = 0x0004,
37  Frame = 0x0008,
38  App = 0x0010
39 };
40 namespace o3tl {
41  template<> struct typed_flags<BorderWindowStyle> : is_typed_flags<BorderWindowStyle, 0x001d> {};
42 };
43 
44 enum class BorderWindowHitTest {
45  NONE = 0x0000,
46  Title = 0x0001,
47  Left = 0x0002,
48  Menu = 0x0004,
49  Top = 0x0008,
50  Right = 0x0010,
51  Bottom = 0x0020,
52  TopLeft = 0x0040,
53  TopRight = 0x0080,
54  BottomLeft = 0x0100,
55  BottomRight = 0x0200,
56  Close = 0x0400,
57  Roll = 0x0800,
58  Dock = 0x1000,
59  Hide = 0x2000,
60  Help = 0x4000,
61 };
62 namespace o3tl {
63  template<> struct typed_flags<BorderWindowHitTest> : is_typed_flags<BorderWindowHitTest, 0xffff> {};
64 };
65 
67  Normal = 0x0001,
68  Small = 0x0002,
69  Tearoff = 0x0004,
70  Popup = 0x0008,
71  NONE = 0x0010
72 };
73 namespace o3tl {
74  template<> struct typed_flags<BorderWindowTitleType> : is_typed_flags<BorderWindowTitleType, 0x001f> {};
75 };
76 
78 {
79  friend class vcl::Window;
80  friend class ImplBorderWindowView;
83 
84 private:
85  std::unique_ptr<ImplBorderWindowView> mpBorderView;
88  long mnMinWidth;
90  long mnMaxWidth;
98  bool mbRollUp;
99  bool mbMenuHide;
100  bool mbDockBtn;
101  bool mbHideBtn;
102  bool mbMenuBtn;
104 
105  using Window::ImplInit;
106  void ImplInit( vcl::Window* pParent,
107  WinBits nStyle, BorderWindowStyle nTypeStyle,
108  SystemParentData* pParentData );
109 
110  ImplBorderWindow (const ImplBorderWindow &) = delete;
111  ImplBorderWindow& operator= (const ImplBorderWindow &) = delete;
112 
113 public:
114  ImplBorderWindow( vcl::Window* pParent,
115  SystemParentData* pParentData,
116  WinBits nStyle,
117  BorderWindowStyle nTypeStyle );
118  ImplBorderWindow( vcl::Window* pParent, WinBits nStyle,
119  BorderWindowStyle nTypeStyle );
120  virtual ~ImplBorderWindow() override;
121  virtual void dispose() override;
122 
123  virtual void MouseMove( const MouseEvent& rMEvt ) override;
124  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
125  virtual void Tracking( const TrackingEvent& rTEvt ) override;
126  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
127  virtual void Activate() override;
128  virtual void Deactivate() override;
129  virtual void Resize() override;
130  virtual void RequestHelp( const HelpEvent& rHEvt ) override;
131  virtual void StateChanged( StateChangedType nType ) override;
132  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
133  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
134 
135  void InitView();
136  void UpdateView( bool bNewView, const Size& rNewOutSize );
137  void InvalidateBorder();
138 
139  using Window::Draw;
140  void Draw( OutputDevice* pDev, const Point& rPos );
141 
142  void SetDisplayActive( bool bActive );
143  void SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize );
144  void SetBorderStyle( WindowBorderStyle nStyle );
146  void SetRollUp( bool bRollUp, const Size& rSize );
147  void SetCloseButton();
148  void SetDockButton( bool bDockButton );
149  void SetHideButton( bool bHideButton );
150  void SetMenuButton( bool bMenuButton );
151 
152  void UpdateMenuHeight();
153  void SetMenuBarWindow( vcl::Window* pWindow );
154  void SetMenuBarMode( bool bHide );
155 
156  void SetNotebookBar(const OUString& rUIXMLDescription,
157  const css::uno::Reference<css::frame::XFrame>& rFrame,
158  const NotebookBarAddonsItem &aNotebookBarAddonsItem);
159  void CloseNotebookBar();
161 
162  void SetMinOutputSize( long nWidth, long nHeight )
163  { mnMinWidth = nWidth; mnMinHeight = nHeight; }
164  void SetMaxOutputSize( long nWidth, long nHeight )
165  { mnMaxWidth = nWidth; mnMaxHeight = nHeight; }
166 
167  void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
168  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
169  long CalcTitleWidth() const;
170 
172 
173  virtual Size GetOptimalSize() const override;
174 };
175 
177 {
188  long mnWidth;
189  long mnHeight;
190  long mnTrackX;
191  long mnTrackY;
194  sal_Int32 mnLeftBorder;
195  sal_Int32 mnTopBorder;
196  sal_Int32 mnRightBorder;
197  sal_Int32 mnBottomBorder;
211 };
212 
214 {
215 public:
216  virtual ~ImplBorderWindowView();
217 
218  virtual bool MouseMove( const MouseEvent& rMEvt );
219  virtual bool MouseButtonDown( const MouseEvent& rMEvt );
220  virtual bool Tracking( const TrackingEvent& rTEvt );
221  virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect );
222 
223  virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ) = 0;
224  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
225  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0;
226  virtual long CalcTitleWidth() const = 0;
227  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) = 0;
228  virtual tools::Rectangle GetMenuRect() const;
229 
230  static void ImplInitTitle( ImplBorderFrameData* pData );
231  static BorderWindowHitTest ImplHitTest( ImplBorderFrameData const * pData, const Point& rPos );
232  static void ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
233  static OUString ImplRequestHelp( ImplBorderFrameData const * pData, const Point& rPos, tools::Rectangle& rHelpRect );
234  static long ImplCalcTitleWidth( const ImplBorderFrameData* pData );
235 };
236 
238 {
239 public:
241 
242  virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ) override;
243  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
244  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
245  virtual long CalcTitleWidth() const override;
246  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
247 };
248 
250 {
253  long mnWidth;
254  long mnHeight;
255  sal_Int32 mnLeftBorder;
256  sal_Int32 mnTopBorder;
257  sal_Int32 mnRightBorder;
258  sal_Int32 mnBottomBorder;
260 
261 public:
263 
264  virtual void Init( OutputDevice* pOutDev, long nWidth, long nHeight ) override;
265  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
266  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
267  virtual long CalcTitleWidth() const override;
268  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
269 };
270 
272 {
274 
275 public:
276  ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow );
277  virtual ~ImplStdBorderWindowView() override;
278 
279  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
280  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
281  virtual bool Tracking( const TrackingEvent& rTEvt ) override;
282  virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect ) override;
283  virtual tools::Rectangle GetMenuRect() const override;
284 
285  virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ) override;
286  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
287  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
288  virtual long CalcTitleWidth() const override;
289  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
290 };
291 
292 #endif // INCLUDED_VCL_INC_BRDWIN_HXX
293 
294 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CloseNotebookBar()
Definition: brdwin.cxx:2024
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const override
Definition: brdwin.cxx:375
ImplBorderFrameData maFrameData
Definition: brdwin.hxx:273
static BorderWindowHitTest ImplHitTest(ImplBorderFrameData const *pData, const Point &rPos)
Definition: brdwin.cxx:174
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr) override
Definition: brdwin.cxx:1395
void SetCloseButton()
Definition: brdwin.cxx:1962
virtual long CalcTitleWidth() const override
Definition: brdwin.cxx:580
DrawButtonFlags mnCloseState
Definition: brdwin.hxx:202
virtual long CalcTitleWidth() const override
Definition: brdwin.cxx:1390
ImplStdBorderWindowView(ImplBorderWindow *pBorderWindow)
Definition: brdwin.cxx:741
virtual void Deactivate() override
Definition: brdwin.cxx:1703
void SetMaxOutputSize(long nWidth, long nHeight)
Definition: brdwin.hxx:164
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:765
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: brdwin.cxx:1659
Definition: help.hxx:60
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: brdwin.cxx:1679
BorderWindowTitleType mnTitleType
Definition: brdwin.hxx:208
VclPtr< ImplBorderWindow > mpBorderWindow
Definition: brdwin.hxx:178
void SetDisplayActive(bool bActive)
Definition: brdwin.cxx:1931
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const override
Definition: brdwin.cxx:571
virtual void Resize() override
Definition: brdwin.cxx:1736
sal_Int32 mnBottomBorder
Definition: brdwin.hxx:197
DrawButtonFlags
Definition: decoview.hxx:78
void InvalidateBorder()
Definition: brdwin.cxx:1900
VclPtr< OutputDevice > mpOutDev
Definition: brdwin.hxx:179
virtual void StateChanged(StateChangedType nType) override
Definition: brdwin.cxx:1814
long mnOrgMenuHeight
Definition: brdwin.hxx:92
void ImplInit(vcl::Window *pParent, WinBits nStyle, BorderWindowStyle nTypeStyle, SystemParentData *pParentData)
Definition: brdwin.cxx:1563
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const =0
DrawButtonFlags mnRollState
Definition: brdwin.hxx:203
VclPtr< NotebookBar > mpNotebookBar
Definition: brdwin.hxx:87
VclPtr< OutputDevice > mpOutDev
Definition: brdwin.hxx:252
BorderWindowTitleType
Definition: brdwin.hxx:66
tools::Rectangle maRollRect
Definition: brdwin.hxx:182
StateChangedType
Definition: window.hxx:311
BorderWindowTitleType mnTitleType
Definition: brdwin.hxx:93
sal_Int64 WinBits
sal_Int32 mnLeftBorder
Definition: brdwin.hxx:194
long mnMaxHeight
Definition: brdwin.hxx:91
bool mbFrameBorder
Definition: brdwin.hxx:97
virtual void Init(OutputDevice *pDev, long nWidth, long nHeight)=0
sal_Int32 mnTopBorder
Definition: brdwin.hxx:195
tools::Rectangle maHideRect
Definition: brdwin.hxx:185
tools::Rectangle maCloseRect
Definition: brdwin.hxx:181
sal_Int32 mnRightBorder
Definition: brdwin.hxx:196
std::unique_ptr< ImplBorderWindowView > mpBorderView
Definition: brdwin.hxx:85
VclPtr< ImplBorderWindow > mpBorderWindow
Definition: brdwin.hxx:251
tools::Rectangle maHelpRect
Definition: brdwin.hxx:186
virtual bool MouseMove(const MouseEvent &rMEvt)
Definition: brdwin.cxx:114
void SetRollUp(bool bRollUp, const Size &rSize)
Definition: brdwin.cxx:1956
void UpdateView(bool bNewView, const Size &rNewOutSize)
Definition: brdwin.cxx:1859
static OUString ImplRequestHelp(ImplBorderFrameData const *pData, const Point &rPos, tools::Rectangle &rHelpRect)
Definition: brdwin.cxx:290
virtual OUString RequestHelp(const Point &rPos, tools::Rectangle &rHelpRect) override
Definition: brdwin.cxx:1258
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: brdwin.cxx:1712
WindowBorderStyle GetBorderStyle() const
Definition: brdwin.hxx:145
virtual ~ImplBorderWindowView()
Definition: brdwin.cxx:110
bool mbFloatWindow
Definition: brdwin.hxx:95
void SetMenuBarWindow(vcl::Window *pWindow)
Definition: brdwin.cxx:1999
VclPtr< vcl::Window > mpMenuBarWindow
Definition: brdwin.hxx:86
virtual bool Tracking(const TrackingEvent &rTEvt)
Definition: brdwin.cxx:124
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
virtual ~ImplStdBorderWindowView() override
Definition: brdwin.cxx:755
WindowBorderStyle mnBorderStyle
Definition: brdwin.hxx:94
ImplBorderWindow & operator=(const ImplBorderWindow &)=delete
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: brdwin.cxx:1685
void UpdateMenuHeight()
Definition: brdwin.cxx:1994
tools::Rectangle GetMenuRect() const
Definition: brdwin.cxx:2049
BorderWindowHitTest mnHitTest
Definition: brdwin.hxx:201
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:1673
void SetBorderStyle(WindowBorderStyle nStyle)
Definition: brdwin.cxx:1947
virtual long CalcTitleWidth() const override
Definition: brdwin.cxx:384
const VclPtr< NotebookBar > & GetNotebookBar() const
Definition: brdwin.hxx:160
virtual tools::Rectangle GetMenuRect() const
Definition: brdwin.cxx:134
virtual void Activate() override
Definition: brdwin.cxx:1697
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: brdwin.cxx:1826
long mnMinHeight
Definition: brdwin.hxx:89
void SetNotebookBar(const OUString &rUIXMLDescription, const css::uno::Reference< css::frame::XFrame > &rFrame, const NotebookBarAddonsItem &aNotebookBarAddonsItem)
Definition: brdwin.cxx:2013
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr)=0
long CalcTitleWidth() const
Definition: brdwin.cxx:2044
static void ImplMouseMove(ImplBorderFrameData *pData, const MouseEvent &rMEvt)
Definition: brdwin.cxx:249
virtual bool Tracking(const TrackingEvent &rTEvt) override
Definition: brdwin.cxx:867
void SetMenuBarMode(bool bHide)
Definition: brdwin.cxx:2007
virtual void Init(OutputDevice *pOutDev, long nWidth, long nHeight) override
Definition: brdwin.cxx:406
BorderWindowHitTest
Definition: brdwin.hxx:44
static long ImplCalcTitleWidth(const ImplBorderFrameData *pData)
Definition: brdwin.cxx:348
bool mbSmallOutBorder
Definition: brdwin.hxx:96
bool mbDisplayActive
Definition: brdwin.hxx:103
Definition: menu.hxx:121
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const override
Definition: brdwin.cxx:1381
void Draw(OutputDevice *pDev, const Point &rPos)
Definition: brdwin.cxx:1691
virtual tools::Rectangle GetMenuRect() const override
Definition: brdwin.cxx:1263
virtual Size GetOptimalSize() const override
Definition: brdwin.cxx:2054
tools::Rectangle maMenuRect
Definition: brdwin.hxx:184
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: brdwin.cxx:2032
virtual OUString RequestHelp(const Point &rPos, tools::Rectangle &rHelpRect)
Definition: brdwin.cxx:129
void SetHideButton(bool bHideButton)
Definition: brdwin.cxx:1978
void SetTitleType(BorderWindowTitleType nTitleType, const Size &rSize)
Definition: brdwin.cxx:1941
void SetDockButton(bool bDockButton)
Definition: brdwin.cxx:1970
DrawButtonFlags mnHelpState
Definition: brdwin.hxx:207
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr) override
Definition: brdwin.cxx:389
virtual long CalcTitleWidth() const =0
BorderWindowStyle
Definition: brdwin.hxx:33
virtual void Init(OutputDevice *pDev, long nWidth, long nHeight) override
Definition: brdwin.cxx:1268
DrawButtonFlags mnMenuState
Definition: brdwin.hxx:205
DrawButtonFlags mnHideState
Definition: brdwin.hxx:206
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: brdwin.cxx:119
static void ImplInitTitle(ImplBorderFrameData *pData)
Definition: brdwin.cxx:139
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: brdwin.cxx:2062
tools::Rectangle maTitleRect
Definition: brdwin.hxx:180
ImplSmallBorderWindowView(ImplBorderWindow *pBorderWindow)
Definition: brdwin.cxx:393
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr) override
Definition: brdwin.cxx:585
ImplBorderWindow(const ImplBorderWindow &)=delete
virtual ~ImplBorderWindow() override
Definition: brdwin.cxx:1654
WindowBorderStyle
Definition: vclenum.hxx:108
tools::Rectangle maDockRect
Definition: brdwin.hxx:183
void SetMinOutputSize(long nWidth, long nHeight)
Definition: brdwin.hxx:162
void SetMenuButton(bool bMenuButton)
Definition: brdwin.cxx:1986
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:759
DrawButtonFlags mnDockState
Definition: brdwin.hxx:204
virtual void Init(OutputDevice *pDev, long nWidth, long nHeight) override
Definition: brdwin.cxx:371
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:1667