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