00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef XWINDOWS_MODULE_H
00028 #define XWINDOWS_MODULE_H
00029
00030 #include "FsfCell.h"
00031 #include "FsfTypeCellBase.h"
00032
00033 #include "FsfNode.h"
00034
00035 #include "ImageModule.h"
00036
00037 #include <X11/Xlib.h>
00038 #include <X11/Xutil.h>
00039
00040 namespace xwindows{
00043
00047
00049 void registerFactories();
00050
00051 using namespace std;
00052
00056 class CInterface : public fsf::CNode {
00057
00058 private:
00059 static const long DEFAULT_WIDTH=640;
00060 static const long DEFAULT_HEIGHT=480;
00061 static const std::string DEFAULT_TITLE;
00062
00063 fsf::CMutex m_csDisplay;
00064 Display *m_pDisplay;
00065 Window m_window;
00066 int m_depth;
00067 GC m_gc;
00068 Visual *m_pVisual;
00069
00070 std::string m_strWindowTitle;
00071 long m_nWidth;
00072 long m_nHeight;
00073
00075
00076
00077 static void* interfaceThreadProc(void* pParam);
00079 bool init();
00081 void close();
00083 bool eventLoop();
00085
00086 public:
00088
00089
00090 CInterface();
00092 CInterface(fsf::CNode *pParent, fsf::Time tTime=0);
00094 CInterface(const std::string &strName, fsf::CNode *pParent=NULL, fsf::Time tTime=0);
00098 CInterface(const string &strWindowTitle, long nWidth, long nHeight, fsf::CNode *pParent=NULL, fsf::Time tTime=0);
00103 CInterface(const string &strName, const string &strWindowTitle, long nWidth, long nHeight, fsf::CNode *pParent=NULL, fsf::Time tTime=0);
00105 CInterface(const CInterface&);
00107 virtual fsf::CNode *clone() const { return new CInterface(*this); }
00108
00109
00111
00112
00113 CInterface& operator=(const CInterface&);
00115 void setSize(int nWidth, int nHeight){
00116 m_nWidth=nWidth;
00117 m_nHeight=nHeight;
00118 }
00120 void setTitle(std::string strTitle){
00121 m_strWindowTitle=strTitle;
00122 }
00124 bool drawImage(image::CImage *pImage);
00126
00128
00129
00130 virtual void getTypeID(string &str) const { str.assign("IMAGE_IMAGE"); }
00132
00134
00135
00136 void startInterface();
00138 };
00139
00143 class CDisplay : public fsf::CCell {
00144 protected:
00145 public:
00147 CDisplay();
00149 virtual void getTypeID(std::string &str) const { str.assign("XWINDOWS_DISPLAY"); }
00153 virtual void process(fsf::CPassiveHandle *pPassiveHandle, fsf::CActiveHandle *pActiveHandle, fsf::CActivePulse *pActivePulse);
00154 };
00155
00156 }
00157
00158 #endif