juce_Desktop.h

Go to the documentation of this file.
00001 /*
00002   ==============================================================================
00003 
00004    This file is part of the JUCE library - "Jules' Utility Class Extensions"
00005    Copyright 2004-7 by Raw Material Software ltd.
00006 
00007   ------------------------------------------------------------------------------
00008 
00009    JUCE can be redistributed and/or modified under the terms of the
00010    GNU General Public License, as published by the Free Software Foundation;
00011    either version 2 of the License, or (at your option) any later version.
00012 
00013    JUCE is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with JUCE; if not, visit www.gnu.org/licenses or write to the
00020    Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00021    Boston, MA 02111-1307 USA
00022 
00023   ------------------------------------------------------------------------------
00024 
00025    If you'd like to release a closed-source product which uses JUCE, commercial
00026    licenses are also available: visit www.rawmaterialsoftware.com/juce for
00027    more information.
00028 
00029   ==============================================================================
00030 */
00031 
00032 #ifndef __JUCE_DESKTOP_JUCEHEADER__
00033 #define __JUCE_DESKTOP_JUCEHEADER__
00034 
00035 #include "juce_Component.h"
00036 #include "../../application/juce_DeletedAtShutdown.h"
00037 #include "../../events/juce_Timer.h"
00038 #include "../../events/juce_AsyncUpdater.h"
00039 #include "../../../juce_core/containers/juce_SortedSet.h"
00040 
00041 
00042 //==============================================================================
00049 class JUCE_API  FocusChangeListener
00050 {
00051 public:
00053     virtual ~FocusChangeListener()  {}
00054 
00056     virtual void globalFocusChanged (Component* focusedComponent) = 0;
00057 };
00058 
00059 
00060 //==============================================================================
00065 class JUCE_API  Desktop  : private DeletedAtShutdown,
00066                            private Timer,
00067                            private AsyncUpdater
00068 {
00069 public:
00070     //==============================================================================
00073     static Desktop& JUCE_CALLTYPE getInstance() throw();
00074 
00075     //==============================================================================
00083     const RectangleList getAllMonitorDisplayAreas (const bool clippedToWorkArea = true) const throw();
00084 
00090     const Rectangle getMainMonitorArea (const bool clippedToWorkArea = true) const throw();
00091 
00100     const Rectangle getMonitorAreaContaining (int x, int y, const bool clippedToWorkArea = true) const throw();
00101 
00102 
00103     //==============================================================================
00108     static void getMousePosition (int& x, int& y) throw();
00109 
00114     static void setMousePosition (int x, int y) throw();
00115 
00118     static void getLastMouseDownPosition (int& x, int& y) throw();
00119 
00125     static int getMouseButtonClickCounter() throw();
00126 
00127     //==============================================================================
00142     static void setScreenSaverEnabled (const bool isEnabled) throw();
00143 
00152     static bool isScreenSaverEnabled() throw();
00153 
00154     //==============================================================================
00160     void addGlobalMouseListener (MouseListener* const listener) throw();
00161 
00167     void removeGlobalMouseListener (MouseListener* const listener) throw();
00168 
00169     //==============================================================================
00173     void addFocusChangeListener (FocusChangeListener* const listener) throw();
00174 
00176     void removeFocusChangeListener (FocusChangeListener* const listener) throw();
00177 
00178     //==============================================================================
00184     int getNumComponents() const throw();
00185 
00193     Component* getComponent (const int index) const throw();
00194 
00202     Component* findComponentAt (const int screenX,
00203                                 const int screenY) const;
00204 
00205 
00206     //==============================================================================
00207     juce_UseDebuggingNewOperator
00208 
00213     void refreshMonitorSizes() throw();
00214 
00216     static bool canUseSemiTransparentWindows() throw();
00217 
00218 
00219 private:
00220     //==============================================================================
00221     friend class Component;
00222     friend class ComponentPeer;
00223     SortedSet <void*> mouseListeners, focusListeners;
00224     VoidArray desktopComponents;
00225 
00226     friend class DeletedAtShutdown;
00227     friend class TopLevelWindowManager;
00228     Desktop() throw();
00229     ~Desktop() throw();
00230 
00231     Array <Rectangle> monitorCoordsClipped, monitorCoordsUnclipped;
00232     int lastMouseX, lastMouseY;
00233 
00234     void timerCallback();
00235     void sendMouseMove();
00236     void resetTimer() throw();
00237 
00238     int getNumDisplayMonitors() const throw();
00239     const Rectangle getDisplayMonitorCoordinates (const int index, const bool clippedToWorkArea) const throw();
00240 
00241     void addDesktopComponent (Component* const c) throw();
00242     void removeDesktopComponent (Component* const c) throw();
00243     void componentBroughtToFront (Component* const c) throw();
00244 
00245     void triggerFocusCallback() throw();
00246     void handleAsyncUpdate();
00247 
00248     Desktop (const Desktop&);
00249     const Desktop& operator= (const Desktop&);
00250 };
00251 
00252 
00253 #endif   // __JUCE_DESKTOP_JUCEHEADER__