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 
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  Dock = 0x0800,
58  Hide = 0x1000,
59  Help = 0x2000,
60 };
61 namespace o3tl {
62  template<> struct typed_flags<BorderWindowHitTest> : is_typed_flags<BorderWindowHitTest, 0x3fff> {};
63 };
64 
66  Normal = 0x0001,
67  Small = 0x0002,
68  Tearoff = 0x0004,
69  Popup = 0x0008,
70  NONE = 0x0010
71 };
72 namespace o3tl {
73  template<> struct typed_flags<BorderWindowTitleType> : is_typed_flags<BorderWindowTitleType, 0x001f> {};
74 };
75 
76 class ImplBorderWindow final : public vcl::Window
77 {
78  friend class vcl::Window;
80  friend class ImplBorderWindowView;
83 
84 private:
85  std::unique_ptr<ImplBorderWindowView> mpBorderView;
98  bool mbMenuHide;
99  bool mbDockBtn;
100  bool mbHideBtn;
101  bool mbMenuBtn;
103 
104  using Window::ImplInit;
105  void ImplInit( vcl::Window* pParent,
106  WinBits nStyle, BorderWindowStyle nTypeStyle,
107  SystemParentData* pParentData );
108 
109  ImplBorderWindow (const ImplBorderWindow &) = delete;
110  ImplBorderWindow& operator= (const ImplBorderWindow &) = delete;
111 
112 public:
113  ImplBorderWindow( vcl::Window* pParent,
114  SystemParentData* pParentData,
115  WinBits nStyle,
116  BorderWindowStyle nTypeStyle );
117  ImplBorderWindow( vcl::Window* pParent, WinBits nStyle,
118  BorderWindowStyle nTypeStyle );
119  virtual ~ImplBorderWindow() override;
120  virtual void dispose() override;
121 
122  virtual void MouseMove( const MouseEvent& rMEvt ) override;
123  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
124  virtual void Tracking( const TrackingEvent& rTEvt ) override;
125  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
126  virtual void Activate() override;
127  virtual void Deactivate() override;
128  virtual void Resize() override;
129  virtual void RequestHelp( const HelpEvent& rHEvt ) override;
130  virtual void StateChanged( StateChangedType nType ) override;
131  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
132  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
133 
134  void InitView();
135  void UpdateView( bool bNewView, const Size& rNewOutSize );
136  void InvalidateBorder();
137 
138  using Window::Draw;
139  void Draw( OutputDevice* pDev, const Point& rPos );
140 
141  void SetDisplayActive( bool bActive );
142  void SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize );
143  void SetBorderStyle( WindowBorderStyle nStyle );
145  void SetCloseButton();
146  void SetDockButton( bool bDockButton );
147  void SetHideButton( bool bHideButton );
148  void SetMenuButton( bool bMenuButton );
149 
150  void UpdateMenuHeight();
151  void SetMenuBarWindow( vcl::Window* pWindow );
152  void SetMenuBarMode( bool bHide );
153 
154  void SetNotebookBar(const OUString& rUIXMLDescription,
155  const css::uno::Reference<css::frame::XFrame>& rFrame,
156  const NotebookBarAddonsItem &aNotebookBarAddonsItem);
157  void CloseNotebookBar();
159 
160  void SetMinOutputSize( tools::Long nWidth, tools::Long nHeight )
161  { mnMinWidth = nWidth; mnMinHeight = nHeight; }
162  void SetMaxOutputSize( tools::Long nWidth, tools::Long nHeight )
163  { mnMaxWidth = nWidth; mnMaxHeight = nHeight; }
164 
165  void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
166  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
167  tools::Long CalcTitleWidth() const;
168 
170 
171  virtual Size GetOptimalSize() const override;
172 };
173 
175 {
191  sal_Int32 mnLeftBorder;
192  sal_Int32 mnTopBorder;
193  sal_Int32 mnRightBorder;
194  sal_Int32 mnBottomBorder;
207 };
208 
210 {
211 public:
212  virtual ~ImplBorderWindowView();
213 
214  virtual bool MouseMove( const MouseEvent& rMEvt );
215  virtual bool MouseButtonDown( const MouseEvent& rMEvt );
216  virtual bool Tracking( const TrackingEvent& rTEvt );
217  virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect );
218 
219  virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) = 0;
220  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
221  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0;
222  virtual tools::Long CalcTitleWidth() const = 0;
223  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) = 0;
224  virtual tools::Rectangle GetMenuRect() const;
225 
226  static void ImplInitTitle( ImplBorderFrameData* pData );
227  static BorderWindowHitTest ImplHitTest( ImplBorderFrameData const * pData, const Point& rPos );
228  static void ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
229  static OUString ImplRequestHelp( ImplBorderFrameData const * pData, const Point& rPos, tools::Rectangle& rHelpRect );
230  static tools::Long ImplCalcTitleWidth( const ImplBorderFrameData* pData );
231 };
232 
234 {
235 public:
237 
238  virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) override;
239  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
240  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
241  virtual tools::Long CalcTitleWidth() const override;
242  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
243 };
244 
246 {
251  sal_Int32 mnLeftBorder;
252  sal_Int32 mnTopBorder;
253  sal_Int32 mnRightBorder;
254  sal_Int32 mnBottomBorder;
256 
257 public:
259 
260  virtual void Init( OutputDevice* pOutDev, tools::Long nWidth, tools::Long nHeight ) override;
261  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
262  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
263  virtual tools::Long CalcTitleWidth() const override;
264  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
265 };
266 
268 {
270 
271 public:
272  ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow );
273  virtual ~ImplStdBorderWindowView() override;
274 
275  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
276  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
277  virtual bool Tracking( const TrackingEvent& rTEvt ) override;
278  virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect ) override;
279  virtual tools::Rectangle GetMenuRect() const override;
280 
281  virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) override;
282  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
283  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
284  virtual tools::Long CalcTitleWidth() const override;
285  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
286 };
287 
288 #endif // INCLUDED_VCL_INC_BRDWIN_HXX
289 
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long mnWidth
Definition: brdwin.hxx:185
void CloseNotebookBar()
Definition: brdwin.cxx:1946
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const override
Definition: brdwin.cxx:363
ImplBorderFrameData maFrameData
Definition: brdwin.hxx:269
virtual tools::Long CalcTitleWidth() const override
Definition: brdwin.cxx:1337
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:1342
void SetCloseButton()
Definition: brdwin.cxx:1884
tools::Long mnMinHeight
Definition: brdwin.hxx:89
DrawButtonFlags mnCloseState
Definition: brdwin.hxx:199
ImplStdBorderWindowView(ImplBorderWindow *pBorderWindow)
Definition: brdwin.cxx:736
std::unique_ptr< ContentProperties > pData
virtual void Deactivate() override
Definition: brdwin.cxx:1634
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:759
static tools::Long ImplCalcTitleWidth(const ImplBorderFrameData *pData)
Definition: brdwin.cxx:337
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: brdwin.cxx:1590
Definition: help.hxx:60
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: brdwin.cxx:1610
BorderWindowTitleType mnTitleType
Definition: brdwin.hxx:204
VclPtr< ImplBorderWindow > mpBorderWindow
Definition: brdwin.hxx:176
long Long
void SetDisplayActive(bool bActive)
Definition: brdwin.cxx:1859
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const override
Definition: brdwin.cxx:562
virtual void Resize() override
Definition: brdwin.cxx:1667
sal_Int32 mnBottomBorder
Definition: brdwin.hxx:194
DrawButtonFlags
Definition: decoview.hxx:53
void InvalidateBorder()
Definition: brdwin.cxx:1828
VclPtr< OutputDevice > mpOutDev
Definition: brdwin.hxx:177
virtual void StateChanged(StateChangedType nType) override
Definition: brdwin.cxx:1742
void ImplInit(vcl::Window *pParent, WinBits nStyle, BorderWindowStyle nTypeStyle, SystemParentData *pParentData)
Definition: brdwin.cxx:1495
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const =0
VclPtr< NotebookBar > mpNotebookBar
Definition: brdwin.hxx:87
VclPtr< OutputDevice > mpOutDev
Definition: brdwin.hxx:248
BorderWindowTitleType
Definition: brdwin.hxx:65
StateChangedType
Definition: window.hxx:289
BorderWindowTitleType mnTitleType
Definition: brdwin.hxx:93
sal_Int64 WinBits
sal_Int32 mnLeftBorder
Definition: brdwin.hxx:191
void SetMinOutputSize(tools::Long nWidth, tools::Long nHeight)
Definition: brdwin.hxx:160
tools::Long mnTrackX
Definition: brdwin.hxx:187
bool mbFrameBorder
Definition: brdwin.hxx:97
tools::Long mnMaxWidth
Definition: brdwin.hxx:90
virtual tools::Long CalcTitleWidth() const override
Definition: brdwin.cxx:571
sal_Int32 mnTopBorder
Definition: brdwin.hxx:192
tools::Rectangle maHideRect
Definition: brdwin.hxx:182
tools::Rectangle maCloseRect
Definition: brdwin.hxx:179
sal_Int32 mnRightBorder
Definition: brdwin.hxx:193
tools::Long mnHeight
Definition: brdwin.hxx:186
std::unique_ptr< ImplBorderWindowView > mpBorderView
Definition: brdwin.hxx:85
VclPtr< ImplBorderWindow > mpBorderWindow
Definition: brdwin.hxx:247
tools::Rectangle maHelpRect
Definition: brdwin.hxx:183
virtual bool MouseMove(const MouseEvent &rMEvt)
Definition: brdwin.cxx:114
tools::Long mnTrackY
Definition: brdwin.hxx:188
tools::Long mnTitleHeight
Definition: brdwin.hxx:197
void UpdateView(bool bNewView, const Size &rNewOutSize)
Definition: brdwin.cxx:1787
static OUString ImplRequestHelp(ImplBorderFrameData const *pData, const Point &rPos, tools::Rectangle &rHelpRect)
Definition: brdwin.cxx:287
virtual OUString RequestHelp(const Point &rPos, tools::Rectangle &rHelpRect) override
Definition: brdwin.cxx:1212
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: brdwin.cxx:1643
WindowBorderStyle GetBorderStyle() const
Definition: brdwin.hxx:144
virtual ~ImplBorderWindowView()
Definition: brdwin.cxx:110
bool mbFloatWindow
Definition: brdwin.hxx:95
void SetMenuBarWindow(vcl::Window *pWindow)
Definition: brdwin.cxx:1921
VclPtr< vcl::Window > mpMenuBarWindow
Definition: brdwin.hxx:86
tools::Long mnBorderSize
Definition: brdwin.hxx:196
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:162
virtual ~ImplStdBorderWindowView() override
Definition: brdwin.cxx:749
WindowBorderStyle mnBorderStyle
Definition: brdwin.hxx:94
tools::Long CalcTitleWidth() const
Definition: brdwin.cxx:1966
ImplBorderWindow & operator=(const ImplBorderWindow &)=delete
void SetMaxOutputSize(tools::Long nWidth, tools::Long nHeight)
Definition: brdwin.hxx:162
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: brdwin.cxx:1616
void UpdateMenuHeight()
Definition: brdwin.cxx:1916
tools::Rectangle GetMenuRect() const
Definition: brdwin.cxx:1971
BorderWindowHitTest mnHitTest
Definition: brdwin.hxx:198
virtual tools::Long CalcTitleWidth() const =0
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:1604
void SetBorderStyle(WindowBorderStyle nStyle)
Definition: brdwin.cxx:1875
const VclPtr< NotebookBar > & GetNotebookBar() const
Definition: brdwin.hxx:158
virtual tools::Rectangle GetMenuRect() const
Definition: brdwin.cxx:134
virtual void Activate() override
Definition: brdwin.cxx:1628
virtual void Init(OutputDevice *pOutDev, tools::Long nWidth, tools::Long nHeight) override
Definition: brdwin.cxx:394
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: brdwin.cxx:1754
void SetNotebookBar(const OUString &rUIXMLDescription, const css::uno::Reference< css::frame::XFrame > &rFrame, const NotebookBarAddonsItem &aNotebookBarAddonsItem)
Definition: brdwin.cxx:1935
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr)=0
tools::Long mnMaxHeight
Definition: brdwin.hxx:91
tools::Long mnTrackHeight
Definition: brdwin.hxx:190
static void ImplMouseMove(ImplBorderFrameData *pData, const MouseEvent &rMEvt)
Definition: brdwin.cxx:246
virtual bool Tracking(const TrackingEvent &rTEvt) override
Definition: brdwin.cxx:861
void SetMenuBarMode(bool bHide)
Definition: brdwin.cxx:1929
BorderWindowHitTest
Definition: brdwin.hxx:44
bool mbSmallOutBorder
Definition: brdwin.hxx:96
bool mbDisplayActive
Definition: brdwin.hxx:102
Definition: menu.hxx:124
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const override
Definition: brdwin.cxx:1328
void Draw(OutputDevice *pDev, const Point &rPos)
Definition: brdwin.cxx:1622
virtual tools::Rectangle GetMenuRect() const override
Definition: brdwin.cxx:1217
virtual Size GetOptimalSize() const override
Definition: brdwin.cxx:1976
tools::Rectangle maMenuRect
Definition: brdwin.hxx:181
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: brdwin.cxx:1954
tools::Long mnOrgMenuHeight
Definition: brdwin.hxx:92
virtual OUString RequestHelp(const Point &rPos, tools::Rectangle &rHelpRect)
Definition: brdwin.cxx:129
void SetHideButton(bool bHideButton)
Definition: brdwin.cxx:1900
void SetTitleType(BorderWindowTitleType nTitleType, const Size &rSize)
Definition: brdwin.cxx:1869
void SetDockButton(bool bDockButton)
Definition: brdwin.cxx:1892
DrawButtonFlags mnHelpState
Definition: brdwin.hxx:203
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr) override
Definition: brdwin.cxx:377
BorderWindowStyle
Definition: brdwin.hxx:33
DrawButtonFlags mnMenuState
Definition: brdwin.hxx:201
DrawButtonFlags mnHideState
Definition: brdwin.hxx:202
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: brdwin.cxx:119
virtual void Init(OutputDevice *pDev, tools::Long nWidth, tools::Long nHeight)=0
virtual void Init(OutputDevice *pDev, tools::Long nWidth, tools::Long nHeight) override
Definition: brdwin.cxx:1222
static void ImplInitTitle(ImplBorderFrameData *pData)
Definition: brdwin.cxx:139
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: brdwin.cxx:1984
virtual void Init(OutputDevice *pDev, tools::Long nWidth, tools::Long nHeight) override
Definition: brdwin.cxx:359
tools::Rectangle maTitleRect
Definition: brdwin.hxx:178
ImplSmallBorderWindowView(ImplBorderWindow *pBorderWindow)
Definition: brdwin.cxx:381
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr) override
Definition: brdwin.cxx:576
ImplBorderWindow(const ImplBorderWindow &)=delete
virtual ~ImplBorderWindow() override
Definition: brdwin.cxx:1585
WindowBorderStyle
Definition: vclenum.hxx:106
tools::Long mnMinWidth
Definition: brdwin.hxx:88
tools::Long mnNoTitleTop
Definition: brdwin.hxx:195
tools::Rectangle maDockRect
Definition: brdwin.hxx:180
void SetMenuButton(bool bMenuButton)
Definition: brdwin.cxx:1908
tools::Long mnTrackWidth
Definition: brdwin.hxx:189
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:753
DrawButtonFlags mnDockState
Definition: brdwin.hxx:200
virtual tools::Long CalcTitleWidth() const override
Definition: brdwin.cxx:372
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:1598