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 .
20 #ifndef INCLUDED_VCL_SYSWIN_HXX
21 #define INCLUDED_VCL_SYSWIN_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/builder.hxx>
26 #include <vcl/idle.hxx>
27 #include <vcl/notebookbar.hxx>
28 #include <vcl/window.hxx>
29 #include <o3tl/typed_flags_set.hxx>
37 #define ICON_LO_DEFAULT 1
38 #define ICON_TEXT_DOCUMENT 2
39 #define ICON_SPREADSHEET_DOCUMENT 4
40 #define ICON_DRAWING_DOCUMENT 6
41 #define ICON_PRESENTATION_DOCUMENT 8
42 #define ICON_TEMPLATE 11
43 #define ICON_DATABASE_DOCUMENT 12
44 #define ICON_MATH_DOCUMENT 13
45 #define ICON_MACROLIBRARY 1
47 enum class WindowStateMask
{
57 MaximizedWidth
= 0x0400,
58 MaximizedHeight
= 0x0800,
60 All
= X
| Y
| Width
| Height
| MaximizedX
| MaximizedY
| MaximizedWidth
| MaximizedHeight
| State
| Minimized
64 template<> struct typed_flags
<WindowStateMask
> : is_typed_flags
<WindowStateMask
, 0x0f3f> {};
67 enum class WindowStateState
{
73 MaximizedHorz
= 0x0010,
74 MaximizedVert
= 0x0020,
79 template<> struct typed_flags
<WindowStateState
> : is_typed_flags
<WindowStateState
, 0xffff> {};
82 class VCL_PLUGIN_PUBLIC WindowStateData
85 WindowStateMask mnValidMask
;
89 unsigned int mnHeight
;
92 unsigned int mnMaximizedWidth
;
93 unsigned int mnMaximizedHeight
;
94 WindowStateState mnState
;
98 : mnValidMask(WindowStateMask::NONE
)
105 , mnMaximizedWidth(0)
106 , mnMaximizedHeight(0)
107 , mnState(WindowStateState::NONE
)
111 void SetMask( WindowStateMask nValidMask
) { mnValidMask
= nValidMask
; }
112 WindowStateMask
GetMask() const { return mnValidMask
; }
114 void SetX( int nX
) { mnX
= nX
; }
115 int GetX() const { return mnX
; }
116 void SetY( int nY
) { mnY
= nY
; }
117 int GetY() const { return mnY
; }
118 void SetWidth( unsigned int nWidth
) { mnWidth
= nWidth
; }
119 unsigned int GetWidth() const { return mnWidth
; }
120 void SetHeight( unsigned int nHeight
) { mnHeight
= nHeight
; }
121 unsigned int GetHeight() const { return mnHeight
; }
122 void SetState( WindowStateState nState
) { mnState
= nState
; }
123 WindowStateState
GetState() const { return mnState
; }
124 void SetMaximizedX( int nRX
) { mnMaximizedX
= nRX
; }
125 int GetMaximizedX() const { return mnMaximizedX
; }
126 void SetMaximizedY( int nRY
) { mnMaximizedY
= nRY
; }
127 int GetMaximizedY() const { return mnMaximizedY
; }
128 void SetMaximizedWidth( unsigned int nRWidth
) { mnMaximizedWidth
= nRWidth
; }
129 unsigned int GetMaximizedWidth() const { return mnMaximizedWidth
; }
130 void SetMaximizedHeight( unsigned int nRHeight
) { mnMaximizedHeight
= nRHeight
; }
131 unsigned int GetMaximizedHeight() const { return mnMaximizedHeight
; }
135 enum class MenuBarMode
140 enum class TitleButton
147 class VCL_DLLPUBLIC SystemWindow
149 , public VclBuilderContainer
151 friend class WorkWindow
;
155 VclPtr
<MenuBar
> mpMenuBar
;
157 Size maRollUpOutSize
;
164 bool mbIsCalculatingInitialLayoutSize
;
165 MenuBarMode mnMenuBarMode
;
167 std::unique_ptr
<ImplData
> mpImplData
;
169 OUString maNotebookBarUIFile
;
171 bool mbIsDefferedInit
;
172 VclPtr
<vcl::Window
> mpDialogParent
;
174 using Window::ImplIsInTaskPaneList
;
175 SAL_DLLPRIVATE
bool ImplIsInTaskPaneList( vcl::Window
* pWin
);
176 SAL_DLLPRIVATE
bool isDeferredInit() const { return mbIsDefferedInit
; }
179 SAL_DLLPRIVATE
void ImplMoveToScreen( long& io_rX
, long& io_rY
, long i_nWidth
, long i_nHeight
, vcl::Window
* i_pConfigureWin
);
180 SAL_DLLPRIVATE
void setPosSizeOnContainee(Size aSize
, Window
&rBox
);
181 DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl
, Timer
*, void );
184 // Single argument ctors shall be explicit.
185 explicit SystemWindow(WindowType nType
);
186 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
>());
188 void SetWindowStateData( const WindowStateData
& rData
);
190 virtual void settingOptimalLayoutSize(Window
*pBox
);
192 SAL_DLLPRIVATE
void DoInitialLayout();
194 SAL_DLLPRIVATE
void SetIdleDebugName( const sal_Char
*pDebugName
);
196 virtual ~SystemWindow() override
;
197 virtual void dispose() override
;
199 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
200 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
202 virtual bool Close();
203 virtual void TitleButtonClick( TitleButton nButton
);
204 virtual void Resizing( Size
& rSize
);
205 virtual void Resize() override
;
206 virtual Size
GetOptimalSize() const override
;
207 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
208 bool isLayoutEnabled() const;
209 void setOptimalLayoutSize();
210 bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize
; }
212 void SetIcon( sal_uInt16 nIcon
);
213 sal_uInt16
GetIcon() const { return mnIcon
; }
214 // for systems like MacOSX which can display the URL a document is loaded from
215 // separately from the window title
216 void SetRepresentedURL( const OUString
& );
218 void ShowTitleButton( TitleButton nButton
, bool bVisible
);
219 bool IsTitleButtonVisible( TitleButton nButton
) const;
223 bool IsRollUp() const { return mbRollUp
; }
225 void SetRollUpOutputSizePixel( const Size
& rSize
) { maRollUpOutSize
= rSize
; }
226 const Size
& GetRollUpOutputSizePixel() const { return maRollUpOutSize
; }
228 void SetMinOutputSizePixel( const Size
& rSize
);
229 const Size
& GetMinOutputSizePixel() const { return maMinOutSize
; }
230 void SetMaxOutputSizePixel( const Size
& rSize
);
231 const Size
& GetMaxOutputSizePixel() const;
233 void SetWindowState(const OString
& rStr
);
234 OString
GetWindowState(WindowStateMask nMask
= WindowStateMask::All
) const;
236 void SetMenuBar(MenuBar
* pMenuBar
);
237 MenuBar
* GetMenuBar() const { return mpMenuBar
; }
238 void SetMenuBarMode( MenuBarMode nMode
);
240 void SetNotebookBar(const OUString
& rUIXMLDescription
, const css::uno::Reference
<css::frame::XFrame
>& rFrame
);
241 void CloseNotebookBar();
242 VclPtr
<NotebookBar
> GetNotebookBar() const;
244 TaskPaneList
* GetTaskPaneList();
245 void GetWindowStateData( WindowStateData
& rData
) const;
247 virtual void SetText( const OUString
& rStr
) override
;
248 virtual OUString
GetText() const override
;
251 Returns the screen number the window is on
253 The Display Screen number is counted the same way that
254 <code>Application::GetScreenPosSizePixel</code>
255 and of course <code>SystemWindow::SetScreenNumber</code>
258 In case the window is positioned on multiple screens the
259 screen number returned will be of the screen containing the
260 upper left pixel of the frame area (that is of the client
261 area on system decorated windows, or the frame area of
262 undecorated resp. owner decorated windows.
264 @returns the screen number
266 @see SystemWindow::SetScreenNumber
268 unsigned int GetScreenNumber() const;
270 Move the Window to a new screen. The same rules for
271 positioning apply as in <code>SystemWindow::GetScreenNumber</code>
273 The Display Screen number is counted the same way that
274 <code>Application::GetScreenPosSizePixel</code>
275 and of course <code>SystemWindow::GetScreenNumber</code>
280 void SetScreenNumber( unsigned int nNewScreen
);
282 void SetApplicationID( const OUString
&rApplicationID
);
284 void SetCloseHdl(const Link
<SystemWindow
&,void>& rLink
);
285 const Link
<SystemWindow
&,void>& GetCloseHdl() const;
287 SAL_DLLPRIVATE
bool hasPendingLayout() const { return maLayoutIdle
.IsActive(); }
289 virtual void doDeferredInit(WinBits nBits
);
292 inline void SystemWindow::SetIdleDebugName( const sal_Char
*pDebugName
)
294 maLayoutIdle
.SetDebugName( pDebugName
);
297 #endif // INCLUDED_VCL_SYSWIN_HXX
299 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */