include/GUI/URLChangeUpdater.hpp

Go to the documentation of this file.
00001 #ifndef hpp_URLChangeUpdater_hpp
00002 #define hpp_URLChangeUpdater_hpp
00003 
00004 // We need base declaration
00005 #include "UZIBase.hpp"
00006 
00007 namespace juce
00008 {
00010     class URLChangeListener
00011     {
00012     public:
00014         virtual void URLIsChanged(const juce::String & newURL) = 0;
00015     };
00016 
00018     class URLChangeUpdate : public juce::AsyncUpdater
00019     {
00020         // Members
00021     private:
00023         Array<URLChangeListener *, CriticalSection> listeners; 
00025         CriticalSection                             urlProtection;
00027         String                                      newURL;
00028 
00029     public:
00031         void UpdateURL(const juce::String & _newURL) 
00032         {
00033             ScopedLock lock(urlProtection);
00034             newURL = _newURL;
00035             triggerAsyncUpdate();
00036         }
00037 
00039         void addListener(URLChangeListener * listener)
00040         {
00041             listeners.addIfNotAlreadyThere(listener);
00042         }
00043 
00045         void removeListener(URLChangeListener * listener)
00046         {
00047             listeners.removeValue(listener);
00048         }
00049 
00051         virtual void    handleAsyncUpdate ()
00052         {
00053             String urlToBroadcast;
00054             {
00055                 ScopedLock lock(urlProtection);
00056                 urlToBroadcast = newURL;
00057             }
00058 
00059             listeners.lockArray();
00060             for (int i = 0; i < listeners.size(); i++)
00061             {
00062                 if (listeners.getUnchecked(i))
00063                     listeners.getUnchecked(i)->URLIsChanged(urlToBroadcast);
00064             }
00065             listeners.unlockArray();
00066         }
00067     };
00068 }
00069 
00070 
00071 
00072 
00073 
00074 #endif

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is