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 #ifndef INCLUDED_VCL_DIALOG_HXX
21 #define INCLUDED_VCL_DIALOG_HXX
22 
23 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
24 #error "don't use this in new code"
25 #endif
26 
27 #include <memory>
28 #include <vcl/dllapi.h>
29 #include <vcl/syswin.hxx>
30 #include <vcl/vclptr.hxx>
31 #include <vcl/abstdlg.hxx>
32 
33 struct DialogImpl;
34 class PushButton;
35 class VclBox;
36 class VclButtonBox;
37 
39 {
40 public:
41  enum class InitFlag
42  {
44  Default,
45 
47  NoParent
48  };
49 
50 private:
51  std::unique_ptr<DialogImpl> mpDialogImpl;
55  bool mbInClose;
57  InitFlag mnInitFlag; // used for deferred init
58 
61 
62  SAL_DLLPRIVATE void RemoveFromDlgList();
63  SAL_DLLPRIVATE void ImplInitDialogData();
64  SAL_DLLPRIVATE void ImplInitSettings();
65  SAL_DLLPRIVATE VclPtr<vcl::Window> AddBorderWindow(vcl::Window* pParent, WinBits nBits);
66 
67  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
68 
69  SAL_DLLPRIVATE Dialog (const Dialog &) = delete;
70  SAL_DLLPRIVATE Dialog & operator= (const Dialog &) = delete;
71 
72  DECL_DLLPRIVATE_LINK(ImplAsyncCloseHdl, void*, void);
73  DECL_DLLPRIVATE_LINK(ResponseHdl, Button*, void);
74 
75 protected:
76  void ImplInitDialog( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
77 
79  void ImplLOKNotifier(vcl::Window* pParent);
80 
81 public:
82  SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
83  virtual void doDeferredInit(WinBits nBits) override;
84  SAL_DLLPRIVATE void disposeOwnedButtons();
85 
86 protected:
87  explicit Dialog( WindowType nType );
88  explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription);
89  virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override;
90  virtual void settingOptimalLayoutSize(Window *pBox) override;
91 
92 protected:
93  friend class VclBuilder;
94  friend class SalInstanceBuilder;
95  void set_action_area(VclButtonBox* pBox);
96  virtual void set_content_area(VclBox* pBox);
97 
98 public:
99  explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default );
100  virtual ~Dialog() override;
101  virtual void dispose() override;
102 
103  // get the default parent for a dialog as is done in standard initialization
104  static vcl::Window* GetDefaultParent(WinBits nStyle);
105 
106  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
107  virtual void StateChanged( StateChangedType nStateChange ) override;
108  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
109  virtual void Command( const CommandEvent& rCEvt ) override;
110 
111  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
112  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
113  VclButtonBox* get_action_area() { return mpActionArea; }
114  VclBox* get_content_area() { return mpContentArea; }
115 
116  virtual bool Close() override;
117 
118  short Execute();
119  bool IsInExecute() const { return mbInExecute; }
120  // Return true when dialog is synchronously executed (calling ::Execute())
121  bool IsInSyncExecute() const { return mbInSyncExecute; };
122 
123  virtual FactoryFunction GetUITestFactory() const override;
124 
125 private:
126  bool ImplStartExecute();
127  static void ImplEndExecuteModal();
128  void ImplSetModalInputMode(bool bModal);
129 public:
130 
132  bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx);
133 
134  // Dialog::Execute replacement API
135 
136 
137  void EndDialog( tools::Long nResult = RET_CANCEL );
138 
139  void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
140  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
141 
142  void SetModalInputMode( bool bModal );
143  bool IsModalInputMode() const { return mbModalMode; }
144 
145  void GrabFocusToFirstControl();
146  virtual void Resize() override;
147 
148  void Activate() override;
149 
150  void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink);
151  void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink);
152 
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);
157 };
158 
159 #endif // INCLUDED_VCL_DIALOG_HXX
160 
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3915
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:171
VclBox * get_content_area()
Definition: dialog.hxx:114
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
bool IsInSyncExecute() const
Definition: dialog.hxx:121
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
VclPtr< VclButtonBox > mpActionArea
Definition: dialog.hxx:59
StateChangedType
Definition: window.hxx:317
sal_Int64 WinBits
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar, etc.
Definition: builder.hxx:65
bool mbModalMode
Definition: dialog.hxx:56
bool mbInSyncExecute
Definition: dialog.hxx:54
bool IsModalInputMode() const
Definition: dialog.hxx:143
virtual bool Close()
Definition: syswin.cxx:266
bool mbInClose
Definition: dialog.hxx:55
VclPtr< VclBox > mpContentArea
Definition: dialog.hxx:60
virtual void doDeferredInit(WinBits nBits)
Definition: syswin.cxx:1154
DrawFlags
Definition: window.hxx:360
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3831
bool mbInExecute
Definition: dialog.hxx:53
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
virtual void Draw(::OutputDevice *pDev, const Point &rPos, DrawFlags nFlags)
Definition: window.cxx:1825
DECL_DLLPRIVATE_LINK(ImplHandleLayoutTimerHdl, Timer *, void)
bool IsInExecute() const
Definition: dialog.hxx:119
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1445
InitFlag
Definition: dialog.hxx:41
VclButtonBox * get_action_area()
Definition: dialog.hxx:113
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:1041
WindowType
virtual void settingOptimalLayoutSize(Window *pBox)
Definition: syswin.cxx:1115
InitFlag mnInitFlag
Definition: dialog.hxx:57
virtual void Activate()
Definition: window.cxx:1833
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1936
OutputDevice & operator=(const OutputDevice &)=delete
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1919
std::unique_ptr< DialogImpl > mpDialogImpl
Definition: dialog.hxx:51
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:82
virtual void Resize() override
Definition: syswin.cxx:1053
tools::Long mnMousePositioned
Definition: dialog.hxx:52
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35