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;
108  sal_uInt16 mnIcon;
109  std::unique_ptr<ImplData> mpImplData;
112 protected:
115 public:
117  SAL_DLLPRIVATE bool ImplIsInTaskPaneList( vcl::Window* pWin );
118  SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; }
119 
120 private:
121  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 );
122  SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox);
123  DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void );
124 
125  // try to extract content and return as Bitmap. To do that reliably, a Yield-loop
126  // like in Execute() has to be executed and it is necessary to detect when the
127  // paint is finished
128  virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
129  virtual void PostPaint(vcl::RenderContext& rRenderContext) override;
130 
131  // ensureRepaint - triggers Application::Yield until the dialog is
132  // completely repainted. Sometimes needed for dialogs showing progress
133  // during actions
134  SAL_DLLPRIVATE void ensureRepaint();
135 
136 protected:
137  // Single argument ctors shall be explicit.
138  explicit SystemWindow(WindowType nType);
139  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>());
140 
141  void SetWindowStateData( const WindowStateData& rData );
142 
143  virtual void settingOptimalLayoutSize(Window *pBox);
144 
145  SAL_DLLPRIVATE void DoInitialLayout();
146 
147  SAL_DLLPRIVATE void SetIdleDebugName( const char *pDebugName );
148 
149 public:
150  virtual ~SystemWindow() override;
151  virtual void dispose() override;
152 
153  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
154  virtual bool PreNotify( NotifyEvent& rNEvt ) override;
155 
156  virtual bool Close();
157  virtual void TitleButtonClick( TitleButton nButton );
158  virtual void Resizing( Size& rSize );
159  virtual void Resize() override;
160  virtual Size GetOptimalSize() const override;
161  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
162  bool isLayoutEnabled() const;
163  void setOptimalLayoutSize();
164  bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; }
165 
166  void SetIcon( sal_uInt16 nIcon );
167  sal_uInt16 GetIcon() const { return mnIcon; }
168  // for systems like MacOSX which can display the URL a document is loaded from
169  // separately from the window title
170  void SetRepresentedURL( const OUString& );
171 
172  void ShowTitleButton( TitleButton nButton, bool bVisible );
173  bool IsTitleButtonVisible( TitleButton nButton ) const;
174 
175  void SetMinOutputSizePixel( const Size& rSize );
176  const Size& GetMinOutputSizePixel() const { return maMinOutSize; }
177  void SetMaxOutputSizePixel( const Size& rSize );
178  const Size& GetMaxOutputSizePixel() const;
179 
180  void SetWindowState(const OString& rStr);
181  OString GetWindowState(WindowStateMask nMask = WindowStateMask::All) const;
182 
183  void SetMenuBar(MenuBar* pMenuBar);
184  MenuBar* GetMenuBar() const { return mpMenuBar; }
185  void SetMenuBarMode( MenuBarMode nMode );
186  void CollectMenuBarMnemonics(MnemonicGenerator& rMnemonicGenerator) const;
187  int GetMenuBarHeight() const;
188 
189  void SetNotebookBar(const OUString& rUIXMLDescription,
190  const css::uno::Reference<css::frame::XFrame>& rFrame,
191  const NotebookBarAddonsItem& aNotebookBarAddonsItem,
192  bool bReloadNotebookbar = false);
193 
194  void CloseNotebookBar();
195  VclPtr<NotebookBar> const & GetNotebookBar() const;
196 
197  TaskPaneList* GetTaskPaneList();
198  void GetWindowStateData( WindowStateData& rData ) const;
199 
200  virtual void SetText( const OUString& rStr ) override;
201  virtual OUString GetText() const override;
202 
221  unsigned int GetScreenNumber() const;
233  void SetScreenNumber( unsigned int nNewScreen );
234 
235  void SetApplicationID( const OUString &rApplicationID );
236 
237  bool UpdatePositionData();
238 
239  void SetCloseHdl(const Link<SystemWindow&,void>& rLink);
240  const Link<SystemWindow&,void>& GetCloseHdl() const;
241 
242  SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutIdle.IsActive(); }
243 
244  virtual void doDeferredInit(WinBits nBits);
245 
246  // Screenshot interface
247  VclPtr<VirtualDevice> createScreenshot();
248 };
249 
250 inline void SystemWindow::SetIdleDebugName( const char *pDebugName )
251 {
252  maLayoutIdle.SetDebugName( pDebugName );
253 }
254 
255 
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3015
SAL_DLLPRIVATE bool isDeferredInit() const
Definition: syswin.hxx:118
SAL_DLLPRIVATE void ImplIsInTaskPaneList(bool mbIsInTaskList)
Definition: window.cxx:3613
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
VclPtr< MenuBar > mpMenuBar
Definition: syswin.hxx:97
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
virtual Size GetOptimalSize() const
Definition: window3.cxx:26
std::unique_ptr< ImplData > mpImplData
Definition: syswin.hxx:109
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: window.cxx:137
bool IsActive() const
Definition: task.hxx:102
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:66
WindowStateMask
Definition: vclenum.hxx:121
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1326
virtual OUString GetText() const
Definition: window.cxx:3044
Idle maLayoutIdle
Definition: syswin.hxx:110
const Size & GetMinOutputSizePixel() const
Definition: syswin.hxx:176
void SetDebugName(const char *pDebugName)
Definition: task.hxx:82
virtual void PrePaint(vcl::RenderContext &rRenderContext)
Definition: paint.cxx:1013
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:162
bool isCalculatingInitialLayoutSize() const
Definition: syswin.hxx:164
sal_uInt16 mnIcon
Definition: syswin.hxx:108
virtual void Resize()
Definition: window.cxx:1825
bool mbIsDeferredInit
Definition: syswin.hxx:113
std::unique_ptr< VclBuilder > m_pUIBuilder
Definition: syswin.hxx:86
bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:2884
OUString maNotebookBarUIFile
Definition: syswin.hxx:111
Size maMinOutSize
Definition: syswin.hxx:101
SAL_DLLPRIVATE bool hasPendingLayout() const
Definition: syswin.hxx:242
Definition: menu.hxx:124
WindowType
MenuBar * GetMenuBar() const
Definition: syswin.hxx:184
bool mbDockBtn
Definition: syswin.hxx:102
MenuBarMode mnMenuBarMode
Definition: syswin.hxx:107
VclPtr< vcl::Window > mpDialogParent
Definition: syswin.hxx:114
sal_uInt16 GetIcon() const
Definition: syswin.hxx:167
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:1017
bool mbPaintComplete
Definition: syswin.hxx:106
This implements Widget Layout-based notebook-like menu bar.
Definition: notebookbar.hxx:26
bool mbSysChild
Definition: syswin.hxx:104
SAL_DLLPRIVATE void SetIdleDebugName(const char *pDebugName)
Definition: syswin.hxx:250
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
TitleButton
Definition: syswin.hxx:54
MenuBarMode
Definition: syswin.hxx:49