1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef X11_FACTORY_HPP
26 #define X11_FACTORY_HPP
30 #include "../src/os_factory.hpp"
31 #include "../src/generic_window.hpp"
39 /// Class used to instanciate X11 specific objects
40 class X11Factory: public OSFactory
43 /** ptrmap is an associative container (like std::map, in fact it builds
44 * on std::map) that provides only operator[] in non-const and const
45 * variants, and has the property that a (const) lookup of a non-existent
46 * key does not cause an empty node to be inserted. Instead it returns
47 * NULL if there was no entry; so it only stores pointers. */
48 template<class K, class V> class ptrmap {
50 typedef V *value_type;
51 typedef std::map<K,value_type> map_t;
53 ptrmap &operator=(const ptrmap &);
54 ptrmap(const ptrmap &);
57 value_type &operator[](K k) { return m_map.operator[](k); }
58 value_type operator[](K k) const
60 typename map_t::const_iterator i=m_map.find(k);
61 return i!=m_map.end() ? i->second : NULL;
65 /// Map to find the GenericWindow* associated to a X11Window
66 ptrmap<Window, GenericWindow> m_windowMap;
67 /// Map to find the Dnd object (X11DragDrop*) associated to a X11Window
68 ptrmap<Window, X11DragDrop> m_dndMap;
70 X11Factory( intf_thread_t *pIntf );
71 virtual ~X11Factory();
73 /// Initialization method
76 /// Instantiate an object OSGraphics
77 virtual OSGraphics *createOSGraphics( int width, int height );
79 /// Get the instance of the singleton OSLoop
80 virtual OSLoop *getOSLoop();
82 /// Destroy the instance of OSLoop
83 virtual void destroyOSLoop();
85 /// Instantiate an OSTimer with the given command
86 virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
88 /// Minimize all the windows
89 virtual void minimize();
91 /// Restore the minimized windows
92 virtual void restore();
94 /// Add an icon in the system tray
95 virtual void addInTray();
97 /// Remove the icon from the system tray
98 virtual void removeFromTray();
100 /// Show the task in the task bar
101 virtual void addInTaskBar();
103 /// Remove the task from the task bar
104 virtual void removeFromTaskBar();
106 /// Instantiate an OSWindow object
107 virtual OSWindow *createOSWindow( GenericWindow &rWindow,
108 bool dragDrop, bool playOnDrop,
110 GenericWindow::WindowType_t type );
112 /// Instantiate an object OSTooltip
113 virtual OSTooltip *createOSTooltip();
115 /// Instantiate an object OSPopup
116 virtual OSPopup *createOSPopup();
118 /// Get the directory separator
119 virtual const string &getDirSeparator() const { return m_dirSep; }
121 /// Get the resource path
122 virtual const list<string> &getResourcePath() const
123 { return m_resourcePath; }
125 /// Get the screen size
126 virtual int getScreenWidth() const;
127 virtual int getScreenHeight() const;
129 /// Get the work area (screen area without taskbars)
130 virtual SkinsRect getWorkArea() const;
132 /// Get the position of the mouse
133 virtual void getMousePos( int &rXPos, int &rYPos ) const;
135 /// Change the cursor
136 virtual void changeCursor( CursorType_t type ) const { /*TODO*/ }
138 /// Delete a directory recursively
139 virtual void rmDir( const string &rPath );
141 /// Get the timer loop
142 X11TimerLoop *getTimerLoop() const { return m_pTimerLoop; }
146 X11Display *m_pDisplay;
148 X11TimerLoop *m_pTimerLoop;
149 /// Directory separator
150 const string m_dirSep;
152 list<string> m_resourcePath;