1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _SV_DIALOG_HXX
21 #define _SV_DIALOG_HXX
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>
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)
41 class VCL_DLLPUBLIC Dialog
43 , public VclBuilderContainer
46 Window
* mpDialogParent
;
47 Dialog
* mpPrevExecuteDlg
;
48 DialogImpl
* mpDialogImpl
;
49 long mnMousePositioned
;
51 sal_Bool mbOldSaveBack
;
54 bool mbIsDefferedInit
;
55 bool mbIsCalculatingInitialLayoutSize
;
57 VclButtonBox
* mpActionArea
;
58 VclBox
* mpContentArea
;
60 SAL_DLLPRIVATE
void ImplInitDialogData();
61 SAL_DLLPRIVATE
void ImplInitSettings();
63 // Copy assignment is forbidden and not implemented.
64 SAL_DLLPRIVATE
Dialog (const Dialog
&);
65 SAL_DLLPRIVATE Dialog
& operator= (const Dialog
&);
67 DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl
, void* );
68 DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl
, void* );
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
);
76 SAL_DLLPRIVATE
void setPosSizeOnContainee(Size aSize
, VclContainer
&rBox
);
78 SAL_DLLPRIVATE sal_Bool
IsInClose() const { return mbInClose
; }
79 SAL_DLLPRIVATE
bool hasPendingLayout() const { return maLayoutTimer
.IsActive(); }
80 SAL_DLLPRIVATE
void doDeferredInit(bool bResizable
);
81 SAL_DLLPRIVATE
bool isDeferredInit() const { return mbIsDefferedInit
; }
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
);
89 friend class VclBuilder
;
90 void set_action_area(VclButtonBox
*pBox
);
91 void set_content_area(VclBox
*pBox
);
94 explicit Dialog( Window
* pParent
, WinBits nStyle
= WB_STDDIALOG
);
95 explicit Dialog( Window
* pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
);
98 virtual long Notify( NotifyEvent
& rNEvt
);
99 virtual void StateChanged( StateChangedType nStateChange
);
100 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
102 virtual Size
GetOptimalSize() const;
103 virtual void Resize();
104 bool isLayoutEnabled() const;
105 void setOptimalLayoutSize();
106 bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize
; }
107 virtual void queue_layout();
108 virtual bool set_property(const OString
&rKey
, const OString
&rValue
);
109 VclButtonBox
* get_action_area();
110 VclBox
* get_content_area();
112 virtual sal_Bool
Close();
114 virtual short Execute();
115 sal_Bool
IsInExecute() const { return mbInExecute
; }
117 virtual void SetText( const OUString
& rStr
);
118 virtual OUString
GetText() const;
120 ////////////////////////////////////////
121 // Dialog::Execute replacement API
123 // Link impl: DECL_LINK( MyEndDialogHdl, Dialog* ); <= param is dialog just ended
124 virtual void StartExecuteModal( const Link
& rEndDialogHdl
);
125 long GetResult() const;
127 sal_Bool
ImplStartExecuteModal();
128 void ImplEndExecuteModal();
131 // Dialog::Execute replacement API
132 ////////////////////////////////////////
134 void EndDialog( long nResult
= 0 );
135 static void EndAllDialogs( Window
* pParent
=NULL
);
137 void GetDrawWindowBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
138 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const;
140 void SetModalInputMode( sal_Bool bModal
);
141 void SetModalInputMode( sal_Bool bModal
, sal_Bool bSubModalDialogs
);
142 sal_Bool
IsModalInputMode() const { return mbModalMode
; }
144 void GrabFocusToFirstControl();
147 // ------------------
148 // - ModelessDialog -
149 // ------------------
151 class VCL_DLLPUBLIC ModelessDialog
: public Dialog
153 // Copy assignment is forbidden and not implemented.
154 SAL_DLLPRIVATE
ModelessDialog (const ModelessDialog
&);
155 SAL_DLLPRIVATE ModelessDialog
& operator= (const ModelessDialog
&);
158 explicit ModelessDialog( Window
* pParent
, const ResId
& rResId
);
159 explicit ModelessDialog( Window
* pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
);
166 class VCL_DLLPUBLIC ModalDialog
: public Dialog
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
);
175 void Show( sal_Bool bVisible
= sal_True
);
181 // Copy assignment is forbidden and not implemented.
182 SAL_DLLPRIVATE
ModalDialog (const ModalDialog
&);
183 SAL_DLLPRIVATE ModalDialog
& operator= (const ModalDialog
&);
186 #endif // _SV_DIALOG_HXX
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */