forked from od-contrib/commander
-
Notifications
You must be signed in to change notification settings - Fork 2
/
window.h
executable file
·79 lines (53 loc) · 1.74 KB
/
window.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef _WINDOW_H_
#define _WINDOW_H_
#include <SDL.h>
#include "sdl_backports.h"
class CWindow
{
public:
// Destructor
virtual ~CWindow(void);
// Execute main loop of the window
int execute();
// Return value
const int getReturnValue(void) const;
// Draw window
virtual void render(const bool p_focus) const = 0;
// Is window full screen?
virtual bool isFullScreen(void) const;
// Call SDL_Start/StopTextInput accordingly.
virtual bool handlesTextInput() const;
protected:
// Constructor
CWindow(void);
// Window resized.
virtual void onResize();
// Mouse down event.
// Return true if re-render is needed after handling this.
virtual bool mouseDown(int button, int x, int y);
// Mouse wheel event.
// `dx` - the amount scrolled horizontally, positive to the right and negative to the left.
// `dy` - the amount scrolled vertically, positive away from the user and negative towards the user.
// Return true if re-render is needed after handling this.
virtual bool mouseWheel(int dx, int dy);
// Key press management
virtual const bool keyPress(const SDL_Event &p_event);
// Key hold management
virtual const bool keyHold(void);
// SDL2 text input events: SDL_TEXTINPUT and SDL_TEXTEDITING
virtual bool textInput(const SDL_Event &event);
// Timer tick
bool tick(SDLC_Keycode p_held);
// Timer for key hold
unsigned int m_timer;
SDLC_Keycode m_lastPressed;
// Return value
int m_retVal;
private:
bool handleZoomTrigger(const SDL_Event &event);
void triggerOnResize();
// Forbidden
CWindow(const CWindow &p_source);
const CWindow &operator =(const CWindow &p_source);
};
#endif