1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_SLIDESHOW_SCREENUPDATER_HXX
29 #define INCLUDED_SLIDESHOW_SCREENUPDATER_HXX
30 
31 #include "viewupdate.hxx"
32 #include "unoviewcontainer.hxx"
33 #include <boost/noncopyable.hpp>
34 #include <boost/scoped_ptr.hpp>
35 
36 /* Definition of ScreenUpdater class */
37 
38 namespace slideshow
39 {
40     namespace internal
41     {
42         /** Screen updater
43 
44             This class handles and synchronizes screen updates
45             centrally. Therefore, it can hold a number of ViewUpdate
46             objects, which are polled for pending updates on
47             commitUpdates(). Furthermore, external code can request
48             updates via notifyUpdate() calls. If neither such an
49             update was requested, nor any of the registered ViewUpdate
50             objects report any pending update, commitUpdates() does
51             nothing.
52          */
53         class ScreenUpdater : boost::noncopyable
54         {
55         public:
56             explicit ScreenUpdater( UnoViewContainer const& rViewContainer );
57             ~ScreenUpdater();
58 
59             /** Notify screen update
60 
61                 This method records a screen content update request
62                 for all views.
63             */
64             void notifyUpdate();
65 
66             /** Notify screen update
67 
68                 This method records a screen content update request
69                 for the given view.
70 
71                 @param rView
72                 The view that needs an update
73 
74                 @param bViewClobbered
75                 When true, notifies update that view content is
76                 clobbered by external circumstances (e.g. by another
77                 application), and needs update even if the
78                 implementation 'thinks' it does not need to render
79                 something to screen.
80             */
81             void notifyUpdate( const UnoViewSharedPtr& rView, bool bViewClobbered=false );
82 
83             /** Commits collected update actions
84              */
85             void commitUpdates();
86 
87             /** Register ViewUpdate
88 
89                 @param rViewUpdate
90                 Add this ViewUpdate to the list that's asked for
91                 pending updates
92              */
93             void addViewUpdate( ViewUpdateSharedPtr const& rViewUpdate );
94 
95             /** Unregister ViewUpdate
96 
97                 @param rViewUpdate
98                 Remove this ViewUpdate from the list that's asked for
99                 pending updates
100              */
101             void removeViewUpdate( ViewUpdateSharedPtr const& );
102 
103             /** A wart.
104 
105                 Used to fire an immediate screen update. Currently
106                 needed for the wait symbol, since switching that on
107                 and off does get to commitUpdates()
108              */
109             void requestImmediateUpdate();
110 
111             class UpdateLock {public: virtual void Activate (void) = 0; };
112 
113             /** Call this method to create a lock instead of calling
114                 lockUpdates() and unlockUpdates() directly.
115                 @param bStartLocked
116                     When <TRUE/> then the UpdateLock is created already
117                     locked. When <FALSE/> then Activate() has to be called in order
118                     to lock the lock.
119             */
120             ::boost::shared_ptr<UpdateLock> createLock (const bool bStartLocked);
121 
122             /** Lock updates to prevent intermediate repaints.
123             */
124             void lockUpdates (void);
125 
126             /** When called as often as lockUpdates() then commitUpdates()
127                 is called.
128             */
129             void unlockUpdates (void);
130 
131         private:
132             struct ImplScreenUpdater;
133             boost::scoped_ptr<ImplScreenUpdater> mpImpl;
134 
135         };
136     }
137 }
138 
139 #endif /* INCLUDED_SLIDESHOW_SCREENUPDATER_HXX */
140