Line data Source code
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 <tools/solar.h>
24 : #include <vcl/dllapi.h>
25 : #include <vcl/syswin.hxx>
26 : #include <vcl/timer.hxx>
27 : #include <vcl/vclptr.hxx>
28 :
29 : // - Dialog -
30 :
31 : struct DialogImpl;
32 : class VclBox;
33 : class VclButtonBox;
34 :
35 : class VCL_DLLPUBLIC Dialog : public SystemWindow
36 : {
37 : public:
38 : enum class InitFlag { Default, NoParent };
39 :
40 : private:
41 : VclPtr<Dialog> mpPrevExecuteDlg;
42 : DialogImpl* mpDialogImpl;
43 : long mnMousePositioned;
44 : bool mbInExecute;
45 : bool mbOldSaveBack;
46 : bool mbInClose;
47 : bool mbModalMode;
48 : InitFlag mnInitFlag; // used for deferred init
49 :
50 : VclPtr<VclButtonBox> mpActionArea;
51 : VclPtr<VclBox> mpContentArea;
52 :
53 : SAL_DLLPRIVATE void ImplInitDialogData();
54 : SAL_DLLPRIVATE void ImplInitSettings();
55 :
56 : virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
57 :
58 : SAL_DLLPRIVATE Dialog (const Dialog &) SAL_DELETED_FUNCTION;
59 : SAL_DLLPRIVATE Dialog & operator= (const Dialog &) SAL_DELETED_FUNCTION;
60 :
61 : DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void* );
62 :
63 : protected:
64 : using Window::ImplInit;
65 : SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
66 :
67 : public:
68 134 : SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
69 : virtual void doDeferredInit(WinBits nBits) SAL_OVERRIDE;
70 :
71 : protected:
72 : explicit Dialog( WindowType nType );
73 : explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag = InitFlag::Default );
74 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) SAL_OVERRIDE;
75 : virtual void settingOptimalLayoutSize(Window *pBox) SAL_OVERRIDE;
76 :
77 : protected:
78 : friend class VclBuilder;
79 : void set_action_area(VclButtonBox* pBox);
80 : void set_content_area(VclBox* pBox);
81 :
82 : public:
83 : explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default );
84 : explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription );
85 : virtual ~Dialog();
86 : virtual void dispose() SAL_OVERRIDE;
87 :
88 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
89 : virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
90 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
91 :
92 : virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) SAL_OVERRIDE;
93 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
94 0 : VclButtonBox* get_action_area() { return mpActionArea; }
95 0 : VclBox* get_content_area() { return mpContentArea; }
96 :
97 : virtual bool Close() SAL_OVERRIDE;
98 :
99 : virtual short Execute();
100 1 : bool IsInExecute() const { return mbInExecute; }
101 :
102 : // Dialog::Execute replacement API
103 : public:
104 : // Link impl: DECL_LINK( MyEndDialogHdl, Dialog* ); <= param is dialog just ended
105 : virtual void StartExecuteModal( const Link<>& rEndDialogHdl );
106 : long GetResult() const;
107 : private:
108 : bool ImplStartExecuteModal();
109 : static void ImplEndExecuteModal();
110 : public:
111 :
112 : // Dialog::Execute replacement API
113 :
114 :
115 : void EndDialog( long nResult = 0 );
116 : static void EndAllDialogs( vcl::Window* pParent=NULL );
117 :
118 : void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
119 : sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
120 :
121 : void SetModalInputMode( bool bModal );
122 : void SetModalInputMode( bool bModal, bool bSubModalDialogs );
123 0 : bool IsModalInputMode() const { return mbModalMode; }
124 :
125 : void GrabFocusToFirstControl();
126 : };
127 :
128 : // - ModelessDialog -
129 0 : class VCL_DLLPUBLIC ModelessDialog : public Dialog
130 : {
131 : ModelessDialog (const ModelessDialog &) SAL_DELETED_FUNCTION;
132 : ModelessDialog & operator= (const ModelessDialog &) SAL_DELETED_FUNCTION;
133 :
134 : public:
135 : explicit ModelessDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, Dialog::InitFlag eFlag = Dialog::InitFlag::Default );
136 : };
137 :
138 : // - ModalDialog -
139 1 : class VCL_DLLPUBLIC ModalDialog : public Dialog
140 : {
141 : public:
142 : explicit ModalDialog( vcl::Window* pParent, WinBits nStyle = WB_STDMODAL );
143 : explicit ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription );
144 :
145 : protected:
146 : using Window::Show;
147 : void Show( bool bVisible = true );
148 : using Window::Hide;
149 : void Hide();
150 :
151 : private:
152 :
153 : SAL_DLLPRIVATE ModalDialog (const ModalDialog &) SAL_DELETED_FUNCTION;
154 : SAL_DLLPRIVATE ModalDialog & operator= (const ModalDialog &) SAL_DELETED_FUNCTION;
155 : };
156 :
157 : #endif // INCLUDED_VCL_DIALOG_HXX
158 :
159 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|