Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ContextWX.hh
1 #ifndef __CONTEXTWX_HH__
2 #define __CONTEXTWX_HH__
3 
4 #include <bias_config.h>
5 #include <Gui/biasgl.h>
6 
7 #ifndef BIAS_HAVE_WXWIDGETS
8 # error Your BIAS needs WX. Please recompile BIAS with USE_WXWIDGETS.
9 #endif
10 
11 #include <Base/Common/BIASpragmaStart.hh>
12 #include <wx/wx.h>
13 #include <wx/glcanvas.h>
14 #include <Base/Common/BIASpragmaEnd.hh>
15 
16 #include "RenderContextBase.hh"
17 
18 // check defines from wx/setup.h implicitly
19 #if !(defined(wxUSE_GLCANVAS) && wxUSE_GLCANVAS)
20 # error WX has not been compiled with wxUSE_GLCANVAS. Please set it in wx/setup.h and recompile WX.
21 #endif
22 
23 namespace BIAS {
24 
25  /** @class ContextWX
26  @brief Context implementation for wxWidgets.
27  @attention Call InitializationComplete() in order to enable rendering!
28  @ingroup g_glviewer
29  @author Jan Kollmann
30  */
31  class BIASGLviewer_EXPORT ContextWX : public wxGLCanvas,
32  public RenderContextBase
33  {
34  public:
35  static int defaultAttribs[];
36 
37  ContextWX(wxWindow* parent, wxWindowID id = -1,
38  const wxPoint& pos = wxDefaultPosition,
39  const wxSize& size = wxDefaultSize,
40  long style = 0, const wxString& name = wxT("GLCanvas"),
41  int* attribList = defaultAttribs,
42  const wxPalette& palette = wxNullPalette);
43 
44  // The shared context constructor is deprecated in wx >= 2.9
45  // so this constructor will / should be removed
46  /* ContextWX(wxWindow* parent, wxGLContext* shared, wxWindowID id = -1,
47  const wxPoint& pos = wxDefaultPosition,
48  const wxSize& size = wxDefaultSize,
49  long style = 0, const wxString& name = wxT("GLCanvas"),
50  int* attribList = defaultAttribs,
51  const wxPalette& palette = wxNullPalette);*/
52 
53  int FindWorkingDisplayConfiguration();
54 
55  virtual void Redisplay() { Refresh(); }
56 
57  virtual void MakeGLContextCurrent();
58 
59  /** @brief Delay rendering until this method has been called. */
60  virtual void InitializationComplete() { initialized_ = true; }
61 
62  virtual void SetTimer(unsigned int interval);
63 
64  virtual void DeactivateTimer();
65 
66  protected:
67 
69 
70  //wxGLContext *wxGLContext_;
71 
72  virtual void OnPaint(wxPaintEvent& event);
73 
74  private:
75 
76  virtual void OnLeftDown(wxMouseEvent& event);
77  virtual void OnLeftUp(wxMouseEvent& event);
78  virtual void OnMiddleDown(wxMouseEvent& event);
79  virtual void OnMiddleUp(wxMouseEvent& event);
80  virtual void OnRightDown(wxMouseEvent& event);
81  virtual void OnRightUp(wxMouseEvent& event);
82  virtual void OnLeftDClick(wxMouseEvent& event);
83  virtual void OnRightDClick(wxMouseEvent& event);
84  virtual void OnMotion(wxMouseEvent& event);
85  virtual void OnEnterWindow(wxMouseEvent& event);
86  virtual void OnLeaveWindow(wxMouseEvent& event);
87  virtual void OnSize(wxSizeEvent& event);
88  virtual void OnKey(wxKeyEvent& event);
89  virtual void OnKeyDown(wxKeyEvent& event);
90  virtual void OnKeyUp(wxKeyEvent& event);
91  virtual void OnTimer(wxTimerEvent& event);
92  virtual void OnEraseBG(wxEraseEvent& event);
93 
94  int _OldMouseX, _OldMouseY;
95  bool _FirstPaint;
96  wxTimer Timer_;
97 
98  // The implicit context of wxGLCanvas is deprecated in wx >= 2.9
99  #if wxCHECK_VERSION(2, 9, 0)
100  wxGLContext* context_;
101  #endif
102 
103  DECLARE_EVENT_TABLE()
104  };
105 
106 } // namespace BIAS
107 
108 #endif // __CONTEXTWX_HH__
Context implementation for wxWidgets.
Definition: ContextWX.hh:31
virtual void Redisplay()
Demands a rendering from the Context;.
Definition: ContextWX.hh:55
virtual void InitializationComplete()
Delay rendering until this method has been called.
Definition: ContextWX.hh:60
Base for all classes creating interface between GL and &quot;window manager&quot;.