]> git.saurik.com Git - wxWidgets.git/blame_incremental - samples/opengl/cube/cube.cpp
Forgot to add this one
[wxWidgets.git] / samples / opengl / cube / cube.cpp
... / ...
Content-type: text/html ]> git.saurik.com Git - wxWidgets.git/blame_incremental - samples/opengl/cube/cube.cpp


500 - Internal Server Error

Malformed UTF-8 character (fatal) at /usr/lib/x86_64-linux-gnu/perl5/5.40/HTML/Entities.pm line 485, <$fd> line 120.
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: cube.cpp
3// Purpose: wxGLCanvas demo program
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation
14#pragma interface
15#endif
16
17// For compilers that support precompilation, includes "wx.h".
18#include "wx/wxprec.h"
19
20#ifdef __BORLANDC__
21#pragma hdrstop
22#endif
23
24#ifndef WX_PRECOMP
25#include "wx/wx.h"
26#endif
27
28#include "wx/log.h"
29
30#include "cube.h"
31
32#ifndef __WXMSW__ // for wxStopWatch, see remark below
33#include <sys/time.h>
34#include <sys/unistd.h>
35#else
36#include <sys/timeb.h>
37#endif
38
39#define ID_NEW_WINDOW 10000
40#define ID_DEF_ROTATE_LEFT_KEY 10001
41#define ID_DEF_ROTATE_RIGHT_KEY 10002
42
43/*----------------------------------------------------------
44 Control to get a keycode
45 ----------------------------------------------------------*/
46class ScanCodeCtrl : public wxTextCtrl
47{
48public:
49 ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
50 const wxPoint& pos, const wxSize& size );
51 void OnChar( wxKeyEvent& event ) { } /* do nothing */
52 void OnKeyDown(wxKeyEvent& event);
53private:
54// any class wishing to process wxWindows events must use this macro
55 DECLARE_EVENT_TABLE()
56};
57BEGIN_EVENT_TABLE( ScanCodeCtrl, wxTextCtrl )
58 EVT_CHAR( ScanCodeCtrl::OnChar )
59 EVT_KEY_DOWN( ScanCodeCtrl::OnKeyDown )
60END_EVENT_TABLE()
61
62ScanCodeCtrl::ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
63 const wxPoint& pos, const wxSize& size )
64 : wxTextCtrl( parent, id, "", pos, size )
65{ wxString buf;
66 buf.Printf( "0x%04x", code );
67 SetValue( buf );
68}
69
70void ScanCodeCtrl::OnKeyDown( wxKeyEvent& event )
71{ wxString buf;
72 buf.Printf( "0x%04x", event.KeyCode() );
73 SetValue( buf );
74}
75
76/*------------------------------------------------------------------
77 Dialog for defining a keypress
78-------------------------------------------------------------------*/
79
80class ScanCodeDialog : public wxDialog
81{
82public:
83 ScanCodeDialog( wxWindow* parent, wxWindowID id, const int code,
84 const wxString &descr, const wxString& title );
85 int GetValue();
86private:
87 ScanCodeCtrl *m_ScanCode;
88 wxTextCtrl *m_Description;
89};
90
91ScanCodeDialog::ScanCodeDialog( wxWindow* parent, wxWindowID id,
92 const int code, const wxString &descr, const wxString& title )
93 : wxDialog( parent, id, title, wxPoint(-1, -1), wxSize(96*2,76*2) )
94{
95 new wxStaticText( this, -1, "Scancode", wxPoint(4*2,3*2),
96 wxSize(31*2,12*2) );
97 m_ScanCode = new ScanCodeCtrl( this, -1, code, wxPoint(37*2,6*2),
98 wxSize(53*2,14*2) );
99
100 new wxStaticText( this, -1, "Description", wxPoint(4*2,24*2),
101 wxSize(32*2,12*2) );
102 m_Description = new wxTextCtrl( this, -1, descr, wxPoint(37*2,27*2),
103 wxSize(53*2,14*2) );
104
105 new wxButton( this, wxID_OK, "Ok", wxPoint(20*2,50*2), wxSize(20*2,13*2) );
106 new wxButton( this, wxID_CANCEL, "Cancel", wxPoint(44*2,50*2),
107 wxSize(25*2,13*2) );
108}
109
110int ScanCodeDialog::GetValue()
111{
112 int code;
113 wxString buf = m_ScanCode->GetValue();
114 sscanf( buf.c_str(), "%i", &code );
115 return( code );
116}
117
118/*----------------------------------------------------------------------
119 Utility function to get the elapsed time (in msec) since a given point
120