1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
30 class SalInstanceBuilder
;
33 class MnemonicGenerator
;
37 struct NotebookBarAddonsItem
;
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
49 enum class MenuBarMode
54 enum class TitleButton
61 //helper baseclass to ease retro fitting dialogs/tabpages that load a resource
62 //to load a .ui file instead
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.
69 //i.e. class Dialog : public SystemWindow, public VclBuilderContainer
70 //not class Dialog : public VclBuilderContainer, public SystemWindow
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.
76 class VCL_DLLPUBLIC VclBuilderContainer
79 VclBuilderContainer();
80 virtual ~VclBuilderContainer();
81 void disposeBuilder();
83 void setDeferredProperties();
86 std::unique_ptr
<VclBuilder
> m_pUIBuilder
;
88 friend class ::SalInstanceBuilder
;
89 friend class ::ScreenshotTest
;
92 class VCL_DLLPUBLIC SystemWindow
94 , public VclBuilderContainer
96 friend class WorkWindow
;
100 VclPtr
<MenuBar
> mpMenuBar
;
105 bool mbIsCalculatingInitialLayoutSize
;
106 bool mbPaintComplete
;
107 MenuBarMode mnMenuBarMode
;
109 std::unique_ptr
<ImplData
> mpImplData
;
111 OUString maNotebookBarUIFile
;
113 bool mbIsDeferredInit
;
114 VclPtr
<vcl::Window
> mpDialogParent
;
116 using Window::ImplIsInTaskPaneList
;
117 SAL_DLLPRIVATE
bool ImplIsInTaskPaneList( vcl::Window
* pWin
);
118 SAL_DLLPRIVATE
bool isDeferredInit() const { return mbIsDeferredInit
; }
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 );
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
128 virtual void PrePaint(vcl::RenderContext
& rRenderContext
) override
;
129 virtual void PostPaint(vcl::RenderContext
& rRenderContext
) override
;
131 // ensureRepaint - triggers Application::Yield until the dialog is
132 // completely repainted. Sometimes needed for dialogs showing progress
134 SAL_DLLPRIVATE
void ensureRepaint();
137 // Single argument ctors shall be explicit.
138 explicit SystemWindow(WindowType nType
, const char* pIdleDebugName
);
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
>());
141 void SetWindowStateData( const WindowStateData
& rData
);
143 virtual void settingOptimalLayoutSize(Window
*pBox
);
145 SAL_DLLPRIVATE
void DoInitialLayout();
148 virtual ~SystemWindow() override
;
149 virtual void dispose() override
;
151 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
152 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
154 virtual bool Close();
155 virtual void TitleButtonClick( TitleButton nButton
);
156 virtual void Resizing( Size
& rSize
);
157 virtual void Resize() override
;
158 virtual Size
GetOptimalSize() const override
;
159 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
160 bool isLayoutEnabled() const;
161 void setOptimalLayoutSize();
162 bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize
; }
164 void SetIcon( sal_uInt16 nIcon
);
165 sal_uInt16
GetIcon() const { return mnIcon
; }
166 // for systems like MacOSX which can display the URL a document is loaded from
167 // separately from the window title
168 void SetRepresentedURL( const OUString
& );
170 void ShowTitleButton( TitleButton nButton
, bool bVisible
);
171 bool IsTitleButtonVisible( TitleButton nButton
) const;
173 void SetMinOutputSizePixel( const Size
& rSize
);
174 const Size
& GetMinOutputSizePixel() const { return maMinOutSize
; }
175 void SetMaxOutputSizePixel( const Size
& rSize
);
176 const Size
& GetMaxOutputSizePixel() const;
178 void SetWindowState(const OString
& rStr
);
179 OString
GetWindowState(WindowStateMask nMask
= WindowStateMask::All
) const;
181 void SetMenuBar(MenuBar
* pMenuBar
);
182 MenuBar
* GetMenuBar() const { return mpMenuBar
; }
183 void SetMenuBarMode( MenuBarMode nMode
);
184 void CollectMenuBarMnemonics(MnemonicGenerator
& rMnemonicGenerator
) const;
185 int GetMenuBarHeight() const;
187 void SetNotebookBar(const OUString
& rUIXMLDescription
,
188 const css::uno::Reference
<css::frame::XFrame
>& rFrame
,
189 const NotebookBarAddonsItem
& aNotebookBarAddonsItem
,
190 bool bReloadNotebookbar
= false);
192 void CloseNotebookBar();
193 VclPtr
<NotebookBar
> const & GetNotebookBar() const;
195 TaskPaneList
* GetTaskPaneList();
196 void GetWindowStateData( WindowStateData
& rData
) const;
198 virtual void SetText( const OUString
& rStr
) override
;
199 virtual OUString
GetText() const override
;
202 Returns the screen number the window is on
204 The Display Screen number is counted the same way that
205 <code>Application::GetScreenPosSizePixel</code>
206 and of course <code>SystemWindow::SetScreenNumber</code>
209 In case the window is positioned on multiple screens the
210 screen number returned will be of the screen containing the
211 upper left pixel of the frame area (that is of the client
212 area on system decorated windows, or the frame area of
213 undecorated resp. owner decorated windows.
215 @returns the screen number
217 @see SystemWindow::SetScreenNumber
219 unsigned int GetScreenNumber() const;
221 Move the Window to a new screen. The same rules for
222 positioning apply as in <code>SystemWindow::GetScreenNumber</code>
224 The Display Screen number is counted the same way that
225 <code>Application::GetScreenPosSizePixel</code>
226 and of course <code>SystemWindow::GetScreenNumber</code>
231 void SetScreenNumber( unsigned int nNewScreen
);
233 void SetApplicationID( const OUString
&rApplicationID
);
235 bool UpdatePositionData();
237 void SetCloseHdl(const Link
<SystemWindow
&,void>& rLink
);
238 const Link
<SystemWindow
&,void>& GetCloseHdl() const;
240 SAL_DLLPRIVATE
bool hasPendingLayout() const { return maLayoutIdle
.IsActive(); }
242 virtual void doDeferredInit(WinBits nBits
);
244 // Screenshot interface
245 VclPtr
<VirtualDevice
> createScreenshot();
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */