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/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 : bool mbInExecute;
51 : bool mbOldSaveBack;
52 : bool mbInClose;
53 : bool mbModalMode;
54 : bool mbIsDefferedInit;
55 : bool mbIsCalculatingInitialLayoutSize;
56 : Timer maLayoutTimer;
57 : VclButtonBox* mpActionArea;
58 : VclBox* mpContentArea;
59 :
60 : SAL_DLLPRIVATE void ImplInitDialogData();
61 : SAL_DLLPRIVATE void ImplInitSettings();
62 :
63 : // Copy assignment is forbidden and not implemented.
64 : SAL_DLLPRIVATE Dialog (const Dialog &);
65 : SAL_DLLPRIVATE Dialog & operator= (const Dialog &);
66 :
67 : DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void* );
68 : DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* );
69 :
70 : protected:
71 : using Window::ImplInit;
72 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
73 : SAL_DLLPRIVATE void ImplDialogRes( const ResId& rResId );
74 : SAL_DLLPRIVATE WinBits init(Window *pParent, const ResId& rResId);
75 :
76 : SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclContainer &rBox);
77 : public:
78 0 : SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
79 0 : SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); }
80 : SAL_DLLPRIVATE void doDeferredInit(bool bResizable);
81 0 : SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
82 :
83 : protected:
84 : explicit Dialog( WindowType nType );
85 : explicit Dialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType );
86 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
87 :
88 : protected:
89 : friend class VclBuilder;
90 : void set_action_area(VclButtonBox *pBox);
91 : void set_content_area(VclBox *pBox);
92 :
93 : public:
94 : explicit Dialog( Window* pParent, WinBits nStyle = WB_STDDIALOG );
95 : explicit Dialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription );
96 : virtual ~Dialog();
97 :
98 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
99 : virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
100 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
101 :
102 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
103 : virtual void Resize() SAL_OVERRIDE;
104 : bool isLayoutEnabled() const;
105 : void setOptimalLayoutSize();
106 0 : bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; }
107 : virtual void queue_resize() SAL_OVERRIDE;
108 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
109 : VclButtonBox* get_action_area();
110 : VclBox* get_content_area();
111 :
112 : virtual bool Close() SAL_OVERRIDE;
113 :
114 : virtual short Execute();
115 0 : bool IsInExecute() const { return mbInExecute; }
116 :
117 : virtual void SetText( const OUString& rStr ) SAL_OVERRIDE;
118 : virtual OUString GetText() const SAL_OVERRIDE;
119 :
120 :
121 : // Dialog::Execute replacement API
122 : public:
123 : // Link impl: DECL_LINK( MyEndDialogHdl, Dialog* ); <= param is dialog just ended
124 : virtual void StartExecuteModal( const Link& rEndDialogHdl );
125 : long GetResult() const;
126 : private:
127 : bool ImplStartExecuteModal();
128 : void ImplEndExecuteModal();
129 : public:
130 :
131 : // Dialog::Execute replacement API
132 :
133 :
134 : void EndDialog( long nResult = 0 );
135 : static void EndAllDialogs( Window* pParent=NULL );
136 :
137 : void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
138 : sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
139 :
140 : void SetModalInputMode( bool bModal );
141 : void SetModalInputMode( bool bModal, bool bSubModalDialogs );
142 0 : bool IsModalInputMode() const { return mbModalMode; }
143 :
144 : void GrabFocusToFirstControl();
145 : };
146 :
147 :
148 : // - ModelessDialog -
149 :
150 :
151 0 : class VCL_DLLPUBLIC ModelessDialog : public Dialog
152 : {
153 : // Copy assignment is forbidden and not implemented.
154 : SAL_DLLPRIVATE ModelessDialog (const ModelessDialog &);
155 : SAL_DLLPRIVATE ModelessDialog & operator= (const ModelessDialog &);
156 :
157 : public:
158 : explicit ModelessDialog( Window* pParent, const ResId& rResId );
159 : explicit ModelessDialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription );
160 : };
161 :
162 :
163 : // - ModalDialog -
164 :
165 :
166 0 : class VCL_DLLPUBLIC ModalDialog : public Dialog
167 : {
168 : public:
169 : explicit ModalDialog( Window* pParent, WinBits nStyle = WB_STDMODAL );
170 : explicit ModalDialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription );
171 : explicit ModalDialog( Window* pParent, const ResId& rResId );
172 :
173 : protected:
174 : using Window::Show;
175 : void Show( bool bVisible = true );
176 : using Window::Hide;
177 : void Hide();
178 :
179 : private:
180 :
181 : // Copy assignment is forbidden and not implemented.
182 : SAL_DLLPRIVATE ModalDialog (const ModalDialog &);
183 : SAL_DLLPRIVATE ModalDialog & operator= (const ModalDialog &);
184 : };
185 :
186 : #endif // INCLUDED_VCL_DIALOG_HXX
187 :
188 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|