GteWindowBase.h
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 #pragma once
9 
12 #include <Graphics/GteBaseEngine.h>
14 
15 namespace gte
16 {
17 
19 {
20 public:
21  // All parameters for constructing windows are in this structure. Derived
22  // classes may define nested classes to derive from this. The creation by
23  // WindowSystem requires you to pass such a structure.
25  {
26  Parameters();
27 
28  Parameters(std::wstring const& inTitle,
29  int inXOrigin, int inYOrigin, int inXSize, int inYSize);
30 
31  std::wstring title;
32  int xOrigin, yOrigin, xSize, ySize;
33  bool allowResize, created;
34  std::shared_ptr<BaseEngine> engine;
35  std::shared_ptr<ProgramFactory> factory;
36  };
37 
38 protected:
39  // Abstract base class. Only WindowSystem may create windows.
40  WindowBase(Parameters& parameters);
41 public:
42  virtual ~WindowBase();
43 
44  // Member access.
45  virtual void SetTitle(std::wstring const& title);
46  inline std::wstring GetTitle() const;
47  inline int GetXOrigin() const;
48  inline int GetYOrigin() const;
49  inline int GetXSize() const;
50  inline int GetYSize() const;
51  inline bool IsMinimized() const;
52  inline bool IsMaximized() const;
53  inline float GetAspectRatio() const;
54 
55  // Display callbacks.
56  virtual void OnMove(int x, int y);
57  virtual bool OnResize(int xSize, int ySize);
58  virtual void OnMinimize();
59  virtual void OnMaximize();
60  virtual void OnDisplay();
61  virtual void OnIdle();
62 
63  // Keyboard callbacks. OnCharPress allows you to distinguish between
64  // upper-case and lower-case letters; OnKeyDown and OnKeyUp do not.
65  // For OnCharPress, pressing KEY_ESCAPE terminates the application.
66  // Pressing ' ' resets the application timer.
67  virtual bool OnCharPress(unsigned char key, int x, int y);
68  virtual bool OnKeyDown(int key, int x, int y);
69  virtual bool OnKeyUp(int key, int x, int y);
70 
71  // Mouse callbacks and state information.
72  // TODO: HACK FOR NOW. Once these are removed, all the sample applications
73  // must have their signatures changed.
74  typedef int MouseButton;
75  typedef int MouseState;
76  // END TODO;
77  virtual bool OnMouseClick(int button, int state, int x, int y, unsigned int modifiers);
78  virtual bool OnMouseMotion(int button, int x, int y, unsigned int modifiers);
79  virtual bool OnMouseWheel(int delta, int x, int y, unsigned int modifiers);
80  virtual void SetMousePosition(int x, int y);
81  virtual void GetMousePosition(int& x, int& y) const;
82 
83  // Actions to take before the window closes.
84  virtual void OnClose();
85 
86  // Key identifiers. These are platform-specific, so classes that
87  // implement the WindowApplication interfaces must define these
88  // variables. They are not defined by WindowApplication.
89  static int const KEY_ESCAPE;
90  static int const KEY_LEFT;
91  static int const KEY_RIGHT;
92  static int const KEY_UP;
93  static int const KEY_DOWN;
94  static int const KEY_HOME;
95  static int const KEY_END;
96  static int const KEY_PAGE_UP;
97  static int const KEY_PAGE_DOWN;
98  static int const KEY_INSERT;
99  static int const KEY_DELETE;
100  static int const KEY_F1;
101  static int const KEY_F2;
102  static int const KEY_F3;
103  static int const KEY_F4;
104  static int const KEY_F5;
105  static int const KEY_F6;
106  static int const KEY_F7;
107  static int const KEY_F8;
108  static int const KEY_F9;
109  static int const KEY_F10;
110  static int const KEY_F11;
111  static int const KEY_F12;
112  static int const KEY_BACKSPACE;
113  static int const KEY_TAB;
114  static int const KEY_ENTER;
115  static int const KEY_RETURN;
116 
117  // Keyboard modifiers.
118  static int const KEY_SHIFT;
119  static int const KEY_CONTROL;
120  static int const KEY_ALT;
121  static int const KEY_COMMAND;
122 
123  // Mouse buttons.
124  static int const MOUSE_NONE;
125  static int const MOUSE_LEFT;
126  static int const MOUSE_MIDDLE;
127  static int const MOUSE_RIGHT;
128 
129  // Mouse state.
130  static int const MOUSE_UP;
131  static int const MOUSE_DOWN;
132 
133  // Mouse modifiers.
134  static int const MODIFIER_CONTROL;
135  static int const MODIFIER_LBUTTON;
136  static int const MODIFIER_MBUTTON;
137  static int const MODIFIER_RBUTTON;
138  static int const MODIFIER_SHIFT;
139 
140 protected:
141  // Get the GTE_PATH environment variable has been set. Derived classes
142  // use this variable to ensure that any input data sets necessary for the
143  // sample application exist. If the function returns "", the GTE_PATH
144  // variable has not been set and the derived class should fail gracefully
145  // by setting parameters.created to 'false' and returning.
146  std::string GetGTEPath();
147 
148  // Standard window information.
149  std::wstring mTitle;
150  int mXOrigin, mYOrigin, mXSize, mYSize;
154 
157 
158  // Graphics device and camera.
159  std::shared_ptr<BaseEngine> mBaseEngine;
160  std::shared_ptr<ProgramFactory> mProgramFactory;
161 };
162 
163 
164 inline std::wstring WindowBase::GetTitle() const
165 {
166  return mTitle;
167 }
168 
169 inline int WindowBase::GetXOrigin() const
170 {
171  return mXOrigin;
172 }
173 
174 inline int WindowBase::GetYOrigin() const
175 {
176  return mYOrigin;
177 }
178 
179 inline int WindowBase::GetXSize() const
180 {
181  return mXSize;
182 }
183 
184 inline int WindowBase::GetYSize() const
185 {
186  return mYSize;
187 }
188 
189 inline bool WindowBase::IsMinimized() const
190 {
191  return mIsMinimized;
192 }
193 
194 inline bool WindowBase::IsMaximized() const
195 {
196  return mIsMaximized;
197 }
198 
199 inline float WindowBase::GetAspectRatio() const
200 {
201  return (float)mXSize / (float)mYSize;
202 }
203 
204 }
static int const KEY_LEFT
Definition: GteWindowBase.h:90
int GetYSize() const
static int const MODIFIER_SHIFT
bool IsMinimized() const
static int const MOUSE_MIDDLE
static int const KEY_F1
int GetXOrigin() const
static int const MODIFIER_RBUTTON
static int const KEY_COMMAND
static int const KEY_F10
static int const KEY_ALT
static int const KEY_PAGE_UP
Definition: GteWindowBase.h:96
static int const MODIFIER_LBUTTON
std::shared_ptr< ProgramFactory > mProgramFactory
static int const KEY_HOME
Definition: GteWindowBase.h:94
static int const KEY_RETURN
static int const KEY_F7
static int const MOUSE_RIGHT
float GetAspectRatio() const
GLint GLenum GLint x
Definition: glcorearb.h:404
std::wstring mTitle
std::wstring GetTitle() const
static int const KEY_TAB
static int const MOUSE_UP
static int const KEY_F3
bool IsMaximized() const
static int const MODIFIER_CONTROL
static int const KEY_F11
static int const KEY_F4
static int const KEY_BACKSPACE
static int const MOUSE_DOWN
static int const KEY_DELETE
Definition: GteWindowBase.h:99
static int const MOUSE_NONE
static int const KEY_ENTER
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
std::shared_ptr< ProgramFactory > factory
Definition: GteWindowBase.h:35
int GetYOrigin() const
static int const KEY_F5
static int const KEY_F12
static int const KEY_INSERT
Definition: GteWindowBase.h:98
static int const KEY_PAGE_DOWN
Definition: GteWindowBase.h:97
static int const KEY_F6
static int const MOUSE_LEFT
static int const KEY_RIGHT
Definition: GteWindowBase.h:91
static int const KEY_END
Definition: GteWindowBase.h:95
static int const KEY_ESCAPE
Definition: GteWindowBase.h:89
int GetXSize() const
static int const KEY_SHIFT
static int const KEY_UP
Definition: GteWindowBase.h:92
static int const KEY_DOWN
Definition: GteWindowBase.h:93
static int const KEY_F8
std::shared_ptr< BaseEngine > engine
Definition: GteWindowBase.h:34
static int const KEY_CONTROL
std::shared_ptr< BaseEngine > mBaseEngine
static int const KEY_F2
static int const MODIFIER_MBUTTON
GLint y
Definition: glcorearb.h:98
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63
OnIdleTimer mTimer
Environment mEnvironment
static int const KEY_F9


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