x11_factory.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * x11_factory.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: 66c8047f5c2d5b0476ad1a725ddb5342f53b9d08 $
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *          Olivier Teulière <ipkiss@via.ecp.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef X11_FACTORY_HPP
00026 #define X11_FACTORY_HPP
00027 
00028 #include <X11/Xlib.h>
00029 
00030 #include "../src/os_factory.hpp"
00031 #include "../src/generic_window.hpp"
00032 #include <map>
00033 
00034 class X11Display;
00035 class X11DragDrop;
00036 class X11TimerLoop;
00037 
00038 
00039 /// Class used to instanciate X11 specific objects
00040 class X11Factory: public OSFactory
00041 {
00042 private:
00043     /** ptrmap is an associative container (like std::map, in fact it builds
00044       * on std::map) that provides only operator[] in non-const and const
00045       * variants, and has the property that a (const) lookup of a non-existent
00046       * key does not cause an empty node to be inserted. Instead it returns
00047       * NULL if there was no entry; so it only stores pointers. */
00048     template<class K, class V> class ptrmap {
00049     private:
00050         typedef V *value_type;
00051         typedef std::map<K,value_type> map_t;
00052         map_t m_map;
00053         ptrmap &operator=(const ptrmap &);
00054         ptrmap(const ptrmap &);
00055     public:
00056         ptrmap() { }
00057         value_type &operator[](K k) { return m_map.operator[](k); }
00058         value_type  operator[](K k) const
00059         {
00060             typename map_t::const_iterator i=m_map.find(k);
00061             return i!=m_map.end() ? i->second : NULL;
00062         }
00063     };
00064 public:
00065     /// Map to find the GenericWindow* associated to a X11Window
00066     ptrmap<Window, GenericWindow> m_windowMap;
00067     /// Map to find the Dnd object (X11DragDrop*) associated to a X11Window
00068     ptrmap<Window, X11DragDrop> m_dndMap;
00069 
00070     X11Factory( intf_thread_t *pIntf );
00071     virtual ~X11Factory();
00072 
00073     /// Initialization method
00074     virtual bool init();
00075 
00076     /// Instantiate an object OSGraphics
00077     virtual OSGraphics *createOSGraphics( int width, int height );
00078 
00079     /// Get the instance of the singleton OSLoop
00080     virtual OSLoop *getOSLoop();
00081 
00082     /// Destroy the instance of OSLoop
00083     virtual void destroyOSLoop();
00084 
00085     /// Instantiate an OSTimer with the given command
00086     virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
00087 
00088     /// Minimize all the windows
00089     virtual void minimize();
00090 
00091     /// Restore the minimized windows
00092     virtual void restore();
00093 
00094     /// Add an icon in the system tray
00095     virtual void addInTray();
00096 
00097     /// Remove the icon from the system tray
00098     virtual void removeFromTray();
00099 
00100     /// Show the task in the task bar
00101     virtual void addInTaskBar();
00102 
00103     /// Remove the task from the task bar
00104     virtual void removeFromTaskBar();
00105 
00106     /// Instantiate an OSWindow object
00107     virtual OSWindow *createOSWindow( GenericWindow &rWindow,
00108                                       bool dragDrop, bool playOnDrop,
00109                                       OSWindow *pParent,
00110                                       GenericWindow::WindowType_t type );
00111 
00112     /// Instantiate an object OSTooltip
00113     virtual OSTooltip *createOSTooltip();
00114 
00115     /// Instantiate an object OSPopup
00116     virtual OSPopup *createOSPopup();
00117 
00118     /// Get the directory separator
00119     virtual const string &getDirSeparator() const { return m_dirSep; }
00120 
00121     /// Get the resource path
00122     virtual const list<string> &getResourcePath() const
00123         { return m_resourcePath; }
00124 
00125     /// Get the screen size
00126     virtual int getScreenWidth() const;
00127     virtual int getScreenHeight() const;
00128 
00129     /// Get the work area (screen area without taskbars)
00130     virtual SkinsRect getWorkArea() const;
00131 
00132     /// Get the position of the mouse
00133     virtual void getMousePos( int &rXPos, int &rYPos ) const;
00134 
00135     /// Change the cursor
00136     virtual void changeCursor( CursorType_t type ) const { /*TODO*/ }
00137 
00138     /// Delete a directory recursively
00139     virtual void rmDir( const string &rPath );
00140 
00141     /// Get the timer loop
00142     X11TimerLoop *getTimerLoop() const { return m_pTimerLoop; }
00143 
00144 private:
00145     /// X11 display
00146     X11Display *m_pDisplay;
00147     /// Timer loop
00148     X11TimerLoop *m_pTimerLoop;
00149     /// Directory separator
00150     const string m_dirSep;
00151     /// Resource path
00152     list<string> m_resourcePath;
00153 };
00154 
00155 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6