LibreOffice Module vcl (master)  1
syswin.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 #pragma once
21 
22 #include <vcl/dllapi.h>
23 #include <vcl/idle.hxx>
24 #include <vcl/vclenum.hxx>
25 #include <vcl/window.hxx>
26 #include <vcl/windowstate.hxx>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <memory>
29 
30 class SalInstanceBuilder;
31 class ScreenshotTest;
32 class MenuBar;
33 class MnemonicGenerator;
34 class NotebookBar;
35 class TaskPaneList;
36 class VclBuilder;
38 
39 #define ICON_LO_DEFAULT 1
40 #define ICON_TEXT_DOCUMENT 2
41 #define ICON_SPREADSHEET_DOCUMENT 4
42 #define ICON_DRAWING_DOCUMENT 6
43 #define ICON_PRESENTATION_DOCUMENT 8
44 #define ICON_TEMPLATE 11
45 #define ICON_DATABASE_DOCUMENT 12
46 #define ICON_MATH_DOCUMENT 13
47 #define ICON_MACROLIBRARY 1
48 
49 enum class MenuBarMode
50 {
51  Normal, Hide
52 };
53 
54 enum class TitleButton
55 {
56  Docking = 1,
57  Hide = 2,
58  Menu = 4,
59 };
60 
61 //helper baseclass to ease retro fitting dialogs/tabpages that load a resource
62 //to load a .ui file instead
63 //
64 //vcl requires the Window Children of a Parent Window to be destroyed before
65 //the Parent Window. VclBuilderContainer owns the VclBuilder which owns the
66 //Children Window. So the VclBuilderContainer dtor must be called before
67 //the Parent Window dtor.
68 //
69 //i.e. class Dialog : public SystemWindow, public VclBuilderContainer
70 //not class Dialog : public VclBuilderContainer, public SystemWindow
71 //
72 //With the new 'dispose' framework, it is necessary to force the builder
73 //dispose before the Window dispose; so a Dialog::dispose() method would
74 //finish: disposeBuilder(); SystemWindow::dispose() to capture this ordering.
75 
77 {
78 public:
80  virtual ~VclBuilderContainer();
81  void disposeBuilder();
82 
83  void setDeferredProperties();
84 
85 protected:
86  std::unique_ptr<VclBuilder> m_pUIBuilder;
87 
88  friend class ::SalInstanceBuilder;
89  friend class ::ScreenshotTest;
90 };
91 
93  : public vcl::Window
94  , public VclBuilderContainer
95 {
96  friend class WorkWindow;
97  class ImplData;
98 
99 private:
102  bool mbDockBtn;
103  bool mbHideBtn;
109  sal_uInt16 mnIcon;
110  std::unique_ptr<ImplData> mpImplData;
113 protected:
116 public:
118  SAL_DLLPRIVATE bool ImplIsInTaskPaneList( vcl::Window* pWin );
119  SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; }
120 
121 private:
122  SAL_DLLPRIVATE void ImplMoveToScreen( tools::Long& io_rX, tools::Long& io_rY, tools::Long i_nWidth, tools::Long i_nHeight, vcl::Window const * i_pConfigureWin );
123  SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox);
124  DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void );
125 
126  // try to extract content and return as Bitmap. To do that reliably, a Yield-loop
127  // like in Execute() has to be executed and it is necessary to detect when the
128  // paint is finished
129  virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
130  virtual void PostPaint(vcl::RenderContext& rRenderContext) override;
131 
132  // ensureRepaint - triggers Application::Yield until the dialog is
133  // completely repainted. Sometimes needed for dialogs showing progress
134  // during actions
135  SAL_DLLPRIVATE void ensureRepaint();
136 
137 protected:
138  // Single argument ctors shall be explicit.
139  explicit SystemWindow(WindowType nType, const char* pIdleDebugName);
140  void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
141 
142  void SetWindowState(const vcl::WindowData& rData);
143 
144  virtual void settingOptimalLayoutSize(Window *pBox);
145 
146  SAL_DLLPRIVATE void DoInitialLayout();
147 
148 public:
149  virtual ~SystemWindow() override;
150  virtual void dispose() override;
151 
152  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
153  virtual bool PreNotify( NotifyEvent& rNEvt ) override;
154 
155  virtual bool Close();
156  virtual void TitleButtonClick( TitleButton nButton );
157  virtual void Resizing( Size& rSize );
158  virtual void Resize() override;
159  virtual Size GetOptimalSize() const override;
160  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
161  bool isLayoutEnabled() const;
162  void setOptimalLayoutSize(bool bAllowWindowShrink);
163  bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; }
164 
165  void SetIcon( sal_uInt16 nIcon );
166  sal_uInt16 GetIcon() const { return mnIcon; }
167  // for systems like MacOSX which can display the URL a document is loaded from
168  // separately from the window title
169  void SetRepresentedURL( const OUString& );
170 
171  void ShowTitleButton( TitleButton nButton, bool bVisible );
172  bool IsTitleButtonVisible( TitleButton nButton ) const;
173 
174  void SetMinOutputSizePixel( const Size& rSize );
175  const Size& GetMinOutputSizePixel() const { return maMinOutSize; }
176  void SetMaxOutputSizePixel( const Size& rSize );
177  const Size& GetMaxOutputSizePixel() const;
178 
179  void SetWindowState(std::string_view rStr);
180  OString GetWindowState(vcl::WindowDataMask nMask = vcl::WindowDataMask::All) const;
181 
182  void SetMenuBar(MenuBar* pMenuBar);
183  MenuBar* GetMenuBar() const { return mpMenuBar; }
184  void SetMenuBarMode( MenuBarMode nMode );
185  void CollectMenuBarMnemonics(MnemonicGenerator& rMnemonicGenerator) const;
186  int GetMenuBarHeight() const;
187 
188  void SetNotebookBar(const OUString& rUIXMLDescription,
189  const css::uno::Reference<css::frame::XFrame>& rFrame,
190  const NotebookBarAddonsItem& aNotebookBarAddonsItem,
191  bool bReloadNotebookbar = false);
192 
193  void CloseNotebookBar();
194  VclPtr<NotebookBar> const & GetNotebookBar() const;
195 
196  TaskPaneList* GetTaskPaneList();
197  void GetWindowState(vcl::WindowData& rData) const;
198 
199  virtual void SetText( const OUString& rStr ) override;
200  virtual OUString GetText() const override;
201 
220  unsigned int GetScreenNumber() const;
232  void SetScreenNumber( unsigned int nNewScreen );
233 
234  void SetApplicationID( const OUString &rApplicationID );
235 
236  bool UpdatePositionData();
237 
238  void SetCloseHdl(const Link<SystemWindow&,void>& rLink);
239  const Link<SystemWindow&,void>& GetCloseHdl() const;
240 
241  SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutIdle.IsActive(); }
242 
243  virtual void doDeferredInit(WinBits nBits);
244 
245  // Screenshot interface
247 };
248 
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3031
SAL_DLLPRIVATE bool isDeferredInit() const
Definition: syswin.hxx:119
SAL_DLLPRIVATE void ImplIsInTaskPaneList(bool mbIsInTaskList)
Definition: window.cxx:3630
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
VclPtr< MenuBar > mpMenuBar
Definition: syswin.hxx:97
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
bool mbInitialLayoutSizeCalculated
Definition: syswin.hxx:106
virtual Size GetOptimalSize() const
Definition: window3.cxx:26
std::unique_ptr< ImplData > mpImplData
Definition: syswin.hxx:110
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: window.cxx:140
bool IsActive() const
Definition: task.hxx:101
StateChangedType
Definition: window.hxx:289
sal_Int64 WinBits
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar, etc.
Definition: builder.hxx:67
virtual BitmapEx createScreenshot() const override
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1350
virtual OUString GetText() const
Definition: window.cxx:3060
Idle maLayoutIdle
Definition: syswin.hxx:111
WindowDataMask
Definition: windowstate.hxx:42
const Size & GetMinOutputSizePixel() const
Definition: syswin.hxx:175
virtual void PrePaint(vcl::RenderContext &rRenderContext)
Definition: paint.cxx:1012
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
virtual bool EventNotify(NotifyEvent &rNEvt)
Definition: event.cxx:104
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:175
bool isCalculatingInitialLayoutSize() const
Definition: syswin.hxx:163
sal_uInt16 mnIcon
Definition: syswin.hxx:109
virtual void Resize()
Definition: window.cxx:1837
bool mbIsDeferredInit
Definition: syswin.hxx:114
std::unique_ptr< VclBuilder > m_pUIBuilder
Definition: syswin.hxx:86
bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:2917
OUString maNotebookBarUIFile
Definition: syswin.hxx:112
Size maMinOutSize
Definition: syswin.hxx:101
SAL_DLLPRIVATE bool hasPendingLayout() const
Definition: syswin.hxx:241
Definition: menu.hxx:115
WindowType
MenuBar * GetMenuBar() const
Definition: syswin.hxx:183
bool mbDockBtn
Definition: syswin.hxx:102
MenuBarMode mnMenuBarMode
Definition: syswin.hxx:108
VclPtr< vcl::Window > mpDialogParent
Definition: syswin.hxx:115
sal_uInt16 GetIcon() const
Definition: syswin.hxx:166
bool mbHideBtn
Definition: syswin.hxx:103
Definition: timer.hxx:26
bool mbIsCalculatingInitialLayoutSize
Definition: syswin.hxx:105
virtual void PostPaint(vcl::RenderContext &rRenderContext)
Definition: paint.cxx:1016
bool mbPaintComplete
Definition: syswin.hxx:107
This implements Widget Layout-based notebook-like menu bar.
Definition: notebookbar.hxx:27
bool mbSysChild
Definition: syswin.hxx:104
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
TitleButton
Definition: syswin.hxx:54
MenuBarMode
Definition: syswin.hxx:49