Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / syswin.hxx
blob9dd1e4fb9b6981957daa40c8daebebf3ed64c28b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/window.hxx>
27 #include <vcl/idle.hxx>
29 class ModalDialog;
30 class MenuBar;
31 class TaskPaneList;
32 class VclContainer;
34 // - Icon-Types -
35 #define ICON_LO_DEFAULT 1
36 #define ICON_TEXT_DOCUMENT 2
37 #define ICON_SPREADSHEET_DOCUMENT 4
38 #define ICON_DRAWING_DOCUMENT 6
39 #define ICON_PRESENTATION_DOCUMENT 8
40 #define ICON_TEMPLATE 11
41 #define ICON_DATABASE_DOCUMENT 12
42 #define ICON_MATH_DOCUMENT 13
43 #define ICON_MACROLIBRARY 1
46 // - WindowStateData -
49 #define WINDOWSTATE_MASK_X ((sal_uLong)0x00000001)
50 #define WINDOWSTATE_MASK_Y ((sal_uLong)0x00000002)
51 #define WINDOWSTATE_MASK_WIDTH ((sal_uLong)0x00000004)
52 #define WINDOWSTATE_MASK_HEIGHT ((sal_uLong)0x00000008)
53 #define WINDOWSTATE_MASK_STATE ((sal_uLong)0x00000010)
54 #define WINDOWSTATE_MASK_MINIMIZED ((sal_uLong)0x00000020)
55 #define WINDOWSTATE_MASK_MAXIMIZED_X ((sal_uLong)0x00000100)
56 #define WINDOWSTATE_MASK_MAXIMIZED_Y ((sal_uLong)0x00000200)
57 #define WINDOWSTATE_MASK_MAXIMIZED_WIDTH ((sal_uLong)0x00000400)
58 #define WINDOWSTATE_MASK_MAXIMIZED_HEIGHT ((sal_uLong)0x00000800)
59 #define WINDOWSTATE_MASK_POS (WINDOWSTATE_MASK_X | WINDOWSTATE_MASK_Y)
60 #define WINDOWSTATE_MASK_ALL (WINDOWSTATE_MASK_X | WINDOWSTATE_MASK_Y | WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT | WINDOWSTATE_MASK_MAXIMIZED_X | WINDOWSTATE_MASK_MAXIMIZED_Y | WINDOWSTATE_MASK_MAXIMIZED_WIDTH | WINDOWSTATE_MASK_MAXIMIZED_HEIGHT | WINDOWSTATE_MASK_STATE | WINDOWSTATE_MASK_MINIMIZED)
62 #define WINDOWSTATE_STATE_NORMAL ((sal_uLong)0x00000001)
63 #define WINDOWSTATE_STATE_MINIMIZED ((sal_uLong)0x00000002)
64 #define WINDOWSTATE_STATE_MAXIMIZED ((sal_uLong)0x00000004)
65 #define WINDOWSTATE_STATE_ROLLUP ((sal_uLong)0x00000008)
66 #define WINDOWSTATE_STATE_MAXIMIZED_HORZ ((sal_uLong)0x00000010)
67 #define WINDOWSTATE_STATE_MAXIMIZED_VERT ((sal_uLong)0x00000020)
68 #define WINDOWSTATE_STATE_SYSTEMMASK ((sal_uLong)0x0000FFFF)
70 class VCL_PLUGIN_PUBLIC WindowStateData
72 private:
73 sal_uInt32 mnValidMask;
74 int mnX;
75 int mnY;
76 unsigned int mnWidth;
77 unsigned int mnHeight;
78 int mnMaximizedX;
79 int mnMaximizedY;
80 unsigned int mnMaximizedWidth;
81 unsigned int mnMaximizedHeight;
82 sal_uInt32 mnState;
84 public:
85 WindowStateData()
87 mnValidMask = mnX = mnY = mnWidth = mnHeight = mnState = 0;
88 mnMaximizedX = mnMaximizedY = mnMaximizedWidth = mnMaximizedHeight = 0;
91 void SetMask( sal_uLong nValidMask ) { mnValidMask = nValidMask; }
92 sal_uInt32 GetMask() const { return mnValidMask; }
94 void SetX( int nX ) { mnX = nX; }
95 int GetX() const { return mnX; }
96 void SetY( int nY ) { mnY = nY; }
97 int GetY() const { return mnY; }
98 void SetWidth( unsigned int nWidth ) { mnWidth = nWidth; }
99 unsigned int GetWidth() const { return mnWidth; }
100 void SetHeight( unsigned int nHeight ) { mnHeight = nHeight; }
101 unsigned int GetHeight() const { return mnHeight; }
102 void SetState( sal_uInt32 nState ) { mnState = nState; }
103 sal_uInt32 GetState() const { return mnState; }
104 void SetMaximizedX( int nRX ) { mnMaximizedX = nRX; }
105 int GetMaximizedX() const { return mnMaximizedX; }
106 void SetMaximizedY( int nRY ) { mnMaximizedY = nRY; }
107 int GetMaximizedY() const { return mnMaximizedY; }
108 void SetMaximizedWidth( unsigned int nRWidth ) { mnMaximizedWidth = nRWidth; }
109 unsigned int GetMaximizedWidth() const { return mnMaximizedWidth; }
110 void SetMaximizedHeight( unsigned int nRHeight ) { mnMaximizedHeight = nRHeight; }
111 unsigned int GetMaximizedHeight() const { return mnMaximizedHeight; }
115 // - SystemWindow-Types -
118 #define MENUBAR_MODE_NORMAL ((sal_uInt16)0)
119 #define MENUBAR_MODE_HIDE ((sal_uInt16)1)
121 enum class TitleButton
123 Docking = 1,
124 Hide = 2,
125 Menu = 4,
128 // - SystemWindow -
129 class VCL_DLLPUBLIC SystemWindow
130 : public vcl::Window
131 , public VclBuilderContainer
133 friend class WorkWindow;
134 class ImplData;
136 private:
137 MenuBar* mpMenuBar;
138 Size maOrgSize;
139 Size maRollUpOutSize;
140 Size maMinOutSize;
141 bool mbPinned;
142 bool mbRollUp;
143 bool mbRollFunc;
144 bool mbDockBtn;
145 bool mbHideBtn;
146 bool mbSysChild;
147 bool mbIsCalculatingInitialLayoutSize;
148 bool mbInitialLayoutDone;
149 sal_uInt16 mnMenuBarMode;
150 sal_uInt16 mnIcon;
151 ImplData* mpImplData;
152 Idle maLayoutIdle;
153 protected:
154 bool mbIsDefferedInit;
155 VclPtr<vcl::Window> mpDialogParent;
156 public:
157 using Window::ImplIsInTaskPaneList;
158 SAL_DLLPRIVATE bool ImplIsInTaskPaneList( vcl::Window* pWin );
159 SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
161 private:
162 SAL_DLLPRIVATE void Init();
163 SAL_DLLPRIVATE void ImplMoveToScreen( long& io_rX, long& io_rY, long i_nWidth, long i_nHeight, vcl::Window* i_pConfigureWin );
164 virtual void setPosSizeOnContainee(Size aSize, Window &rBox);
165 DECL_DLLPRIVATE_LINK_TYPED( ImplHandleLayoutTimerHdl, Idle*, void );
167 protected:
168 // Single argument ctors shall be explicit.
169 explicit SystemWindow(WindowType nType);
170 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>());
172 void SetWindowStateData( const WindowStateData& rData );
174 virtual void settingOptimalLayoutSize(Window *pBox);
176 SAL_DLLPRIVATE void DoInitialLayout();
177 public:
178 virtual ~SystemWindow();
179 virtual void dispose() SAL_OVERRIDE;
181 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
182 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
184 virtual bool Close();
185 virtual void TitleButtonClick( TitleButton nButton );
186 virtual void Pin();
187 virtual void Roll();
188 virtual void Resizing( Size& rSize );
189 virtual void Resize() SAL_OVERRIDE;
190 virtual Size GetOptimalSize() const SAL_OVERRIDE;
191 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) SAL_OVERRIDE;
192 bool isLayoutEnabled() const;
193 void setOptimalLayoutSize();
194 bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; }
196 void SetIcon( sal_uInt16 nIcon );
197 sal_uInt16 GetIcon() const { return mnIcon; }
198 // for systems like MacOSX which can display the URL a document is loaded from
199 // separately from the window title
200 void SetRepresentedURL( const OUString& );
202 void EnableSaveBackground( bool bSave = true );
203 bool IsSaveBackgroundEnabled() const;
205 void ShowTitleButton( TitleButton nButton, bool bVisible = true );
206 bool IsTitleButtonVisible( TitleButton nButton ) const;
208 void SetPin( bool bPin );
209 bool IsPinned() const { return mbPinned; }
211 void RollUp();
212 void RollDown();
213 bool IsRollUp() const { return mbRollUp; }
215 void SetRollUpOutputSizePixel( const Size& rSize ) { maRollUpOutSize = rSize; }
216 Size GetRollUpOutputSizePixel() const { return maRollUpOutSize; }
218 void SetMinOutputSizePixel( const Size& rSize );
219 const Size& GetMinOutputSizePixel() const { return maMinOutSize; }
220 void SetMaxOutputSizePixel( const Size& rSize );
221 const Size& GetMaxOutputSizePixel() const;
223 void SetWindowState(const OString& rStr);
224 OString GetWindowState(sal_uLong nMask = WINDOWSTATE_MASK_ALL) const;
226 void SetMenuBar(MenuBar* pMenuBar, const css::uno::Reference<css::frame::XFrame>& rFrame = css::uno::Reference<css::frame::XFrame>());
227 MenuBar* GetMenuBar() const { return mpMenuBar; }
228 void SetMenuBarMode( sal_uInt16 nMode );
229 sal_uInt16 GetMenuBarMode() const { return mnMenuBarMode; }
231 TaskPaneList* GetTaskPaneList();
232 void GetWindowStateData( WindowStateData& rData ) const;
234 virtual void SetText( const OUString& rStr ) SAL_OVERRIDE;
235 virtual OUString GetText() const SAL_OVERRIDE;
238 Returns the screen number the window is on
240 The Display Screen number is counted the same way that
241 <code>Application::GetScreenPosSizePixel</code>,
242 <code>Application::GetDisplayScreenName</code>
243 and of course <code>SystemWindow::SetScreenNumber</code>
244 are counted in.
246 In case the window is positioned on multiple screens the
247 screen number returned will be of the screen containing the
248 upper left pixel of the frame area (that is of the client
249 area on system decorated windows, or the frame area of
250 undecorated resp. owner decorated windows.
252 @returns the screen number
254 @see SystemWindow::SetScreenNumber
256 unsigned int GetScreenNumber() const;
258 Move the Window to a new screen. The same rules for
259 positioning apply as in <code>SystemWindow::GetScreenNumber</code>
261 The Display Screen number is counted the same way that
262 <code>Application::GetScreenPosSizePixel</code>,
263 <code>Application::GetDisplayScreenName</code>
264 and of course <code>SystemWindow::GetScreenNumber</code>
265 are counted in.
267 @see GetScreenNumber
269 void SetScreenNumber( unsigned int nNewScreen );
271 void SetApplicationID( const OUString &rApplicationID );
273 void SetCloseHdl(const Link<>& rLink);
274 const Link<>& GetCloseHdl() const;
276 SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutIdle.IsActive(); }
278 virtual void doDeferredInit(WinBits nBits);
281 #endif // INCLUDED_VCL_SYSWIN_HXX
283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */