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 .
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
27 #include <string_view>
29 #include <vcl/dllapi.h>
30 #include <vcl/syswin.hxx>
31 #include <vcl/vclptr.hxx>
32 #include <vcl/abstdlg.hxx>
40 class VCL_DLLPUBLIC Dialog
: public SystemWindow
45 /** Use given parent or get a default one using GetDefaultParent(...) */
53 std::unique_ptr
<DialogImpl
> mpDialogImpl
;
54 tools::Long mnMousePositioned
;
59 InitFlag mnInitFlag
; // used for deferred init
61 VclPtr
<VclButtonBox
> mpActionArea
;
62 VclPtr
<VclBox
> mpContentArea
;
64 SAL_DLLPRIVATE
void RemoveFromDlgList();
65 SAL_DLLPRIVATE
void ImplInitDialogData();
66 SAL_DLLPRIVATE
void ImplInitSettings();
67 SAL_DLLPRIVATE VclPtr
<vcl::Window
> AddBorderWindow(vcl::Window
* pParent
, WinBits nBits
);
69 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
71 SAL_DLLPRIVATE
Dialog (const Dialog
&) = delete;
72 SAL_DLLPRIVATE Dialog
& operator= (const Dialog
&) = delete;
74 DECL_DLLPRIVATE_LINK(ImplAsyncCloseHdl
, void*, void);
75 DECL_DLLPRIVATE_LINK(ResponseHdl
, Button
*, void);
77 // get the default parent for a dialog as is done in standard initialization
78 SAL_DLLPRIVATE
static vcl::Window
* GetDefaultParent(WinBits nStyle
);
81 void ImplInitDialog( vcl::Window
* pParent
, WinBits nStyle
, InitFlag eFlag
= InitFlag::Default
);
82 virtual void ImplDeferredInit(vcl::Window
* pParent
, WinBits nBits
) override
;
84 /// Find and set the LOK notifier according to the pParent.
85 void ImplLOKNotifier(vcl::Window
* pParent
);
88 SAL_DLLPRIVATE
bool IsInClose() const { return mbInClose
; }
89 SAL_DLLPRIVATE
void disposeOwnedButtons();
91 SAL_DLLPRIVATE
static vcl::Window
* GetDefDialogParent();
94 explicit Dialog( WindowType nType
);
95 explicit Dialog( vcl::Window
* pParent
, const OUString
& rID
, const OUString
& rUIXMLDescription
);
96 virtual void Draw( OutputDevice
* pDev
, const Point
& rPos
, SystemTextColorFlags nFlags
) override
;
97 virtual void settingOptimalLayoutSize(Window
*pBox
) override
;
100 friend class VclBuilder
;
101 friend class SalInstanceBuilder
;
102 void set_action_area(VclButtonBox
* pBox
);
103 void set_content_area(VclBox
* pBox
);
104 vcl::Window
* GetFirstControlForFocus();
107 explicit Dialog( vcl::Window
* pParent
, WinBits nStyle
= WB_STDDIALOG
, InitFlag eFlag
= InitFlag::Default
);
108 virtual ~Dialog() override
;
109 virtual void dispose() override
;
111 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
112 virtual void StateChanged( StateChangedType nStateChange
) override
;
113 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
114 virtual void Command( const CommandEvent
& rCEvt
) override
;
115 virtual void PixelInvalidate(const tools::Rectangle
* pRectangle
) override
;
117 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
118 virtual bool set_property(const OUString
&rKey
, const OUString
&rValue
) override
;
119 VclButtonBox
* get_action_area() { return mpActionArea
; }
120 VclBox
* get_content_area() { return mpContentArea
; }
122 virtual bool Close() override
;
125 bool IsInExecute() const { return mbInExecute
; }
126 // Return true when dialog is synchronously executed (calling ::Execute())
127 bool IsInSyncExecute() const { return mbInSyncExecute
; };
129 virtual FactoryFunction
GetUITestFactory() const override
;
132 bool ImplStartExecute();
133 static void ImplEndExecuteModal();
134 void ImplSetModalInputMode(bool bModal
);
138 /// Commence execution of a modal dialog, disposes owner on failure
139 bool StartExecuteAsync(VclAbstractDialog::AsyncContext
&rCtx
);
141 // Dialog::Execute replacement API
144 void EndDialog( tools::Long nResult
= RET_CANCEL
);
146 void GetDrawWindowBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
147 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const;
149 void SetModalInputMode( bool bModal
);
150 bool IsModalInputMode() const { return mbModalMode
; }
152 void GrabFocusToFirstControl();
153 virtual void Resize() override
;
155 void Activate() override
;
157 void SetPopupMenuHdl(const Link
<const CommandEvent
&, bool>& rLink
);
158 void SetInstallLOKNotifierHdl(const Link
<void*, vcl::ILibreOfficeKitNotifier
*>& rLink
);
159 void SetLOKTunnelingState(bool bEnabled
);
161 void add_button(PushButton
* pButton
, int nResponse
, bool bTransferOwnership
);
162 void set_default_response(int nResponse
);
163 int get_default_response() const;
164 vcl::Window
* get_widget_for_response(int nResponse
);
166 void DumpAsPropertyTree(tools::JsonWriter
& rJsonWriter
) override
;
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */