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 _SV_DIALOG_HXX
21 : #define _SV_DIALOG_HXX
22 :
23 : #include <tools/solar.h>
24 : #include <vcl/dllapi.h>
25 : #include <vcl/builder.hxx>
26 : #include <vcl/syswin.hxx>
27 : #include <vcl/timer.hxx>
28 :
29 : // parameter to pass to the dialog constructor if really no parent is wanted
30 : // whereas NULL chooses the default dialog parent
31 : #define DIALOG_NO_PARENT ((Window*)0xffffffff)
32 :
33 : // ----------
34 : // - Dialog -
35 : // ----------
36 : struct DialogImpl;
37 : class VclBox;
38 : class VclButtonBox;
39 : class VclContainer;
40 :
41 : class VCL_DLLPUBLIC Dialog
42 : : public SystemWindow
43 : , public VclBuilderContainer
44 : {
45 : private:
46 : Window* mpDialogParent;
47 : Dialog* mpPrevExecuteDlg;
48 : DialogImpl* mpDialogImpl;
49 : long mnMousePositioned;
50 : sal_Bool mbInExecute;
51 : sal_Bool mbOldSaveBack;
52 : sal_Bool mbInClose;
53 : sal_Bool mbModalMode;
54 : bool mbIsDefferedInit;
55 : Timer maLayoutTimer;
56 :
57 : SAL_DLLPRIVATE void ImplInitDialogData();
58 : SAL_DLLPRIVATE void ImplInitSettings();
59 :
60 : // Copy assignment is forbidden and not implemented.
61 : SAL_DLLPRIVATE Dialog (const Dialog &);
62 : SAL_DLLPRIVATE Dialog & operator= (const Dialog &);
63 :
64 : DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void* );
65 : DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* );
66 :
67 : protected:
68 : using Window::ImplInit;
69 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
70 : SAL_DLLPRIVATE void ImplDialogRes( const ResId& rResId );
71 : SAL_DLLPRIVATE WinBits init(Window *pParent, const ResId& rResId);
72 :
73 : SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclContainer &rBox);
74 : public:
75 0 : SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; }
76 0 : SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); }
77 : SAL_DLLPRIVATE void doDeferredInit(bool bResizable);
78 0 : SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
79 :
80 : protected:
81 : Dialog( WindowType nType );
82 : Dialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription, WindowType nType );
83 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
84 :
85 : public:
86 : Dialog( Window* pParent, WinBits nStyle = WB_STDDIALOG );
87 : Dialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription );
88 : virtual ~Dialog();
89 :
90 : virtual long Notify( NotifyEvent& rNEvt );
91 : virtual void StateChanged( StateChangedType nStateChange );
92 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
93 :
94 : virtual Size GetOptimalSize(WindowSizeType eType) const;
95 : virtual void Resize();
96 : bool isLayoutEnabled() const;
97 : void setInitialLayoutSize();
98 : void queue_layout();
99 : virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue);
100 : VclButtonBox* get_action_area();
101 : VclBox* get_content_area();
102 :
103 : virtual sal_Bool Close();
104 :
105 : virtual short Execute();
106 0 : sal_Bool IsInExecute() const { return mbInExecute; }
107 :
108 : ////////////////////////////////////////
109 : // Dialog::Execute replacement API
110 : public:
111 : // Link impl: DECL_LINK( MyEndDialogHdl, Dialog* ); <= param is dialog just ended
112 : virtual void StartExecuteModal( const Link& rEndDialogHdl );
113 : long GetResult() const;
114 : private:
115 : sal_Bool ImplStartExecuteModal();
116 : void ImplEndExecuteModal();
117 : public:
118 :
119 : // Dialog::Execute replacement API
120 : ////////////////////////////////////////
121 :
122 : void EndDialog( long nResult = 0 );
123 : static void EndAllDialogs( Window* pParent=NULL );
124 :
125 : void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
126 : sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
127 :
128 : void SetModalInputMode( sal_Bool bModal );
129 : void SetModalInputMode( sal_Bool bModal, sal_Bool bSubModalDialogs );
130 : sal_Bool IsModalInputMode() const { return mbModalMode; }
131 :
132 : void GrabFocusToFirstControl();
133 : };
134 :
135 : // ------------------
136 : // - ModelessDialog -
137 : // ------------------
138 :
139 0 : class VCL_DLLPUBLIC ModelessDialog : public Dialog
140 : {
141 : // Copy assignment is forbidden and not implemented.
142 : SAL_DLLPRIVATE ModelessDialog (const ModelessDialog &);
143 : SAL_DLLPRIVATE ModelessDialog & operator= (const ModelessDialog &);
144 :
145 : public:
146 : ModelessDialog( Window* pParent, const ResId& rResId );
147 : ModelessDialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription );
148 : };
149 :
150 : // ---------------
151 : // - ModalDialog -
152 : // ---------------
153 :
154 0 : class VCL_DLLPUBLIC ModalDialog : public Dialog
155 : {
156 : public:
157 : ModalDialog( Window* pParent, WinBits nStyle = WB_STDMODAL );
158 : ModalDialog( Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription );
159 : ModalDialog( Window* pParent, const ResId& rResId );
160 :
161 : protected:
162 : using Window::Show;
163 : void Show( sal_Bool bVisible = sal_True );
164 : using Window::Hide;
165 : void Hide();
166 :
167 : private:
168 :
169 : // Copy assignment is forbidden and not implemented.
170 : SAL_DLLPRIVATE ModalDialog (const ModalDialog &);
171 : SAL_DLLPRIVATE ModalDialog & operator= (const ModalDialog &);
172 : };
173 :
174 : #endif // _SV_DIALOG_HXX
175 :
176 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|