1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef FORMS_WINDOWSTATEGUARD_HXX
29 #define FORMS_WINDOWSTATEGUARD_HXX
30 
31 /** === begin UNO includes === **/
32 #include <com/sun/star/awt/XWindow2.hpp>
33 #include <com/sun/star/awt/XControlModel.hpp>
34 /** === end UNO includes === **/
35 #include <rtl/ref.hxx>
36 
37 //........................................................................
38 namespace frm
39 {
40 //........................................................................
41 
42 	//====================================================================
43 	//= WindowStateGuard
44 	//====================================================================
45     class WindowStateGuard_Impl;
46 
47     /** a helper class which monitors certain states of an XWindow2, and ensures
48         that they're consistent with respective properties at an XModel.
49 
50         For form controls, window states - such as "Enabled" - can be set by various
51         means. You can set the respective control model property, you can directly manipulate
52         the XWindow2, or the state can change implicitly due to VCL actions. In any case,
53         we need to ensure that the state does not contradict the model property "too much".
54 
55         As an example, consider a form control which, according to its model's property, is disabled.
56         Now when the parent VCL window of the control's VCL window is enabled, then the the control's
57         window is enabled, too - which contradicts the model property.
58 
59         A WindowStateGuard helps you preventing such inconsistent states.
60 
61         The class is not threadsafe.
62     */
63 	class WindowStateGuard
64 	{
65     private:
66         ::rtl::Reference< WindowStateGuard_Impl >   m_pImpl;
67 
68     public:
69         WindowStateGuard();
70         ~WindowStateGuard();
71 
72         void    attach(
73             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow2 >& _rxWindow,
74             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel
75         );
76 	};
77 
78 //........................................................................
79 } // namespace frm
80 //........................................................................
81 
82 #endif // FORMS_WINDOWSTATEGUARD_HXX
83 
84