1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef FORMS_WINDOWSTATEGUARD_HXX 25 #define FORMS_WINDOWSTATEGUARD_HXX 26 27 /** === begin UNO includes === **/ 28 #include <com/sun/star/awt/XWindow2.hpp> 29 #include <com/sun/star/awt/XControlModel.hpp> 30 /** === end UNO includes === **/ 31 #include <rtl/ref.hxx> 32 33 //........................................................................ 34 namespace frm 35 { 36 //........................................................................ 37 38 //==================================================================== 39 //= WindowStateGuard 40 //==================================================================== 41 class WindowStateGuard_Impl; 42 43 /** a helper class which monitors certain states of an XWindow2, and ensures 44 that they're consistent with respective properties at an XModel. 45 46 For form controls, window states - such as "Enabled" - can be set by various 47 means. You can set the respective control model property, you can directly manipulate 48 the XWindow2, or the state can change implicitly due to VCL actions. In any case, 49 we need to ensure that the state does not contradict the model property "too much". 50 51 As an example, consider a form control which, according to its model's property, is disabled. 52 Now when the parent VCL window of the control's VCL window is enabled, then the the control's 53 window is enabled, too - which contradicts the model property. 54 55 A WindowStateGuard helps you preventing such inconsistent states. 56 57 The class is not threadsafe. 58 */ 59 class WindowStateGuard 60 { 61 private: 62 ::rtl::Reference< WindowStateGuard_Impl > m_pImpl; 63 64 public: 65 WindowStateGuard(); 66 ~WindowStateGuard(); 67 68 void attach( 69 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow2 >& _rxWindow, 70 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel 71 ); 72 }; 73 74 //........................................................................ 75 } // namespace frm 76 //........................................................................ 77 78 #endif // FORMS_WINDOWSTATEGUARD_HXX 79 80