00001 00023 #ifndef CONTROLLER_OSD_H 00024 #define CONTROLLER_OSD_H 00025 00026 #include "module_interface.h" 00027 #include "osd_config.h" 00028 #include <X11/Xlib.h> 00029 #include <X11/extensions/shape.h> 00030 00031 class Osd : public ControllerInterface 00032 { 00033 Q_OBJECT 00034 Q_PROPERTY(int width READ width WRITE setWidth) 00035 Q_PROPERTY(int height READ height WRITE setHeight) 00036 Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset) 00037 Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset) 00038 Q_PROPERTY(QString color READ color WRITE setColor) 00039 Q_PROPERTY(QString position READ position WRITE setPosition) 00040 00041 public: 00042 Osd(); 00043 QWidget* configWidget(); 00044 QSize size(); 00045 bool init(); 00046 void exit(); 00047 void setPixel(int, int, bool); 00048 void update(); 00049 void clear(const QRect& rect=QRect()); 00050 00051 private: 00052 inline void setWidth(int width) { m_config->m_spinWidth.setValue(width); } 00053 inline void setHeight(int height) { m_config->m_spinHeight.setValue(height); } 00054 inline void setXOffset(int x) { m_config->m_spinXOffset.setValue(x); } 00055 inline void setYOffset(int y) { m_config->m_spinYOffset.setValue(y); } 00056 inline void setColor(const QString& color) 00057 { 00058 int index = m_config->m_cmbColor.findText(color); 00059 m_config->m_cmbColor.setCurrentIndex(index); 00060 } 00061 inline void setPosition(const QString& pos) 00062 { 00063 int index = m_config->m_cmbPosition.findText(pos); 00064 m_config->m_cmbPosition.setCurrentIndex(index); 00065 } 00066 inline int width() { return m_config->m_spinWidth.value(); } 00067 inline int height() { return m_config->m_spinHeight.value(); } 00068 inline int xOffset() { return m_config->m_spinXOffset.value(); } 00069 inline int yOffset() { return m_config->m_spinYOffset.value(); } 00070 inline QString color() { return m_config->m_cmbColor.currentText(); } 00071 inline QString position() { return m_config->m_cmbPosition.currentText(); } 00072 void calcScreenPos(); 00073 00074 OsdConfig* m_config; 00075 QMultiHash<int, int> m_pos; 00076 QMultiHash<int, int>::const_iterator m_posIterator; 00077 Display* m_display; 00078 Window m_win; 00079 00080 GC m_gc; 00081 GC m_gcMask; 00082 GC m_gcMaskBack; 00083 00084 Pixmap m_pixmap; 00085 Pixmap m_pixmapMask; 00086 00087 XColor m_RGBcolour; 00088 XColor m_HWcolour; 00089 Colormap m_colorMap; 00090 00091 int m_screen; 00092 int m_x, m_y; 00093 unsigned int m_depth; 00094 }; 00095 00096 class OsdFactory : public ModuleFactory 00097 { 00098 Q_OBJECT 00099 Q_INTERFACES(ModuleFactory) 00100 00101 public: 00102 OsdFactory() : ModuleFactory("osd", "OSD Controller") {} 00103 inline void init() { addModul("osd", "On Sceen Display"); } 00104 inline ModulType type() { return ModuleFactory::Controller; } 00105 inline ModuleInterface* create(const QString& name) { 00106 if (name == "osd") 00107 return new Osd(); 00108 00109 return 0; 00110 } 00111 }; 00112 00113 #endif