LibreOffice Module vcl (master) 1
dialog.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23#error "don't use this in new code"
24#endif
25
26#include <memory>
27#include <string_view>
28
29#include <vcl/dllapi.h>
30#include <vcl/syswin.hxx>
31#include <vcl/vclptr.hxx>
32#include <vcl/abstdlg.hxx>
33
34struct DialogImpl;
35class Button;
36class PushButton;
37class VclBox;
38class VclButtonBox;
39
41{
42public:
43 enum class InitFlag
44 {
46 Default,
47
49 NoParent
50 };
51
52private:
53 std::unique_ptr<DialogImpl> mpDialogImpl;
59 InitFlag mnInitFlag; // used for deferred init
60
63
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);
68
69 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
70
71 SAL_DLLPRIVATE Dialog (const Dialog &) = delete;
72 SAL_DLLPRIVATE Dialog & operator= (const Dialog &) = delete;
73
74 DECL_DLLPRIVATE_LINK(ImplAsyncCloseHdl, void*, void);
75 DECL_DLLPRIVATE_LINK(ResponseHdl, Button*, void);
76
77 // get the default parent for a dialog as is done in standard initialization
78 SAL_DLLPRIVATE static vcl::Window* GetDefaultParent(WinBits nStyle);
79
80protected:
81 void ImplInitDialog( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
82
84 void ImplLOKNotifier(vcl::Window* pParent);
85
86public:
87 SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
88 virtual void doDeferredInit(WinBits nBits) override;
89 SAL_DLLPRIVATE void disposeOwnedButtons();
90
91 SAL_DLLPRIVATE static vcl::Window* GetDefDialogParent();
92
93protected:
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;
98
99protected:
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();
105
106public:
107 explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default );
108 virtual ~Dialog() override;
109 virtual void dispose() override;
110
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;
116
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; }
121
122 virtual bool Close() override;
123
124 short Execute();
125 bool IsInExecute() const { return mbInExecute; }
126 // Return true when dialog is synchronously executed (calling ::Execute())
127 bool IsInSyncExecute() const { return mbInSyncExecute; };
128
129 virtual FactoryFunction GetUITestFactory() const override;
130
131private:
132 bool ImplStartExecute();
133 static void ImplEndExecuteModal();
134 void ImplSetModalInputMode(bool bModal);
135
136public:
137
139 bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx);
140
141 // Dialog::Execute replacement API
142
143
144 void EndDialog( tools::Long nResult = RET_CANCEL );
145
146 void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
147 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
148
149 void SetModalInputMode( bool bModal );
150 bool IsModalInputMode() const { return mbModalMode; }
151
152 void GrabFocusToFirstControl();
153 virtual void Resize() override;
154
155 void Activate() override;
156
157 void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink);
158 void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink);
159 void SetLOKTunnelingState(bool bEnabled);
160
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);
165
166 void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
167};
168
169/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SystemTextColorFlags
VclBox * get_content_area()
Definition: dialog.hxx:120
DECL_DLLPRIVATE_LINK(ResponseHdl, Button *, void)
bool IsInExecute() const
Definition: dialog.hxx:125
bool mbModalMode
Definition: dialog.hxx:58
bool mbInExecute
Definition: dialog.hxx:55
bool IsInSyncExecute() const
Definition: dialog.hxx:127
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:87
InitFlag
Definition: dialog.hxx:44
std::unique_ptr< DialogImpl > mpDialogImpl
Definition: dialog.hxx:53
bool mbInClose
Definition: dialog.hxx:57
DECL_DLLPRIVATE_LINK(ImplAsyncCloseHdl, void *, void)
bool mbInSyncExecute
Definition: dialog.hxx:56
tools::Long mnMousePositioned
Definition: dialog.hxx:54
VclButtonBox * get_action_area()
Definition: dialog.hxx:119
VclPtr< VclButtonBox > mpActionArea
Definition: dialog.hxx:61
SAL_DLLPRIVATE Dialog(const Dialog &)=delete
InitFlag mnInitFlag
Definition: dialog.hxx:59
VclPtr< VclBox > mpContentArea
Definition: dialog.hxx:62
bool IsModalInputMode() const
Definition: dialog.hxx:150
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: syswin.cxx:981
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:176
virtual void settingOptimalLayoutSize(Window *pBox)
Definition: syswin.cxx:1057
virtual void doDeferredInit(WinBits nBits)
Definition: syswin.cxx:1105
virtual bool Close()
Definition: syswin.cxx:262
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: syswin.cxx:103
virtual void Resize() override
Definition: syswin.cxx:993
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar,...
Definition: builder.hxx:69
VclReferenceBase & operator=(const VclReferenceBase &)=delete
virtual void PixelInvalidate(const tools::Rectangle *pRectangle)
Notification about some rectangle of the output device got invalidated.
Definition: paint.cxx:1201
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1940
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1923
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: window.cxx:3356
virtual void Draw(::OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags)
Definition: window.cxx:1829
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3850
virtual void Activate()
Definition: window.cxx:1837
virtual bool set_property(const OUString &rKey, const OUString &rValue)
Definition: window2.cxx:1478
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3941
virtual void EndDialog(sal_Int32 nResult) override
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
long Long
@ RET_CANCEL
Definition: vclenum.hxx:205
StateChangedType
Definition: window.hxx:291
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_STDDIALOG
Definition: wintypes.hxx:216
WindowType
Definition: wintypes.hxx:27