-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
sys_window.h
200 lines (174 loc) · 6.04 KB
/
sys_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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/**\file sys_window.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2012 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/**
* sys_window.h: Window management.
*/
#ifndef LIBDENG_SYS_WINDOW_H
#define LIBDENG_SYS_WINDOW_H
#include "dd_types.h"
#include "rect.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(UNIX)
# include <curses.h>
# include "dd_uinit.h"
#endif
#if defined(WIN32)
# include <windows.h>
# include "dd_winit.h"
#endif
// Structure used to describe what features are available in a window
// manager implementation.
typedef struct wminfo_s {
uint maxWindows; /* Max number of simultaneous windows of all
supported types
0 = Unlimited. */
uint maxConsoles;
boolean canMoveWindow; // Windows can be moved.
} wminfo_t;
typedef enum {
WT_NORMAL,
WT_CONSOLE
} ddwindowtype_t;
/**
* @defgroup consoleCommandlineFlags Console Commandline flags
* @{
*/
#define CLF_CURSOR_LARGE 0x1 // Use the large command line cursor.
/**@}*/
typedef struct {
ddwindowtype_t type;
boolean inited;
/// \note SDL cannot move windows; thus origin is ignored.
RectRaw geometry;
int flags;
#if defined(WIN32)
HWND hWnd; // Needed for input (among other things).
#endif
union {
struct {
#if defined(WIN32)
HGLRC glContext;
#endif
int bpp;
} normal;
struct {
#if defined(WIN32)
HANDLE hcScreen;
CONSOLE_SCREEN_BUFFER_INFO cbInfo;
WORD attrib;
#elif defined(UNIX)
WINDOW *winTitle, *winText, *winCommand;
#endif
int cx, cy;
int needNewLine;
struct {
int flags;
} cmdline;
} console;
};
} ddwindow_t;
// Doomsday window flags.
#define DDWF_VISIBLE 0x01
#define DDWF_FULLSCREEN 0x02
#define DDWF_CENTER 0x04
// Flags for Sys_SetWindow()
#define DDSW_NOSIZE 0x01
#define DDSW_NOMOVE 0x02
#define DDSW_NOBPP 0x04
#define DDSW_NOVISIBLE 0x08
#define DDSW_NOFULLSCREEN 0x10
#define DDSW_NOCENTER 0x20
#define DDSW_NOCHANGES (DDSW_NOSIZE & DDSW_NOMOVE & DDSW_NOBPP & \
DDSW_NOFULLSCREEN & DDSW_NOVISIBLE & \
DDSW_NOCENTER)
/**
* Currently active window. There is always one active window, so no need
* to worry about NULLs. The easiest way to get information about the
* window where drawing is being is done.
*/
extern const ddwindow_t* theWindow;
// A helpful macro that changes the origin of the screen
// coordinate system.
#define FLIP(y) (theWindow->geometry.size.height - (y+1))
boolean Sys_InitWindowManager(void);
boolean Sys_ShutdownWindowManager(void);
boolean Sys_GetWindowManagerInfo(wminfo_t* info);
boolean Sys_ChangeVideoMode(int width, int height, int bpp);
boolean Sys_GetDesktopBPP(int* bpp);
/**
* Window management.
*/
/**
* Create a new window.
*
* @param app Ptr to the application structure holding our globals.
* @param parentIdx Index number of the window that is to be the parent
* of the new window. If @c 0, window has no parent.
* @param origin Origin of the window in desktop-space.
* @param size Size of the window (client area) in desktop-space.
* @param bpp BPP (bits-per-pixel)
* @param flags DDWF_* flags, control appearance/behavior.
* @param type Type of window to be created (WT_*)
* @param title Window title string, ELSE @c NULL,.
* @param data Platform specific data.
*
* @return If @c 0, window creation was unsuccessful,
* ELSE 1-based index identifier of the new window.
*/
uint Sys_CreateWindow(application_t* app, uint parentIDX, const Point2Raw* origin,
const Size2Raw* size, int bpp, int flags, ddwindowtype_t type, const char* title, void* data);
boolean Sys_DestroyWindow(uint idx);
void Sys_UpdateWindow(uint idx);
/**
* Attempt to get the dimensions (and position) of the given window
* (client area) in screen-space.
*
* @param idx Unique identifier (1-based) to the window.
* @return Geometry of the window else @c NULL if @a idx is not valid.
*/
const RectRaw* Sys_GetWindowGeometry(uint idx);
const Point2Raw* Sys_GetWindowOrigin(uint idx);
const Size2Raw* Sys_GetWindowSize(uint idx);
boolean Sys_GetWindowBPP(uint idx, int* bpp);
boolean Sys_GetWindowFullscreen(uint idx, boolean* fullscreen);
boolean Sys_GetWindowVisibility(uint idx, boolean* show);
boolean Sys_SetActiveWindow(uint idx);
boolean Sys_SetWindow(uint idx, int x, int y, int w, int h, int bpp, uint wflags, uint uflags);
boolean Sys_SetWindowTitle(uint idx, const char* title);
ddwindow_t* Sys_Window(uint idx);
ddwindow_t* Sys_MainWindow(void);
/**
*\todo This is a compromise to prevent having to refactor half the
* engine. In general, system specific patterns should not be carried
* into the engine.
*/
#if defined(WIN32)
HWND Sys_GetWindowHandle(uint idx);
#endif
#ifdef __cplusplus
}
#endif
#endif /* LIBDENG_SYS_WINDOW_H */