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