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 
77 {
78  friend class vcl::Window;
79  friend class ImplBorderWindowView;
82 
83 private:
84  std::unique_ptr<ImplBorderWindowView> mpBorderView;
97  bool mbMenuHide;
98  bool mbDockBtn;
99  bool mbHideBtn;
100  bool mbMenuBtn;
102 
103  using Window::ImplInit;
104  void ImplInit( vcl::Window* pParent,
105  WinBits nStyle, BorderWindowStyle nTypeStyle,
106  SystemParentData* pParentData );
107 
108  ImplBorderWindow (const ImplBorderWindow &) = delete;
109  ImplBorderWindow& operator= (const ImplBorderWindow &) = delete;
110 
111 public:
112  ImplBorderWindow( vcl::Window* pParent,
113  SystemParentData* pParentData,
114  WinBits nStyle,
115  BorderWindowStyle nTypeStyle );
116  ImplBorderWindow( vcl::Window* pParent, WinBits nStyle,
117  BorderWindowStyle nTypeStyle );
118  virtual ~ImplBorderWindow() override;
119  virtual void dispose() override;
120 
121  virtual void MouseMove( const MouseEvent& rMEvt ) override;
122  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
123  virtual void Tracking( const TrackingEvent& rTEvt ) override;
124  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
125  virtual void Activate() override;
126  virtual void Deactivate() override;
127  virtual void Resize() override;
128  virtual void RequestHelp( const HelpEvent& rHEvt ) override;
129  virtual void StateChanged( StateChangedType nType ) override;
130  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
131  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
132 
133  void InitView();
134  void UpdateView( bool bNewView, const Size& rNewOutSize );
135  void InvalidateBorder();
136 
137  using Window::Draw;
138  void Draw( OutputDevice* pDev, const Point& rPos );
139 
140  void SetDisplayActive( bool bActive );
141  void SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize );
142  void SetBorderStyle( WindowBorderStyle nStyle );
144  void SetCloseButton();
145  void SetDockButton( bool bDockButton );
146  void SetHideButton( bool bHideButton );
147  void SetMenuButton( bool bMenuButton );
148 
149  void UpdateMenuHeight();
150  void SetMenuBarWindow( vcl::Window* pWindow );
151  void SetMenuBarMode( bool bHide );
152 
153  void SetNotebookBar(const OUString& rUIXMLDescription,
154  const css::uno::Reference<css::frame::XFrame>& rFrame,
155  const NotebookBarAddonsItem &aNotebookBarAddonsItem);
156  void CloseNotebookBar();
158 
159  void SetMinOutputSize( tools::Long nWidth, tools::Long nHeight )
160  { mnMinWidth = nWidth; mnMinHeight = nHeight; }
161  void SetMaxOutputSize( tools::Long nWidth, tools::Long nHeight )
162  { mnMaxWidth = nWidth; mnMaxHeight = nHeight; }
163 
164  void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
165  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
166  tools::Long CalcTitleWidth() const;
167 
169 
170  virtual Size GetOptimalSize() const override;
171 };
172 
174 {
190  sal_Int32 mnLeftBorder;
191  sal_Int32 mnTopBorder;
192  sal_Int32 mnRightBorder;
193  sal_Int32 mnBottomBorder;
206 };
207 
209 {
210 public:
211  virtual ~ImplBorderWindowView();
212 
213  virtual bool MouseMove( const MouseEvent& rMEvt );
214  virtual bool MouseButtonDown( const MouseEvent& rMEvt );
215  virtual bool Tracking( const TrackingEvent& rTEvt );
216  virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect );
217 
218  virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) = 0;
219  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
220  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0;
221  virtual tools::Long CalcTitleWidth() const = 0;
222  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) = 0;
223  virtual tools::Rectangle GetMenuRect() const;
224 
225  static void ImplInitTitle( ImplBorderFrameData* pData );
226  static BorderWindowHitTest ImplHitTest( ImplBorderFrameData const * pData, const Point& rPos );
227  static void ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
228  static OUString ImplRequestHelp( ImplBorderFrameData const * pData, const Point& rPos, tools::Rectangle& rHelpRect );
229  static tools::Long ImplCalcTitleWidth( const ImplBorderFrameData* pData );
230 };
231 
233 {
234 public:
236 
237  virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) override;
238  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
239  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
240  virtual tools::Long CalcTitleWidth() const override;
241  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
242 };
243 
245 {
250  sal_Int32 mnLeftBorder;
251  sal_Int32 mnTopBorder;
252  sal_Int32 mnRightBorder;
253  sal_Int32 mnBottomBorder;
255 
256 public:
258 
259  virtual void Init( OutputDevice* pOutDev, tools::Long nWidth, tools::Long nHeight ) override;
260  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
261  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
262  virtual tools::Long CalcTitleWidth() const override;
263  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
264 };
265 
267 {
269 
270 public:
271  ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow );
272  virtual ~ImplStdBorderWindowView() override;
273 
274  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
275  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
276  virtual bool Tracking( const TrackingEvent& rTEvt ) override;
277  virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect ) override;
278  virtual tools::Rectangle GetMenuRect() const override;
279 
280  virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) override;
281  virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
282  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
283  virtual tools::Long CalcTitleWidth() const override;
284  virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
285 };
286 
287 #endif // INCLUDED_VCL_INC_BRDWIN_HXX
288 
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long mnWidth
Definition: brdwin.hxx:184
void CloseNotebookBar()
Definition: brdwin.cxx:1948
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:268
virtual tools::Long CalcTitleWidth() const override
Definition: brdwin.cxx:1339
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:1344
void SetCloseButton()
Definition: brdwin.cxx:1886
tools::Long mnMinHeight
Definition: brdwin.hxx:88
DrawButtonFlags mnCloseState
Definition: brdwin.hxx:198
ImplStdBorderWindowView(ImplBorderWindow *pBorderWindow)
Definition: brdwin.cxx:738
std::unique_ptr< ContentProperties > pData
virtual void Deactivate() override
Definition: brdwin.cxx:1636
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:761
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:1592
Definition: help.hxx:60
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: brdwin.cxx:1612
BorderWindowTitleType mnTitleType
Definition: brdwin.hxx:203
VclPtr< ImplBorderWindow > mpBorderWindow
Definition: brdwin.hxx:175
long Long
void SetDisplayActive(bool bActive)
Definition: brdwin.cxx:1861
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const override
Definition: brdwin.cxx:564
virtual void Resize() override
Definition: brdwin.cxx:1669
sal_Int32 mnBottomBorder
Definition: brdwin.hxx:193
DrawButtonFlags
Definition: decoview.hxx:53
void InvalidateBorder()
Definition: brdwin.cxx:1830
VclPtr< OutputDevice > mpOutDev
Definition: brdwin.hxx:176
virtual void StateChanged(StateChangedType nType) override
Definition: brdwin.cxx:1744
void ImplInit(vcl::Window *pParent, WinBits nStyle, BorderWindowStyle nTypeStyle, SystemParentData *pParentData)
Definition: brdwin.cxx:1497
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const =0
VclPtr< NotebookBar > mpNotebookBar
Definition: brdwin.hxx:86
VclPtr< OutputDevice > mpOutDev
Definition: brdwin.hxx:247
BorderWindowTitleType
Definition: brdwin.hxx:65
StateChangedType
Definition: window.hxx:289
BorderWindowTitleType mnTitleType
Definition: brdwin.hxx:92
sal_Int64 WinBits
sal_Int32 mnLeftBorder
Definition: brdwin.hxx:190
void SetMinOutputSize(tools::Long nWidth, tools::Long nHeight)
Definition: brdwin.hxx:159
tools::Long mnTrackX
Definition: brdwin.hxx:186
bool mbFrameBorder
Definition: brdwin.hxx:96
tools::Long mnMaxWidth
Definition: brdwin.hxx:89
virtual tools::Long CalcTitleWidth() const override
Definition: brdwin.cxx:573
sal_Int32 mnTopBorder
Definition: brdwin.hxx:191
tools::Rectangle maHideRect
Definition: brdwin.hxx:181
tools::Rectangle maCloseRect
Definition: brdwin.hxx:178
sal_Int32 mnRightBorder
Definition: brdwin.hxx:192
tools::Long mnHeight
Definition: brdwin.hxx:185
std::unique_ptr< ImplBorderWindowView > mpBorderView
Definition: brdwin.hxx:84
VclPtr< ImplBorderWindow > mpBorderWindow
Definition: brdwin.hxx:246
tools::Rectangle maHelpRect
Definition: brdwin.hxx:182
virtual bool MouseMove(const MouseEvent &rMEvt)
Definition: brdwin.cxx:114
tools::Long mnTrackY
Definition: brdwin.hxx:187
tools::Long mnTitleHeight
Definition: brdwin.hxx:196
void UpdateView(bool bNewView, const Size &rNewOutSize)
Definition: brdwin.cxx:1789
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:1214
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: brdwin.cxx:1645
WindowBorderStyle GetBorderStyle() const
Definition: brdwin.hxx:143
virtual ~ImplBorderWindowView()
Definition: brdwin.cxx:110
bool mbFloatWindow
Definition: brdwin.hxx:94
void SetMenuBarWindow(vcl::Window *pWindow)
Definition: brdwin.cxx:1923
VclPtr< vcl::Window > mpMenuBarWindow
Definition: brdwin.hxx:85
tools::Long mnBorderSize
Definition: brdwin.hxx:195
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:303
virtual ~ImplStdBorderWindowView() override
Definition: brdwin.cxx:751
WindowBorderStyle mnBorderStyle
Definition: brdwin.hxx:93
tools::Long CalcTitleWidth() const
Definition: brdwin.cxx:1968
ImplBorderWindow & operator=(const ImplBorderWindow &)=delete
void SetMaxOutputSize(tools::Long nWidth, tools::Long nHeight)
Definition: brdwin.hxx:161
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: brdwin.cxx:1618
void UpdateMenuHeight()
Definition: brdwin.cxx:1918
tools::Rectangle GetMenuRect() const
Definition: brdwin.cxx:1973
BorderWindowHitTest mnHitTest
Definition: brdwin.hxx:197
virtual tools::Long CalcTitleWidth() const =0
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:1606
void SetBorderStyle(WindowBorderStyle nStyle)
Definition: brdwin.cxx:1877
const VclPtr< NotebookBar > & GetNotebookBar() const
Definition: brdwin.hxx:157
virtual tools::Rectangle GetMenuRect() const
Definition: brdwin.cxx:134
virtual void Activate() override
Definition: brdwin.cxx:1630
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:1756
void SetNotebookBar(const OUString &rUIXMLDescription, const css::uno::Reference< css::frame::XFrame > &rFrame, const NotebookBarAddonsItem &aNotebookBarAddonsItem)
Definition: brdwin.cxx:1937
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr)=0
tools::Long mnMaxHeight
Definition: brdwin.hxx:90
tools::Long mnTrackHeight
Definition: brdwin.hxx:189
static void ImplMouseMove(ImplBorderFrameData *pData, const MouseEvent &rMEvt)
Definition: brdwin.cxx:246
virtual bool Tracking(const TrackingEvent &rTEvt) override
Definition: brdwin.cxx:863
void SetMenuBarMode(bool bHide)
Definition: brdwin.cxx:1931
BorderWindowHitTest
Definition: brdwin.hxx:44
bool mbSmallOutBorder
Definition: brdwin.hxx:95
bool mbDisplayActive
Definition: brdwin.hxx:101
Definition: menu.hxx:123
virtual void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const override
Definition: brdwin.cxx:1330
void Draw(OutputDevice *pDev, const Point &rPos)
Definition: brdwin.cxx:1624
virtual tools::Rectangle GetMenuRect() const override
Definition: brdwin.cxx:1219
virtual Size GetOptimalSize() const override
Definition: brdwin.cxx:1978
tools::Rectangle maMenuRect
Definition: brdwin.hxx:180
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: brdwin.cxx:1956
tools::Long mnOrgMenuHeight
Definition: brdwin.hxx:91
virtual OUString RequestHelp(const Point &rPos, tools::Rectangle &rHelpRect)
Definition: brdwin.cxx:129
void SetHideButton(bool bHideButton)
Definition: brdwin.cxx:1902
void SetTitleType(BorderWindowTitleType nTitleType, const Size &rSize)
Definition: brdwin.cxx:1871
void SetDockButton(bool bDockButton)
Definition: brdwin.cxx:1894
DrawButtonFlags mnHelpState
Definition: brdwin.hxx:202
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:200
DrawButtonFlags mnHideState
Definition: brdwin.hxx:201
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:1224
static void ImplInitTitle(ImplBorderFrameData *pData)
Definition: brdwin.cxx:139
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: brdwin.cxx:1986
virtual void Init(OutputDevice *pDev, tools::Long nWidth, tools::Long nHeight) override
Definition: brdwin.cxx:359
tools::Rectangle maTitleRect
Definition: brdwin.hxx:177
ImplSmallBorderWindowView(ImplBorderWindow *pBorderWindow)
Definition: brdwin.cxx:381
virtual void DrawWindow(vcl::RenderContext &rRenderContext, const Point *pOffset=nullptr) override
Definition: brdwin.cxx:578
ImplBorderWindow(const ImplBorderWindow &)=delete
virtual ~ImplBorderWindow() override
Definition: brdwin.cxx:1587
WindowBorderStyle
Definition: vclenum.hxx:106
tools::Long mnMinWidth
Definition: brdwin.hxx:87
tools::Long mnNoTitleTop
Definition: brdwin.hxx:194
tools::Rectangle maDockRect
Definition: brdwin.hxx:179
void SetMenuButton(bool bMenuButton)
Definition: brdwin.cxx:1910
tools::Long mnTrackWidth
Definition: brdwin.hxx:188
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:755
DrawButtonFlags mnDockState
Definition: brdwin.hxx:199
virtual tools::Long CalcTitleWidth() const override
Definition: brdwin.cxx:372
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: brdwin.cxx:1600