Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/toolx/X11/simple_dispatcher is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef toolx_X11_simple_dispatcher
0005 #define toolx_X11_simple_dispatcher
0006 
0007 #include "base_session"
0008 
0009 namespace toolx {
0010 namespace X11 {
0011 
0012 class simple_dispatcher : public dispatcher {
0013   typedef dispatcher parent;
0014 public:
0015   virtual void win_render() = 0;
0016   virtual void set_size(unsigned int a_width,unsigned int a_height) = 0;
0017 public:
0018   virtual bool dispatch(XEvent& a_event) {
0019     if(!m_win) return false;
0020     if(a_event.xany.window!=m_win) return false;
0021     if( (a_event.type==Expose) || (a_event.type==ConfigureNotify) ){
0022       int width,height;
0023       m_session.window_size(m_win,width,height);
0024       set_size(width,height);   //viewer::set_size()
0025       win_render();
0026       return true;
0027     } else if(a_event.type==ClientMessage) {
0028       if(a_event.xclient.data.l[0]==(long)m_session.WM_DELETE_WINDOW_atom()) {
0029         m_session.post(m_win,m_session.SESSION_EXIT_STEER_atom());
0030         return true;
0031       }
0032     }
0033     return false;
0034   }
0035   virtual Window window() const {return m_win;}
0036 public:
0037   simple_dispatcher(base_session& a_session,Window a_win)
0038   :parent()
0039   ,m_session(a_session)
0040   ,m_win(a_win)
0041   {}
0042   virtual ~simple_dispatcher(){}
0043 public:
0044   simple_dispatcher(const simple_dispatcher& a_from)
0045   :parent(a_from)
0046   ,m_session(a_from.m_session)
0047   ,m_win(a_from.m_win)
0048   {}
0049   simple_dispatcher& operator=(const simple_dispatcher& a_from) {
0050     parent::operator=(a_from);
0051     m_win = a_from.m_win;
0052     return *this;
0053   }
0054 protected:
0055   base_session& m_session;
0056   Window m_win;
0057 };
0058 
0059 }}
0060 
0061 #endif