Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / dialog.hxx
blob8c63e57c74157fbbf78412a1f80036db41f4cc9d
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_DIALOG_HXX
21 #define INCLUDED_VCL_DIALOG_HXX
23 #include <memory>
24 #include <tools/solar.h>
25 #include <vcl/dllapi.h>
26 #include <vcl/syswin.hxx>
27 #include <vcl/vclptr.hxx>
30 struct DialogImpl;
31 class VclBox;
32 class VclButtonBox;
34 class VCL_DLLPUBLIC Dialog : public SystemWindow
36 public:
37 enum class InitFlag { Default, NoParent };
39 private:
40 VclPtr<Dialog> mpPrevExecuteDlg;
41 std::unique_ptr<DialogImpl> mpDialogImpl;
42 long mnMousePositioned;
43 bool mbInExecute;
44 bool mbInClose;
45 bool mbModalMode;
46 bool mbPaintComplete;
47 InitFlag mnInitFlag; // used for deferred init
49 VclPtr<VclButtonBox> mpActionArea;
50 VclPtr<VclBox> mpContentArea;
52 SAL_DLLPRIVATE void ImplInitDialogData();
53 SAL_DLLPRIVATE void ImplInitSettings();
55 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
57 SAL_DLLPRIVATE Dialog (const Dialog &) = delete;
58 SAL_DLLPRIVATE Dialog & operator= (const Dialog &) = delete;
60 DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void*, void );
62 protected:
63 using Window::ImplInit;
64 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
66 public:
67 SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
68 virtual void doDeferredInit(WinBits nBits) override;
70 protected:
71 explicit Dialog( WindowType nType );
72 explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag = InitFlag::Default );
73 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) override;
74 virtual void settingOptimalLayoutSize(Window *pBox) override;
76 protected:
77 friend class VclBuilder;
78 void set_action_area(VclButtonBox* pBox);
79 void set_content_area(VclBox* pBox);
81 public:
82 explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default );
83 explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription );
84 virtual ~Dialog() override;
85 virtual void dispose() override;
87 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
88 virtual void StateChanged( StateChangedType nStateChange ) override;
89 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
91 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
92 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
93 VclButtonBox* get_action_area() { return mpActionArea; }
94 VclBox* get_content_area() { return mpContentArea; }
96 virtual bool Close() override;
98 // try to extract content and return as Bitmap. To do that reliably, a Yield-loop
99 // like in Execute() has to be executed and it is necessary to detect when the
100 // paint is finished
101 virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
102 virtual void PostPaint(vcl::RenderContext& rRenderContext) override;
104 // ensureRepaint - triggers Application::Yield until the dialog is
105 // completely repainted. Sometimes needed for dialogs showing progress
106 // during actions
107 void ensureRepaint();
109 // Screenshot interface
110 virtual std::vector<OString> getAllPageUIXMLDescriptions() const;
111 virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription);
112 Bitmap createScreenshot();
114 virtual short Execute();
115 bool IsInExecute() const { return mbInExecute; }
117 virtual FactoryFunction GetUITestFactory() const override;
119 // Dialog::Execute replacement API
120 public:
121 virtual void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl );
122 long GetResult() const;
123 private:
124 bool ImplStartExecuteModal();
125 static void ImplEndExecuteModal();
126 public:
128 // Dialog::Execute replacement API
131 void EndDialog( long nResult = 0 );
132 static void EndAllDialogs( vcl::Window* pParent );
134 void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
135 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
137 void SetModalInputMode( bool bModal );
138 void SetModalInputMode( bool bModal, bool bSubModalDialogs );
139 bool IsModalInputMode() const { return mbModalMode; }
141 void GrabFocusToFirstControl();
144 class VCL_DLLPUBLIC ModelessDialog : public Dialog
146 ModelessDialog (const ModelessDialog &) = delete;
147 ModelessDialog & operator= (const ModelessDialog &) = delete;
149 public:
150 explicit ModelessDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, Dialog::InitFlag eFlag = Dialog::InitFlag::Default );
153 class VCL_DLLPUBLIC ModalDialog : public Dialog
155 public:
156 explicit ModalDialog( vcl::Window* pParent, WinBits nStyle = WB_STDMODAL );
157 explicit ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription );
159 protected:
160 using Window::Show;
161 using Window::Hide;
163 private:
165 SAL_DLLPRIVATE ModalDialog (const ModalDialog &) = delete;
166 SAL_DLLPRIVATE ModalDialog & operator= (const ModalDialog &) = delete;
169 #endif // INCLUDED_VCL_DIALOG_HXX
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */