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 #include <memory>
24 #include <vcl/dllapi.h>
25 #include <vcl/syswin.hxx>
26 #include <vcl/vclptr.hxx>
27 #include <vcl/abstdlg.hxx>
28 
29 struct DialogImpl;
30 class PushButton;
31 class VclBox;
32 class VclButtonBox;
33 
35 {
36 public:
37  enum class InitFlag
38  {
40  Default,
41 
43  NoParent
44  };
45 
46 private:
47  std::unique_ptr<DialogImpl> mpDialogImpl;
51  bool mbInClose;
53  InitFlag const mnInitFlag; // used for deferred init
54 
57 
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);
62 
63  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
64 
65  SAL_DLLPRIVATE Dialog (const Dialog &) = delete;
66  SAL_DLLPRIVATE Dialog & operator= (const Dialog &) = delete;
67 
68  DECL_DLLPRIVATE_LINK(ImplAsyncCloseHdl, void*, void);
69  DECL_DLLPRIVATE_LINK(ResponseHdl, Button*, void);
70 
71 protected:
72  void ImplInitDialog( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
73 
75  void ImplLOKNotifier(vcl::Window* pParent);
76 
77 public:
78  SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
79  virtual void doDeferredInit(WinBits nBits) override;
80  SAL_DLLPRIVATE void disposeOwnedButtons();
81 
82 protected:
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;
87 
88 protected:
89  friend class VclBuilder;
90  friend class SalInstanceBuilder;
91  void set_action_area(VclButtonBox* pBox);
92  virtual void set_content_area(VclBox* pBox);
93 
94 public:
95  explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default );
96  virtual ~Dialog() override;
97  virtual void dispose() override;
98 
99  // get the default parent for a dialog as is done in standard initialization
100  static vcl::Window* GetDefaultParent(WinBits nStyle);
101 
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;
106 
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; }
111 
112  virtual bool Close() override;
113 
114  short Execute();
115  bool IsInExecute() const { return mbInExecute; }
116  // Return true when dialog is synchronously executed (calling ::Execute())
117  bool IsInSyncExecute() const { return mbInSyncExecute; };
118 
119  virtual FactoryFunction GetUITestFactory() const override;
120 
121 private:
122  bool ImplStartExecute();
123  static void ImplEndExecuteModal();
124  void ImplSetModalInputMode(bool bModal);
125 public:
126 
128  bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx);
129 
130  // Dialog::Execute replacement API
131 
132 
133  void EndDialog( long nResult = RET_CANCEL );
134  static void EndAllDialogs( vcl::Window const * pParent );
135 
136  // returns the most recent of the currently executing modal dialogs
137  static VclPtr<Dialog> GetMostRecentExecutingDialog();
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:3889
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:169
VclBox * get_content_area()
Definition: dialog.hxx:110
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
bool IsInSyncExecute() const
Definition: dialog.hxx:117
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
VclPtr< VclButtonBox > mpActionArea
Definition: dialog.hxx:55
StateChangedType
Definition: window.hxx:311
sal_Int64 WinBits
bool mbModalMode
Definition: dialog.hxx:52
bool mbInSyncExecute
Definition: dialog.hxx:50
bool IsModalInputMode() const
Definition: dialog.hxx:143
virtual void Draw(::OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags)
Definition: window.cxx:1793
virtual bool Close()
Definition: syswin.cxx:264
bool mbInClose
Definition: dialog.hxx:51
VclPtr< VclBox > mpContentArea
Definition: dialog.hxx:56
virtual void doDeferredInit(WinBits nBits)
Definition: syswin.cxx:1152
DrawFlags
Definition: window.hxx:354
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3805
bool mbInExecute
Definition: dialog.hxx:49
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
InitFlag const mnInitFlag
Definition: dialog.hxx:53
DECL_DLLPRIVATE_LINK(ImplHandleLayoutTimerHdl, Timer *, void)
bool IsInExecute() const
Definition: dialog.hxx:115
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1420
long mnMousePositioned
Definition: dialog.hxx:48
InitFlag
Definition: dialog.hxx:37
VclButtonBox * get_action_area()
Definition: dialog.hxx:109
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: syswin.cxx:99
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: syswin.cxx:1039
WindowType
virtual void settingOptimalLayoutSize(Window *pBox)
Definition: syswin.cxx:1113
virtual void Activate()
Definition: window.cxx:1801
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1904
OutputDevice & operator=(const OutputDevice &)=delete
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1887
std::unique_ptr< DialogImpl > mpDialogImpl
Definition: dialog.hxx:47
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:78
virtual void Resize() override
Definition: syswin.cxx:1051
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35