]> git.sesse.net Git - vlc/blob - modules/gui/skins2/x11/x11_factory.hpp
Qt4: module help may be NULL - fix #4144
[vlc] / modules / gui / skins2 / x11 / x11_factory.hpp
1 /*****************************************************************************
2  * x11_factory.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifndef X11_FACTORY_HPP
26 #define X11_FACTORY_HPP
27
28 #include <X11/Xlib.h>
29
30 #include "../src/os_factory.hpp"
31 #include "../src/generic_window.hpp"
32 #include <map>
33
34 class X11Display;
35 class X11DragDrop;
36 class X11TimerLoop;
37
38
39 /// Class used to instanciate X11 specific objects
40 class X11Factory: public OSFactory
41 {
42 private:
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 {
49     private:
50         typedef V *value_type;
51         typedef std::map<K,value_type> map_t;
52         map_t m_map;
53         ptrmap &operator=(const ptrmap &);
54         ptrmap(const ptrmap &);
55     public:
56         ptrmap() { }
57         value_type &operator[](K k) { return m_map.operator[](k); }
58         value_type  operator[](K k) const
59         {
60             typename map_t::const_iterator i=m_map.find(k);
61             return i!=m_map.end() ? i->second : NULL;
62         }
63     };
64 public:
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;
69
70     X11Factory( intf_thread_t *pIntf );
71     virtual ~X11Factory();
72
73     /// Initialization method
74     virtual bool init();
75
76     /// Instantiate an object OSGraphics
77     virtual OSGraphics *createOSGraphics( int width, int height );
78
79     /// Get the instance of the singleton OSLoop
80     virtual OSLoop *getOSLoop();
81
82     /// Destroy the instance of OSLoop
83     virtual void destroyOSLoop();
84
85     /// Instantiate an OSTimer with the given command
86     virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
87
88     /// Minimize all the windows
89     virtual void minimize();
90
91     /// Restore the minimized windows
92     virtual void restore();
93
94     /// Add an icon in the system tray
95     virtual void addInTray();
96
97     /// Remove the icon from the system tray
98     virtual void removeFromTray();
99
100     /// Show the task in the task bar
101     virtual void addInTaskBar();
102
103     /// Remove the task from the task bar
104     virtual void removeFromTaskBar();
105
106     /// Instantiate an OSWindow object
107     virtual OSWindow *createOSWindow( GenericWindow &rWindow,
108                                       bool dragDrop, bool playOnDrop,
109                                       OSWindow *pParent,
110                                       GenericWindow::WindowType_t type );
111
112     /// Instantiate an object OSTooltip
113     virtual OSTooltip *createOSTooltip();
114
115     /// Instantiate an object OSPopup
116     virtual OSPopup *createOSPopup();
117
118     /// Get the directory separator
119     virtual const string &getDirSeparator() const { return m_dirSep; }
120
121     /// Get the resource path
122     virtual const list<string> &getResourcePath() const
123         { return m_resourcePath; }
124
125     /// Get the screen size
126     virtual int getScreenWidth() const;
127     virtual int getScreenHeight() const;
128
129     /// Get the work area (screen area without taskbars)
130     virtual SkinsRect getWorkArea() const;
131
132     /// Get the position of the mouse
133     virtual void getMousePos( int &rXPos, int &rYPos ) const;
134
135     /// Change the cursor
136     virtual void changeCursor( CursorType_t type ) const { /*TODO*/ }
137
138     /// Delete a directory recursively
139     virtual void rmDir( const string &rPath );
140
141     /// Get the timer loop
142     X11TimerLoop *getTimerLoop() const { return m_pTimerLoop; }
143
144 private:
145     /// X11 display
146     X11Display *m_pDisplay;
147     /// Timer loop
148     X11TimerLoop *m_pTimerLoop;
149     /// Directory separator
150     const string m_dirSep;
151     /// Resource path
152     list<string> m_resourcePath;
153 };
154
155 #endif