1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c45d927aSAndrew Rist  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c45d927aSAndrew Rist  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19*c45d927aSAndrew Rist  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SD_UPDATE_LOCK_MANAGER_HXX
25cdf0e10cSrcweir #define SD_UPDATE_LOCK_MANAGER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <memory>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir namespace sd {
30cdf0e10cSrcweir 
31cdf0e10cSrcweir class ViewShellBase;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /** Manage update locks of ViewShellBase objects.
34cdf0e10cSrcweir     A ViewShellBase object is locked while views are switched in order to
35cdf0e10cSrcweir     avoid unnecessary repaints of views and object bars.
36cdf0e10cSrcweir     Locking a ViewShellBase locks the frame::XLayoutManager and prevents
37cdf0e10cSrcweir     Activate() and Deactivate() calls at ViewShell objects being processed.
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     The main responsibility of this class is find the right moment to unlock
40cdf0e10cSrcweir     the managed ViewShellBase object: Only Lock() has to be called from the
41cdf0e10cSrcweir     outside (usually from PaneManager).  Unlock() is called by this class
42cdf0e10cSrcweir     itself.  When all else fails it has a timer that calls Unlock()
43cdf0e10cSrcweir     eventually.
44cdf0e10cSrcweir */
45cdf0e10cSrcweir class UpdateLockManager
46cdf0e10cSrcweir {
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir     /** The newly created instance supports locking for the specified
49cdf0e10cSrcweir         ViewShellBase object by default.  Call Disable() for Lock() and
50cdf0e10cSrcweir         Unlock() calls being ignored.
51cdf0e10cSrcweir     */
52cdf0e10cSrcweir     UpdateLockManager (ViewShellBase& rBase);
53cdf0e10cSrcweir     ~UpdateLockManager (void);
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     /** For e.g. the PresentationViewShellBase locking is not necessary and
56cdf0e10cSrcweir         does lead to problems.  This method lets Lock() and Unlock() calls
57cdf0e10cSrcweir         be ignored and thus turns locking essentially off.
58cdf0e10cSrcweir     */
59cdf0e10cSrcweir     void Disable (void);
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     /** Lock some UI updates.  For every call to this method a call to
62cdf0e10cSrcweir         Unlock() is required to really unlock.
63cdf0e10cSrcweir     */
64cdf0e10cSrcweir     void Lock (void);
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     /** When called as many times as Lock() has been called before then the
67cdf0e10cSrcweir         ViewShellBase object is unlocked.
68cdf0e10cSrcweir     */
69cdf0e10cSrcweir     void Unlock (void);
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     /** Return whether the ViewShellBase object is locked.  When locking is
72cdf0e10cSrcweir         disabled, i.e. Disable() has been called before, then this method
73cdf0e10cSrcweir         always returns <FALSE/>.
74cdf0e10cSrcweir     */
75cdf0e10cSrcweir     bool IsLocked (void) const;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir private:
78cdf0e10cSrcweir     class Implementation;
79cdf0e10cSrcweir     Implementation* mpImpl;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     UpdateLockManager (const UpdateLockManager&); // Not supported.
82cdf0e10cSrcweir     UpdateLockManager& operator= (const UpdateLockManager&); // Not supported.
83cdf0e10cSrcweir };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir } // end of namespace sd
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #endif
88cdf0e10cSrcweir 
89