lokdialog: Move the Notifier down to vcl::Window.
[LibreOffice.git] / include / vcl / dialog.hxx
blob4347917b76753a8629536d1e9f5001ed5e056774
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>
28 #include <vcl/IDialogRenderable.hxx>
30 struct DialogImpl;
31 class VclBox;
32 class VclButtonBox;
34 class VCL_DLLPUBLIC Dialog : public SystemWindow
36 public:
37 enum class InitFlag
39 /** Use given parent or get a default one using GetDefaultParent(...) */
40 Default,
42 /** No Parent */
43 NoParent
46 private:
47 VclPtr<Dialog> mpPrevExecuteDlg;
48 std::unique_ptr<DialogImpl> mpDialogImpl;
49 long mnMousePositioned;
50 bool mbInExecute;
51 bool mbInClose;
52 bool mbModalMode;
53 bool mbPaintComplete;
54 bool mbForceBorderWindow;
55 InitFlag mnInitFlag; // used for deferred init
57 VclPtr<VclButtonBox> mpActionArea;
58 VclPtr<VclBox> mpContentArea;
60 SAL_DLLPRIVATE void ImplInitDialogData();
61 SAL_DLLPRIVATE void ImplInitSettings();
62 SAL_DLLPRIVATE VclPtr<vcl::Window> AddBorderWindow(vcl::Window* pParent, WinBits nBits);
64 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
66 SAL_DLLPRIVATE Dialog (const Dialog &) = delete;
67 SAL_DLLPRIVATE Dialog & operator= (const Dialog &) = delete;
69 DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void*, void );
71 protected:
72 using Window::ImplInit;
73 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
75 public:
76 SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
77 virtual void doDeferredInit(WinBits nBits) override;
78 virtual void LogicInvalidate(const tools::Rectangle* pRectangle) override;
79 void InvalidateFloatingWindow(const Point& rPos);
80 void CloseFloatingWindow();
81 Size PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
83 /// Paints the current dialog to the given virtual device
84 void paintDialog(VirtualDevice& rDevice);
85 void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
86 void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
87 void LogicMouseMove(const MouseEvent& rMouseEvent);
88 void LogicMouseButtonDownChild(const MouseEvent& rMouseEvent);
89 void LogicMouseButtonUpChild(const MouseEvent& rMouseEvent);
90 void LogicMouseMoveChild(const MouseEvent& rMouseEvent);
92 void LOKKeyInput(const KeyEvent& rKeyEvent);
93 void LOKKeyUp(const KeyEvent& rKeyEvent);
94 void LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload);
96 protected:
97 explicit Dialog( WindowType nType );
98 explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag = InitFlag::Default, bool bBorder = false );
99 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) override;
100 virtual void settingOptimalLayoutSize(Window *pBox) override;
102 protected:
103 friend class VclBuilder;
104 void set_action_area(VclButtonBox* pBox);
105 void set_content_area(VclBox* pBox);
107 public:
108 explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default );
109 explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription );
110 virtual ~Dialog() override;
111 virtual void dispose() override;
113 // get the default parent for a dialog as is done in standard initialization
114 static vcl::Window* GetDefaultParent(WinBits nStyle);
116 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
117 virtual void StateChanged( StateChangedType nStateChange ) override;
118 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
120 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
121 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
122 VclButtonBox* get_action_area() { return mpActionArea; }
123 VclBox* get_content_area() { return mpContentArea; }
125 virtual bool Close() override;
127 // try to extract content and return as Bitmap. To do that reliably, a Yield-loop
128 // like in Execute() has to be executed and it is necessary to detect when the
129 // paint is finished
130 virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
131 virtual void PostPaint(vcl::RenderContext& rRenderContext) override;
133 // ensureRepaint - triggers Application::Yield until the dialog is
134 // completely repainted. Sometimes needed for dialogs showing progress
135 // during actions
136 void ensureRepaint();
138 // Screenshot interface
139 virtual std::vector<OString> getAllPageUIXMLDescriptions() const;
140 virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription);
141 Bitmap createScreenshot();
143 virtual short Execute();
144 bool IsInExecute() const { return mbInExecute; }
146 virtual FactoryFunction GetUITestFactory() const override;
148 // Dialog::Execute replacement API
149 public:
150 virtual void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl );
151 long GetResult() const;
152 private:
153 bool ImplStartExecuteModal();
154 static void ImplEndExecuteModal();
155 void ImplSetModalInputMode(bool bModal);
156 public:
158 // Dialog::Execute replacement API
161 void EndDialog( long nResult = 0 );
162 static void EndAllDialogs( vcl::Window const * pParent );
164 void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
165 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
167 void SetModalInputMode( bool bModal );
168 bool IsModalInputMode() const { return mbModalMode; }
170 void GrabFocusToFirstControl();
171 virtual void Resize() override;
174 class VCL_DLLPUBLIC ModelessDialog : public Dialog
176 ModelessDialog (const ModelessDialog &) = delete;
177 ModelessDialog & operator= (const ModelessDialog &) = delete;
179 public:
180 explicit ModelessDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, Dialog::InitFlag eFlag = Dialog::InitFlag::Default );
183 class VCL_DLLPUBLIC ModalDialog : public Dialog
185 public:
186 explicit ModalDialog( vcl::Window* pParent, WinBits nStyle = WB_STDMODAL );
187 explicit ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, bool bBorder = false );
189 protected:
190 using Window::Show;
191 using Window::Hide;
193 private:
195 SAL_DLLPRIVATE ModalDialog (const ModalDialog &) = delete;
196 SAL_DLLPRIVATE ModalDialog & operator= (const ModalDialog &) = delete;
199 #endif // INCLUDED_VCL_DIALOG_HXX
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */