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 INCLUDED_SLIDESHOW_SCREENUPDATER_HXX
25 #define INCLUDED_SLIDESHOW_SCREENUPDATER_HXX
26 
27 #include "viewupdate.hxx"
28 #include "unoviewcontainer.hxx"
29 #include <boost/noncopyable.hpp>
30 #include <boost/scoped_ptr.hpp>
31 
32 /* Definition of ScreenUpdater class */
33 
34 namespace slideshow
35 {
36     namespace internal
37     {
38         /** Screen updater
39 
40             This class handles and synchronizes screen updates
41             centrally. Therefore, it can hold a number of ViewUpdate
42             objects, which are polled for pending updates on
43             commitUpdates(). Furthermore, external code can request
44             updates via notifyUpdate() calls. If neither such an
45             update was requested, nor any of the registered ViewUpdate
46             objects report any pending update, commitUpdates() does
47             nothing.
48          */
49         class ScreenUpdater : boost::noncopyable
50         {
51         public:
52             explicit ScreenUpdater( UnoViewContainer const& rViewContainer );
53             ~ScreenUpdater();
54 
55             /** Notify screen update
56 
57                 This method records a screen content update request
58                 for all views.
59             */
60             void notifyUpdate();
61 
62             /** Notify screen update
63 
64                 This method records a screen content update request
65                 for the given view.
66 
67                 @param rView
68                 The view that needs an update
69 
70                 @param bViewClobbered
71                 When true, notifies update that view content is
72                 clobbered by external circumstances (e.g. by another
73                 application), and needs update even if the
74                 implementation 'thinks' it does not need to render
75                 something to screen.
76             */
77             void notifyUpdate( const UnoViewSharedPtr& rView, bool bViewClobbered=false );
78 
79             /** Commits collected update actions
80              */
81             void commitUpdates();
82 
83             /** Register ViewUpdate
84 
85                 @param rViewUpdate
86                 Add this ViewUpdate to the list that's asked for
87                 pending updates
88              */
89             void addViewUpdate( ViewUpdateSharedPtr const& rViewUpdate );
90 
91             /** Unregister ViewUpdate
92 
93                 @param rViewUpdate
94                 Remove this ViewUpdate from the list that's asked for
95                 pending updates
96              */
97             void removeViewUpdate( ViewUpdateSharedPtr const& );
98 
99             /** A wart.
100 
101                 Used to fire an immediate screen update. Currently
102                 needed for the wait symbol, since switching that on
103                 and off does get to commitUpdates()
104              */
105             void requestImmediateUpdate();
106 
107             class UpdateLock {public: virtual void Activate (void) = 0; };
108 
109             /** Call this method to create a lock instead of calling
110                 lockUpdates() and unlockUpdates() directly.
111                 @param bStartLocked
112                     When <TRUE/> then the UpdateLock is created already
113                     locked. When <FALSE/> then Activate() has to be called in order
114                     to lock the lock.
115             */
116             ::boost::shared_ptr<UpdateLock> createLock (const bool bStartLocked);
117 
118             /** Lock updates to prevent intermediate repaints.
119             */
120             void lockUpdates (void);
121 
122             /** When called as often as lockUpdates() then commitUpdates()
123                 is called.
124             */
125             void unlockUpdates (void);
126 
127         private:
128             struct ImplScreenUpdater;
129             boost::scoped_ptr<ImplScreenUpdater> mpImpl;
130 
131         };
132     }
133 }
134 
135 #endif /* INCLUDED_SLIDESHOW_SCREENUPDATER_HXX */
136