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_DIALOG_HXX
21 #define INCLUDED_VCL_DIALOG_HXX
24 #include <vcl/dllapi.h>
25 #include <vcl/syswin.hxx>
26 #include <vcl/vclptr.hxx>
27 #include <vcl/abstdlg.hxx>
34 class VCL_DLLPUBLIC Dialog
: public SystemWindow
39 /** Use given parent or get a default one using GetDefaultParent(...) */
47 std::unique_ptr
<DialogImpl
> mpDialogImpl
;
48 long mnMousePositioned
;
53 InitFlag
const mnInitFlag
; // used for deferred init
55 VclPtr
<VclButtonBox
> mpActionArea
;
56 VclPtr
<VclBox
> mpContentArea
;
58 SAL_DLLPRIVATE
void RemoveFromDlgList();
59 SAL_DLLPRIVATE
void ImplInitDialogData();
60 SAL_DLLPRIVATE
void ImplInitSettings();
61 SAL_DLLPRIVATE VclPtr
<vcl::Window
> AddBorderWindow(vcl::Window
* pParent
, WinBits nBits
);
63 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
65 SAL_DLLPRIVATE
Dialog (const Dialog
&) = delete;
66 SAL_DLLPRIVATE Dialog
& operator= (const Dialog
&) = delete;
68 DECL_DLLPRIVATE_LINK(ImplAsyncCloseHdl
, void*, void);
69 DECL_DLLPRIVATE_LINK(ResponseHdl
, Button
*, void);
72 void ImplInitDialog( vcl::Window
* pParent
, WinBits nStyle
, InitFlag eFlag
= InitFlag::Default
);
74 /// Find and set the LOK notifier according to the pParent.
75 void ImplLOKNotifier(vcl::Window
* pParent
);
78 SAL_DLLPRIVATE
bool IsInClose() const { return mbInClose
; }
79 virtual void doDeferredInit(WinBits nBits
) override
;
80 SAL_DLLPRIVATE
void disposeOwnedButtons();
83 explicit Dialog( WindowType nType
);
84 explicit Dialog( vcl::Window
* pParent
, const OUString
& rID
, const OUString
& rUIXMLDescription
);
85 virtual void Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, DrawFlags nFlags
) override
;
86 virtual void settingOptimalLayoutSize(Window
*pBox
) override
;
89 friend class VclBuilder
;
90 friend class SalInstanceBuilder
;
91 void set_action_area(VclButtonBox
* pBox
);
92 virtual void set_content_area(VclBox
* pBox
);
95 explicit Dialog( vcl::Window
* pParent
, WinBits nStyle
= WB_STDDIALOG
, InitFlag eFlag
= InitFlag::Default
);
96 virtual ~Dialog() override
;
97 virtual void dispose() override
;
99 // get the default parent for a dialog as is done in standard initialization
100 static vcl::Window
* GetDefaultParent(WinBits nStyle
);
102 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
103 virtual void StateChanged( StateChangedType nStateChange
) override
;
104 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
105 virtual void Command( const CommandEvent
& rCEvt
) override
;
107 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
108 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
109 VclButtonBox
* get_action_area() { return mpActionArea
; }
110 VclBox
* get_content_area() { return mpContentArea
; }
112 virtual bool Close() override
;
115 bool IsInExecute() const { return mbInExecute
; }
116 // Return true when dialog is synchronously executed (calling ::Execute())
117 bool IsInSyncExecute() const { return mbInSyncExecute
; };
119 virtual FactoryFunction
GetUITestFactory() const override
;
122 bool ImplStartExecute();
123 static void ImplEndExecuteModal();
124 void ImplSetModalInputMode(bool bModal
);
127 /// Commence execution of a modal dialog, disposes owner on failure
128 bool StartExecuteAsync(VclAbstractDialog::AsyncContext
&rCtx
);
130 // Dialog::Execute replacement API
133 void EndDialog( long nResult
= RET_CANCEL
);
134 static void EndAllDialogs( vcl::Window
const * pParent
);
136 // returns the most recent of the currently executing modal dialogs
137 static VclPtr
<Dialog
> GetMostRecentExecutingDialog();
139 void GetDrawWindowBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
140 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const;
142 void SetModalInputMode( bool bModal
);
143 bool IsModalInputMode() const { return mbModalMode
; }
145 void GrabFocusToFirstControl();
146 virtual void Resize() override
;
148 void Activate() override
;
150 void SetPopupMenuHdl(const Link
<const CommandEvent
&, bool>& rLink
);
151 void SetInstallLOKNotifierHdl(const Link
<void*, vcl::ILibreOfficeKitNotifier
*>& rLink
);
153 void add_button(PushButton
* pButton
, int nResponse
, bool bTransferOwnership
);
154 void set_default_response(int nResponse
);
155 int get_default_response() const;
156 vcl::Window
* get_widget_for_response(int nResponse
);
159 #endif // INCLUDED_VCL_DIALOG_HXX
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */