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 #include <tools/saui>
0010 
0011 namespace toolx {
0012 namespace X11 {
0013 
0014 class simple_dispatcher : public dispatcher {
0015   typedef dispatcher parent;
0016 public:
0017   virtual void win_render() = 0;
0018   virtual void set_size(unsigned int a_width,unsigned int a_height) = 0;
0019 public:
0020   virtual bool dispatch(XEvent& a_event) {
0021     if(!m_win) return false;
0022     if(a_event.xany.window!=m_win) return false;
0023     if( (a_event.type==Expose) || (a_event.type==ConfigureNotify) ){
0024       int width,height;
0025       m_session.window_size(m_win,width,height);
0026       set_size(width,height);   //viewer::set_size()
0027       win_render();
0028       return true;
0029     } else if(a_event.type==ClientMessage) {
0030       if(a_event.xclient.data.l[0]==(long)m_session.WM_DELETE_WINDOW_atom()) {
0031         m_session.post(m_win,m_session.SESSION_EXIT_STEER_atom());
0032         return true;
0033       }
0034     }
0035     return false;
0036   }
0037   virtual Window window() const {return m_win;}
0038 public:
0039   simple_dispatcher(base_session& a_session,Window a_win)
0040   :parent()
0041   ,m_session(a_session)
0042   ,m_win(a_win)
0043   {}
0044   virtual ~simple_dispatcher(){}
0045 public:
0046   simple_dispatcher(const simple_dispatcher& a_from)
0047   :parent(a_from)
0048   ,m_session(a_from.m_session)
0049   ,m_win(a_from.m_win)
0050   {}
0051   simple_dispatcher& operator=(const simple_dispatcher& a_from) {
0052     parent::operator=(a_from);
0053     m_win = a_from.m_win;
0054     return *this;
0055   }
0056 protected:
0057   base_session& m_session;
0058   Window m_win;
0059 };
0060 
0061 }}
0062 
0063 #endif