65 const
int *attribList,
70 const wxPalette& palette):
71 wxGLCanvas(parent,
id, attribList, pos, size, style, name, palette)
74 setAutomaticDelete(
false);
76 DragAcceptFiles(
true);
78 mWXGLContext =
new wxGLContext(
this);
83 dispatchDestroyEvent();
92 std::vector<String> files;
93 for(
int i=0; i<ev.GetNumberOfFiles(); ++i)
95 wxCharBuffer chars = ev.GetFiles()[i].ToUTF8();
96 String str = String::fromUTF8(chars.data());
99 dispatchFileDroppedEvent(files);
104 if (continuousUpdate())
117 dispatchMouseMoveEvent( ev.GetX(), ev.GetY() );
122 int d = ev.GetWheelRotation() / ev.GetWheelDelta();
123 dispatchMouseWheelEvent( d );
128 if (ev.GetButton() == wxMOUSE_BTN_NONE)
130 switch(ev.GetButton())
132 case wxMOUSE_BTN_LEFT: dispatchMouseUpEvent(
LeftButton, ev.GetX(), ev.GetY());
break;
133 case wxMOUSE_BTN_MIDDLE: dispatchMouseUpEvent(
MiddleButton, ev.GetX(), ev.GetY());
break;
134 case wxMOUSE_BTN_RIGHT: dispatchMouseUpEvent(
RightButton, ev.GetX(), ev.GetY());
break;
136 case wxMOUSE_BTN_ANY: dispatchMouseUpEvent(
UnknownButton, ev.GetX(), ev.GetY());
break;
147 if (ev.GetButton() == wxMOUSE_BTN_NONE)
149 switch(ev.GetButton())
151 case wxMOUSE_BTN_LEFT: dispatchMouseDownEvent(
LeftButton, ev.GetX(), ev.GetY());
break;
152 case wxMOUSE_BTN_MIDDLE: dispatchMouseDownEvent(
MiddleButton, ev.GetX(), ev.GetY());
break;
153 case wxMOUSE_BTN_RIGHT: dispatchMouseDownEvent(
RightButton, ev.GetX(), ev.GetY());
break;
155 case wxMOUSE_BTN_ANY: dispatchMouseDownEvent(
UnknownButton, ev.GetX(), ev.GetY());
break;
167 wxWindow::SetSize(ev.GetSize());
168 wxSize s = GetClientSize();
169 dispatchResizeEvent(s.x, s.y);
180 #if wxUSE_UNICODE == 1 181 unicode = ev.GetUnicodeKey();
183 unicode = ev.GetKeyCode() < 128 ? ev.GetKeyCode() : 0;
186 switch(ev.GetKeyCode())
188 case '0': key =
Key_0;
break;
189 case '1': key =
Key_1;
break;
190 case '2': key =
Key_2;
break;
191 case '3': key =
Key_3;
break;
192 case '4': key =
Key_4;
break;
193 case '5': key =
Key_5;
break;
194 case '6': key =
Key_6;
break;
195 case '7': key =
Key_7;
break;
196 case '8': key =
Key_8;
break;
197 case '9': key =
Key_9;
break;
199 case 'Q': key =
Key_Q;
break;
200 case 'W': key =
Key_W;
break;
201 case 'E': key =
Key_E;
break;
202 case 'R': key =
Key_R;
break;
203 case 'T': key =
Key_T;
break;
204 case 'Y': key =
Key_Y;
break;
205 case 'U': key =
Key_U;
break;
206 case 'I': key =
Key_I;
break;
207 case 'O': key =
Key_O;
break;
208 case 'P': key =
Key_P;
break;
209 case 'A': key =
Key_A;
break;
210 case 'S': key =
Key_S;
break;
211 case 'D': key =
Key_D;
break;
212 case 'F': key =
Key_F;
break;
213 case 'G': key =
Key_G;
break;
214 case 'H': key =
Key_H;
break;
215 case 'J': key =
Key_J;
break;
216 case 'K': key =
Key_K;
break;
217 case 'L': key =
Key_L;
break;
218 case 'Z': key =
Key_Z;
break;
219 case 'X': key =
Key_X;
break;
220 case 'C': key =
Key_C;
break;
221 case 'V': key =
Key_V;
break;
222 case 'B': key =
Key_B;
break;
223 case 'N': key =
Key_N;
break;
224 case 'M': key =
Key_M;
break;
228 case WXK_TAB: key =
Key_Tab;
break;
253 case '@': key =
Key_At;
break;
263 case WXK_CONTROL: key =
Key_Ctrl; unicode = 0;
break;
266 case WXK_ALT: key =
Key_Alt; unicode = 0;
break;
269 case WXK_SHIFT: key =
Key_Shift; unicode = 0;
break;
272 case WXK_INSERT: key =
Key_Insert; unicode = 0;
break;
273 case WXK_DELETE: key =
Key_Delete; unicode = 0;
break;
274 case WXK_HOME: key =
Key_Home; unicode = 0;
break;
275 case WXK_END: key =
Key_End; unicode = 0;
break;
276 case WXK_PRINT: key =
Key_Print; unicode = 0;
break;
277 case WXK_PAUSE: key =
Key_Pause; unicode = 0;
break;
278 case WXK_PAGEUP: key =
Key_PageUp; unicode = 0;
break;
279 case WXK_PAGEDOWN: key =
Key_PageDown; unicode = 0;
break;
280 case WXK_LEFT: key =
Key_Left; unicode = 0;
break;
281 case WXK_RIGHT: key =
Key_Right; unicode = 0;
break;
282 case WXK_UP: key =
Key_Up; unicode = 0;
break;
283 case WXK_DOWN: key =
Key_Down; unicode = 0;
break;
284 case WXK_F1: key =
Key_F1; unicode = 0;
break;
285 case WXK_F2: key =
Key_F2; unicode = 0;
break;
286 case WXK_F3: key =
Key_F3; unicode = 0;
break;
287 case WXK_F4: key =
Key_F4; unicode = 0;
break;
288 case WXK_F5: key =
Key_F5; unicode = 0;
break;
289 case WXK_F6: key =
Key_F6; unicode = 0;
break;
290 case WXK_F7: key =
Key_F7; unicode = 0;
break;
291 case WXK_F8: key =
Key_F8; unicode = 0;
break;
292 case WXK_F9: key =
Key_F9; unicode = 0;
break;
293 case WXK_F10: key =
Key_F10; unicode = 0;
break;
294 case WXK_F11: key =
Key_F11; unicode = 0;
break;
295 case WXK_F12: key =
Key_F12; unicode = 0;
break;
310 dispatchKeyPressEvent(unicode,key);
319 dispatchKeyReleaseEvent(unicode,key);
328 dispatchUpdateEvent();
333 float r = rand()%100 / 100.0f;
334 float g = rand()%100 / 100.0f;
335 float b = rand()%100 / 100.0f;
336 float a = rand()%100 / 100.0f;
337 glClearColor(r,g,b,a);
338 glClear(GL_COLOR_BUFFER_BIT);
350 wxWindow* win =
this;
351 while(win->GetParent())
353 win = win->GetParent();
354 wxTopLevelWindowBase* win_base =
dynamic_cast<wxTopLevelWindowBase*
>(win);
357 win_base->ShowFullScreen(fullscreen, wxFULLSCREEN_ALL);
361 mFullscreen = fullscreen;
367 wxApp* app =
dynamic_cast<wxApp*
>(wxApp::GetInstance());
372 eraseAllEventListeners();
377 if ( getWXGLContext() ) {
378 getWXGLContext()->SetCurrent( *
this );
384 wxGLCanvas::SwapBuffers();
389 wxGLCanvas::SetFocus();
404 wxWindow* win =
this;
405 while(win->GetParent())
406 win = win->GetParent();
426 SetPosition(wxPoint(x,y));
436 wxPoint pt = GetPosition();
437 return ivec2(pt.x, pt.y);
442 wxSize s = GetClientSize();
443 return ivec2(s.GetWidth(), s.GetHeight());
448 if (mouseVisible() && !visible)
450 mCursor = GetCursor();
461 image.SetRGB( wxRect(0,0,8,8), 255,255,255 );
462 image.SetMaskColour(255, 255, 255);
464 wxCursor cursor(image);
468 if (!mouseVisible() && visible)
470 SetCursor( mCursor );
473 mMouseVisible = visible;
void swapBuffers()
Swaps the back and front buffers to present the last rendering.
Vector2< int > ivec2
A 2 components vector with int precision.
void OnIdle(wxIdleEvent &ev)
void setMousePosition(int x, int y)
If the OpenGL context is a widget this function sets the mouse position.
std::wstring toStdWString() const
Returns the std::wstring representation of a String.
void OnKeyDown(wxKeyEvent &ev)
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
void OnEraseBackground(wxEraseEvent &ev)
void quitApplication()
Asks to the windowing system that is managing the OpenGLContext to quit the application.
Visualization Library main namespace.
void translateKey(int &unicode, EKey &key, const wxKeyEvent &ev)
void setSize(int w, int h)
If the OpenGL context is a widget this function sets its size.
void update()
If the OpenGLContext is a widget this function requests a redraw and generates an updateEvent()...
void OnMouseUp(wxMouseEvent &ev)
void setWindowTitle(const vl::String &text)
If the OpenGL context is a top window this function sets its title.
void OnKeyUp(wxKeyEvent &ev)
void setMouseVisible(bool visible)
If the OpenGL context is a widget this function sets whether the mouse is visible over it or not...
The wxWidgets bindings namespace.
void OnMouseWheel(wxMouseEvent &ev)
void OnMouseEnter(wxMouseEvent &ev)
void OnMouseMotion(wxMouseEvent &ev)
vl::ivec2 position() const
If the OpenGL context is a widget this function returns its position.
void show()
If the OpenGL context is a widget this function makes it visible to the user.
The WXGLCanvas class implements a vl::OpenGLContext using the wxWidgets library.
void OnMouseDown(wxMouseEvent &ev)
void makeCurrent()
Sets the OpenGL context as current for the calling thread.
std::string toStdString() const
Returns a UTF8 encoded std::string.
void setPosition(int x, int y)
If the OpenGL context is a widget this function sets its position.
void hide()
If the OpenGL context is a widget this function makes it invisible to the user.
void OnPaint(wxPaintEvent &ev)
void getFocus()
If the OpenGL context is a widget this function requests the mouse focus on it.
void OnDropFiles(wxDropFilesEvent &ev)
bool setFullscreen(bool fullscreen)
If the OpenGL context is a widget this function requests a maximization to fullscreen.
void OnSize(wxSizeEvent &ev)