Go to the documentation of this file.00001 
00002 #ifndef vgui_wx_adaptor_h_
00003 #define vgui_wx_adaptor_h_
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 #include <vgui/vgui_adaptor.h>
00017 #include <vgui/internals/vgui_adaptor_mixin.h>
00018 
00019 #include <wx/docview.h>
00020 #include <wx/glcanvas.h>
00021 class wxMenu;
00022 
00023 #include <vcl_map.h>
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 class vgui_wx_adaptor
00034   : public wxGLCanvas
00035   , public vgui_adaptor
00036   , public vgui_adaptor_mixin
00037 {
00038   DECLARE_CLASS(vgui_wx_adaptor)
00039   DECLARE_EVENT_TABLE()
00040 
00041   typedef vgui_adaptor_mixin mixin;
00042 
00043  public:
00044   
00045   vgui_wx_adaptor(wxWindow* parent,
00046                   wxWindowID id = wxID_ANY,
00047                   const wxPoint& pos = wxDefaultPosition,
00048                   const wxSize& size = wxDefaultSize,
00049                   long style = 0,
00050                   const wxString& name = wxT("vgui_wx_adaptor"),
00051                   int* attributes = 0);
00052 
00053   
00054   virtual ~vgui_wx_adaptor();
00055 
00056   void set_view(wxView* view) { view_ = view; }
00057 
00058   
00059   
00060   
00061 
00062   
00063   virtual unsigned int get_width() const { return GetClientSize().GetWidth(); }
00064 
00065   
00066   virtual unsigned int get_height() const { return GetClientSize().GetHeight(); }
00067 
00068   
00069   virtual void post_redraw();
00070 
00071   
00072   virtual void post_overlay_redraw();
00073 
00074   
00075   virtual void post_idle_request();
00076 
00077   
00078   virtual void post_message(char const *, void const *);
00079 
00080   
00081   virtual void post_destroy();
00082 
00083   
00084   virtual void post_timer(float timeout, int id);
00085 
00086   
00087   virtual void kill_timer(int id);
00088 
00089   
00090   virtual void bind_popups(vgui_modifier m, vgui_button b)
00091   {
00092     mixin::popup_modifier = m;
00093     mixin::popup_button   = b;
00094   }
00095 
00096   
00097   virtual void get_popup_bindings(vgui_modifier &m, vgui_button &b) const
00098   {
00099     m = mixin::popup_modifier;
00100     b = mixin::popup_button;
00101   }
00102 
00103   
00104   virtual vgui_window* get_window() const { return 0; }
00105 
00106   
00107   virtual void swap_buffers();
00108 
00109   
00110   virtual void make_current();
00111 
00112   
00113   
00114  private:
00115   
00116   void on_size(wxSizeEvent& event);
00117 
00118   
00119   void on_paint(wxPaintEvent& WXUNUSED(event));
00120 
00121   
00122   void on_erase_background(wxEraseEvent& WXUNUSED(event));
00123 
00124   
00125   void on_key(vgui_event& ve, wxKeyEvent& event);
00126 
00127   
00128   void on_key_down(wxKeyEvent& event);
00129 
00130   
00131   void on_key_up(wxKeyEvent& event);
00132 
00133   
00134   
00135   
00136   
00137   
00138   void on_char(wxKeyEvent& event);
00139 
00140   
00141   void on_mouse_event(wxMouseEvent& event);
00142 
00143   
00144   void on_idle(wxIdleEvent& event);
00145 
00146   
00147   
00148   
00149   void on_close(wxCloseEvent& event);
00150 
00151   
00152   void on_timer(wxEvent& event);
00153 
00154   
00155   void invalidate_canvas();
00156 
00157   
00158   
00159  private:
00160   wxView* view_;
00161 
00162   static vgui_menu last_popup_;
00163 
00164   
00165   bool redraw_posted_;
00166 
00167   
00168   bool overlay_redraw_posted_;
00169 
00170   
00171   bool idle_request_posted_;
00172 
00173   
00174   bool destroy_posted_;
00175 
00176   int last_key_down_;
00177   vcl_map<int,int> ascii_code_;
00178 };
00179 
00180 #endif // vgui_wx_adaptor_h_