00001 00002 #ifndef _XSHMIMG_H 00003 #define _XSHMIMG_H 00004 00005 #include <X11/Xlib.h> 00006 #include <X11/Xutil.h> 00007 00008 #include <sys/ipc.h> 00009 #include <sys/shm.h> 00010 #include <X11/extensions/XShm.h> 00011 #include "l1394_window.h" 00012 00013 00014 namespace L1394_MM{ 00015 /*! \class XShmImg 00016 * \ingroup L1394_Display 00017 * \brief This class implements a X-Window with shared memory. 00018 * 00019 */ 00020 00021 class XShmImg : public Window { 00022 public: 00023 00024 /*! \fn XShmImg(const int width, const int height, const char *title, l1394_converter converter) 00025 * \brief constructor 00026 * \param width : width value for the window 00027 * \param height : height value for the window 00028 * \param title : char* title of the window 00029 * \param converter : function pointer to the decoder (will be removed in later versions) 00030 */ 00031 XShmImg(const int width,const int height,const char *title, l1394_converter=0); 00032 00033 /*! \fn XShmImg(const char *title, l1394_converter converter) 00034 * \brief constructor 00035 * \param title : char* title of the window 00036 * \param converter : function pointer to the decoder (will be removed in later versions) 00037 */ 00038 XShmImg(const char *title, l1394_converter=0); 00039 00040 /*! \fn ~XShmImg() 00041 * \brief destructor 00042 */ 00043 virtual ~XShmImg(); 00044 00045 /*! \fn getBuffer() const 00046 * \brief This function returns a pointer to the shared memory of the window 00047 */ 00048 unsigned char* getBuffer() const; 00049 00050 /*! \fn update() 00051 * \brief This function updates the X-window. 00052 */ 00053 void update(); 00054 00055 /*! \fn setTitle(const char *title) 00056 * \brief This function sets the title of the X-window. 00057 * \param title : const char* to the name of the window. 00058 */ 00059 void setTitle(const char *title); 00060 00061 00062 /*! \fn getColorDepth() const 00063 * \brief This function returns the color depth of a window as integer value. 00064 * 00065 * This value depends on your X-Server settings. 00066 * \return int : the color depth (in Bit) as integer value (normally 16 o 24) 00067 */ 00068 int getColorDepth() const {return depth;} 00069 virtual void start(); 00070 00071 /*! \fn nodeDestroy(const L1394::Node* node) 00072 * \brief If this function is called, the destructor of this class is called. 00073 * 00074 * So you don't need to delete a connected window. 00075 * \param node: pointer to the connected parent-node 00076 */ 00077 virtual void nodeDestroy(const L1394::Node*); 00078 00079 /*! \fn nodeDisabled(const L1394::Node* node) 00080 * \brief This function handles the NODE_DISABLED event from the connected device. 00081 */ 00082 virtual void nodeDisabled(const L1394::Node*); 00083 private: 00084 void allocate(); 00085 inline void setPixel(int x, int y, char r, char g, char b) 00086 { 00087 unsigned long pixel = r; 00088 pixel <<= 8; 00089 pixel |= g; 00090 pixel <<= 8; 00091 pixel |= b; 00092 XPutPixel(image, x, y, pixel); 00093 } 00094 00095 int width, height, depth; 00096 00097 Display *display; 00098 ::Window win; 00099 GC gc; 00100 XImage *image; 00101 XShmSegmentInfo Shminfo; 00102 bool is_init; 00103 const char* title; 00104 }; 00105 } 00106 #endif