GteWindowBase.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
10 using namespace gte;
11 
13  :
14  title(L""),
15  xOrigin(0),
16  yOrigin(0),
17  xSize(0),
18  ySize(0),
19  allowResize(false),
20  created(false)
21 {
22 }
23 
24 WindowBase::Parameters::Parameters(std::wstring const& inTitle,
25  int inXOrigin, int inYOrigin, int inXSize, int inYSize)
26  :
27  title(inTitle),
28  xOrigin(inXOrigin),
29  yOrigin(inYOrigin),
30  xSize(inXSize),
31  ySize(inYSize),
32  allowResize(false),
33  created(false)
34 {
35 }
36 
37 
39 {
40 }
41 
43  :
44  mTitle(parameters.title),
45  mXOrigin(parameters.xOrigin),
46  mYOrigin(parameters.yOrigin),
47  mXSize(parameters.xSize),
48  mYSize(parameters.ySize),
49  mAllowResize(parameters.allowResize),
50  mIsMinimized(false),
51  mIsMaximized(false),
52  mBaseEngine(parameters.engine),
53  mProgramFactory(parameters.factory)
54 {
55 }
56 
57 void WindowBase::SetTitle(std::wstring const& title)
58 {
59  mTitle = title;
60 }
61 
62 void WindowBase::OnMove(int x, int y)
63 {
64  mXOrigin = x;
65  mYOrigin = y;
66 }
67 
68 bool WindowBase::OnResize(int xSize, int ySize)
69 {
70  mIsMinimized = false;
71  mIsMaximized = false;
72 
73  if (xSize != mXSize || ySize != mYSize)
74  {
75  mXSize = xSize;
76  mYSize = ySize;
77 
78  if (mBaseEngine)
79  {
80  mBaseEngine->Resize(xSize, ySize);
81  }
82  return true;
83  }
84 
85  return false;
86 }
87 
89 {
90  mIsMinimized = true;
91  mIsMaximized = false;
92 }
93 
95 {
96  mIsMinimized = false;
97  mIsMaximized = true;
98 }
99 
101 {
102  // Stub for derived classes.
103 }
104 
106 {
107  // Stub for derived classes.
108 }
109 
110 bool WindowBase::OnCharPress(unsigned char key, int, int)
111 {
112  if (key == KEY_ESCAPE)
113  {
114  // Quit the application when the 'escape' key is pressed.
115  OnClose();
116  return true;
117  }
118 
119  if (key == ' ')
120  {
121  mTimer.Reset();
122  return true;
123  }
124 
125  return false;
126 }
127 
128 bool WindowBase::OnKeyDown(int, int, int)
129 {
130  // Stub for derived classes.
131  return false;
132 }
133 
134 bool WindowBase::OnKeyUp(int, int, int)
135 {
136  // Stub for derived classes.
137  return false;
138 }
139 
140 bool WindowBase::OnMouseClick(int, int, int, int, unsigned int)
141 {
142  // stub for derived classes
143  return false;
144 }
145 
146 bool WindowBase::OnMouseMotion(int, int, int, unsigned int)
147 {
148  // stub for derived classes
149  return false;
150 }
151 
152 bool WindowBase::OnMouseWheel(int, int, int, unsigned int)
153 {
154  // Stub for derived classes.
155  return false;
156 }
157 
159 {
160  // Stub for derived classes.
161 }
162 
163 void WindowBase::GetMousePosition(int&, int&) const
164 {
165  // Stub for derived classes.
166 }
167 
169 {
170  // Stub for derived classes.
171 }
172 
174 {
176  if (path == "")
177  {
178  LogError("You must create the environment variable GTE_PATH.");
179  return "";
180  }
181  return path;
182 }
virtual void OnMaximize()
virtual void OnMove(int x, int y)
virtual bool OnMouseClick(int button, int state, int x, int y, unsigned int modifiers)
virtual bool OnKeyDown(int key, int x, int y)
std::string GetGTEPath()
GLsizei const GLchar *const * path
Definition: glcorearb.h:3337
std::shared_ptr< ProgramFactory > mProgramFactory
GLint GLenum GLint x
Definition: glcorearb.h:404
std::wstring mTitle
virtual void SetMousePosition(int x, int y)
std::string GetVariable(std::string const &name)
virtual void OnIdle()
WindowBase(Parameters &parameters)
virtual void OnMinimize()
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
std::shared_ptr< ProgramFactory > factory
Definition: GteWindowBase.h:35
#define LogError(message)
Definition: GteLogger.h:92
virtual void OnClose()
virtual bool OnKeyUp(int key, int x, int y)
virtual bool OnMouseWheel(int delta, int x, int y, unsigned int modifiers)
virtual void SetTitle(std::wstring const &title)
virtual bool OnResize(int xSize, int ySize)
static int const KEY_ESCAPE
Definition: GteWindowBase.h:89
virtual bool OnMouseMotion(int button, int x, int y, unsigned int modifiers)
virtual void OnDisplay()
virtual ~WindowBase()
virtual void GetMousePosition(int &x, int &y) const
std::shared_ptr< BaseEngine > engine
Definition: GteWindowBase.h:34
std::shared_ptr< BaseEngine > mBaseEngine
GLint y
Definition: glcorearb.h:98
virtual bool OnCharPress(unsigned char key, int x, int y)
OnIdleTimer mTimer
Environment mEnvironment


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:02