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 SD_UPDATE_LOCK_MANAGER_HXX 25 #define SD_UPDATE_LOCK_MANAGER_HXX 26 27 #include <memory> 28 29 namespace sd { 30 31 class ViewShellBase; 32 33 /** Manage update locks of ViewShellBase objects. 34 A ViewShellBase object is locked while views are switched in order to 35 avoid unnecessary repaints of views and object bars. 36 Locking a ViewShellBase locks the frame::XLayoutManager and prevents 37 Activate() and Deactivate() calls at ViewShell objects being processed. 38 39 The main responsibility of this class is find the right moment to unlock 40 the managed ViewShellBase object: Only Lock() has to be called from the 41 outside (usually from PaneManager). Unlock() is called by this class 42 itself. When all else fails it has a timer that calls Unlock() 43 eventually. 44 */ 45 class UpdateLockManager 46 { 47 public: 48 /** The newly created instance supports locking for the specified 49 ViewShellBase object by default. Call Disable() for Lock() and 50 Unlock() calls being ignored. 51 */ 52 UpdateLockManager (ViewShellBase& rBase); 53 ~UpdateLockManager (void); 54 55 /** For e.g. the PresentationViewShellBase locking is not necessary and 56 does lead to problems. This method lets Lock() and Unlock() calls 57 be ignored and thus turns locking essentially off. 58 */ 59 void Disable (void); 60 61 /** Lock some UI updates. For every call to this method a call to 62 Unlock() is required to really unlock. 63 */ 64 void Lock (void); 65 66 /** When called as many times as Lock() has been called before then the 67 ViewShellBase object is unlocked. 68 */ 69 void Unlock (void); 70 71 /** Return whether the ViewShellBase object is locked. When locking is 72 disabled, i.e. Disable() has been called before, then this method 73 always returns <FALSE/>. 74 */ 75 bool IsLocked (void) const; 76 77 private: 78 class Implementation; 79 Implementation* mpImpl; 80 81 UpdateLockManager (const UpdateLockManager&); // Not supported. 82 UpdateLockManager& operator= (const UpdateLockManager&); // Not supported. 83 }; 84 85 } // end of namespace sd 86 87 #endif 88 89