1*aaef562fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*aaef562fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*aaef562fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*aaef562fSAndrew Rist * distributed with this work for additional information 6*aaef562fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*aaef562fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*aaef562fSAndrew Rist * "License"); you may not use this file except in compliance 9*aaef562fSAndrew Rist * with the License. You may obtain a copy of the License at 10*aaef562fSAndrew Rist * 11*aaef562fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*aaef562fSAndrew Rist * 13*aaef562fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*aaef562fSAndrew Rist * software distributed under the License is distributed on an 15*aaef562fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*aaef562fSAndrew Rist * KIND, either express or implied. See the License for the 17*aaef562fSAndrew Rist * specific language governing permissions and limitations 18*aaef562fSAndrew Rist * under the License. 19*aaef562fSAndrew Rist * 20*aaef562fSAndrew Rist *************************************************************/ 21*aaef562fSAndrew Rist 22*aaef562fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_SCREENUPDATER_HXX 25cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_SCREENUPDATER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "viewupdate.hxx" 28cdf0e10cSrcweir #include "unoviewcontainer.hxx" 29cdf0e10cSrcweir #include <boost/noncopyable.hpp> 30cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir /* Definition of ScreenUpdater class */ 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace slideshow 35cdf0e10cSrcweir { 36cdf0e10cSrcweir namespace internal 37cdf0e10cSrcweir { 38cdf0e10cSrcweir /** Screen updater 39cdf0e10cSrcweir 40cdf0e10cSrcweir This class handles and synchronizes screen updates 41cdf0e10cSrcweir centrally. Therefore, it can hold a number of ViewUpdate 42cdf0e10cSrcweir objects, which are polled for pending updates on 43cdf0e10cSrcweir commitUpdates(). Furthermore, external code can request 44cdf0e10cSrcweir updates via notifyUpdate() calls. If neither such an 45cdf0e10cSrcweir update was requested, nor any of the registered ViewUpdate 46cdf0e10cSrcweir objects report any pending update, commitUpdates() does 47cdf0e10cSrcweir nothing. 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir class ScreenUpdater : boost::noncopyable 50cdf0e10cSrcweir { 51cdf0e10cSrcweir public: 52cdf0e10cSrcweir explicit ScreenUpdater( UnoViewContainer const& rViewContainer ); 53cdf0e10cSrcweir ~ScreenUpdater(); 54cdf0e10cSrcweir 55cdf0e10cSrcweir /** Notify screen update 56cdf0e10cSrcweir 57cdf0e10cSrcweir This method records a screen content update request 58cdf0e10cSrcweir for all views. 59cdf0e10cSrcweir */ 60cdf0e10cSrcweir void notifyUpdate(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir /** Notify screen update 63cdf0e10cSrcweir 64cdf0e10cSrcweir This method records a screen content update request 65cdf0e10cSrcweir for the given view. 66cdf0e10cSrcweir 67cdf0e10cSrcweir @param rView 68cdf0e10cSrcweir The view that needs an update 69cdf0e10cSrcweir 70cdf0e10cSrcweir @param bViewClobbered 71cdf0e10cSrcweir When true, notifies update that view content is 72cdf0e10cSrcweir clobbered by external circumstances (e.g. by another 73cdf0e10cSrcweir application), and needs update even if the 74cdf0e10cSrcweir implementation 'thinks' it does not need to render 75cdf0e10cSrcweir something to screen. 76cdf0e10cSrcweir */ 77cdf0e10cSrcweir void notifyUpdate( const UnoViewSharedPtr& rView, bool bViewClobbered=false ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** Commits collected update actions 80cdf0e10cSrcweir */ 81cdf0e10cSrcweir void commitUpdates(); 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** Register ViewUpdate 84cdf0e10cSrcweir 85cdf0e10cSrcweir @param rViewUpdate 86cdf0e10cSrcweir Add this ViewUpdate to the list that's asked for 87cdf0e10cSrcweir pending updates 88cdf0e10cSrcweir */ 89cdf0e10cSrcweir void addViewUpdate( ViewUpdateSharedPtr const& rViewUpdate ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir /** Unregister ViewUpdate 92cdf0e10cSrcweir 93cdf0e10cSrcweir @param rViewUpdate 94cdf0e10cSrcweir Remove this ViewUpdate from the list that's asked for 95cdf0e10cSrcweir pending updates 96cdf0e10cSrcweir */ 97cdf0e10cSrcweir void removeViewUpdate( ViewUpdateSharedPtr const& ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir /** A wart. 100cdf0e10cSrcweir 101cdf0e10cSrcweir Used to fire an immediate screen update. Currently 102cdf0e10cSrcweir needed for the wait symbol, since switching that on 103cdf0e10cSrcweir and off does get to commitUpdates() 104cdf0e10cSrcweir */ 105cdf0e10cSrcweir void requestImmediateUpdate(); 106cdf0e10cSrcweir 107cdf0e10cSrcweir class UpdateLock {public: virtual void Activate (void) = 0; }; 108cdf0e10cSrcweir 109cdf0e10cSrcweir /** Call this method to create a lock instead of calling 110cdf0e10cSrcweir lockUpdates() and unlockUpdates() directly. 111cdf0e10cSrcweir @param bStartLocked 112cdf0e10cSrcweir When <TRUE/> then the UpdateLock is created already 113cdf0e10cSrcweir locked. When <FALSE/> then Activate() has to be called in order 114cdf0e10cSrcweir to lock the lock. 115cdf0e10cSrcweir */ 116cdf0e10cSrcweir ::boost::shared_ptr<UpdateLock> createLock (const bool bStartLocked); 117cdf0e10cSrcweir 118cdf0e10cSrcweir /** Lock updates to prevent intermediate repaints. 119cdf0e10cSrcweir */ 120cdf0e10cSrcweir void lockUpdates (void); 121cdf0e10cSrcweir 122cdf0e10cSrcweir /** When called as often as lockUpdates() then commitUpdates() 123cdf0e10cSrcweir is called. 124cdf0e10cSrcweir */ 125cdf0e10cSrcweir void unlockUpdates (void); 126cdf0e10cSrcweir 127cdf0e10cSrcweir private: 128cdf0e10cSrcweir struct ImplScreenUpdater; 129cdf0e10cSrcweir boost::scoped_ptr<ImplScreenUpdater> mpImpl; 130cdf0e10cSrcweir 131cdf0e10cSrcweir }; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_SCREENUPDATER_HXX */ 136