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 
34 struct DialogImpl;
35 class Button;
36 class PushButton;
37 class VclBox;
38 class VclButtonBox;
39 
41 {
42 public:
43  enum class InitFlag
44  {
46  Default,
47 
49  NoParent
50  };
51 
52 private:
53  std::unique_ptr<DialogImpl> mpDialogImpl;
57  bool mbInClose;
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 
80 protected:
81  void ImplInitDialog( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
82 
84  void ImplLOKNotifier(vcl::Window* pParent);
85 
86 public:
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 
93 protected:
94  explicit Dialog( WindowType nType );
95  explicit Dialog( vcl::Window* pParent, std::u16string_view rID, const OUString& rUIXMLDescription);
96  virtual void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
97  virtual void settingOptimalLayoutSize(Window *pBox) override;
98 
99 protected:
100  friend class VclBuilder;
101  friend class SalInstanceBuilder;
102  void set_action_area(VclButtonBox* pBox);
103  void set_content_area(VclBox* pBox);
104 
105 public:
106  explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default );
107  virtual ~Dialog() override;
108  virtual void dispose() override;
109 
110  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
111  virtual void StateChanged( StateChangedType nStateChange ) override;
112  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
113  virtual void Command( const CommandEvent& rCEvt ) override;
114  virtual void PixelInvalidate(const tools::Rectangle* pRectangle) override;
115 
116  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
117  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
118  VclButtonBox* get_action_area() { return mpActionArea; }
119  VclBox* get_content_area() { return mpContentArea; }
120 
121  virtual bool Close() override;
122 
123  short Execute();
124  bool IsInExecute() const { return mbInExecute; }
125  // Return true when dialog is synchronously executed (calling ::Execute())
126  bool IsInSyncExecute() const { return mbInSyncExecute; };
127 
128  virtual FactoryFunction GetUITestFactory() const override;
129 
130 private:
131  bool ImplStartExecute();
132  static void ImplEndExecuteModal();
133  void ImplSetModalInputMode(bool bModal);
134 public:
135 
137  bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx);
138 
139  // Dialog::Execute replacement API
140 
141 
142  void EndDialog( tools::Long nResult = RET_CANCEL );
143 
144  void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
145  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
146 
147  void SetModalInputMode( bool bModal );
148  bool IsModalInputMode() const { return mbModalMode; }
149 
150  void GrabFocusToFirstControl();
151  virtual void Resize() override;
152 
153  void Activate() override;
154 
155  void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink);
156  void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink);
157  void SetLOKTunnelingState(bool bEnabled);
158 
159  void add_button(PushButton* pButton, int nResponse, bool bTransferOwnership);
160  void set_default_response(int nResponse);
161  int get_default_response() const;
162  vcl::Window* get_widget_for_response(int nResponse);
163 
164  void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
165 };
166 
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VclReferenceBase & operator=(const VclReferenceBase &)=delete
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3924
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:174
VclBox * get_content_area()
Definition: dialog.hxx:119
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
bool IsInSyncExecute() const
Definition: dialog.hxx:126
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
VclPtr< VclButtonBox > mpActionArea
Definition: dialog.hxx:61
StateChangedType
Definition: window.hxx:289
virtual void Draw(::OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags)
Definition: window.cxx:1819
sal_Int64 WinBits
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3348
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar, etc.
Definition: builder.hxx:66
bool mbModalMode
Definition: dialog.hxx:58
bool mbInSyncExecute
Definition: dialog.hxx:56
SystemTextColorFlags
bool IsModalInputMode() const
Definition: dialog.hxx:148
virtual bool Close()
Definition: syswin.cxx:260
bool mbInClose
Definition: dialog.hxx:57
VclPtr< VclBox > mpContentArea
Definition: dialog.hxx:62
virtual void doDeferredInit(WinBits nBits)
Definition: syswin.cxx:1102
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3833
bool mbInExecute
Definition: dialog.hxx:55
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
virtual void PixelInvalidate(const tools::Rectangle *pRectangle)
Notification about some rectangle of the output device got invalidated.
Definition: paint.cxx:1222
DECL_DLLPRIVATE_LINK(ImplHandleLayoutTimerHdl, Timer *, void)
bool IsInExecute() const
Definition: dialog.hxx:124
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1439
InitFlag
Definition: dialog.hxx:43
VclButtonBox * get_action_area()
Definition: dialog.hxx:118
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: syswin.cxx:101
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: syswin.cxx:987
WindowType
virtual void settingOptimalLayoutSize(Window *pBox)
Definition: syswin.cxx:1063
InitFlag mnInitFlag
Definition: dialog.hxx:59
virtual void Activate()
Definition: window.cxx:1827
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1930
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1913
std::unique_ptr< DialogImpl > mpDialogImpl
Definition: dialog.hxx:53
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:87
virtual void Resize() override
Definition: syswin.cxx:999
tools::Long mnMousePositioned
Definition: dialog.hxx:54
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36