112#define WINDOW_NUM_BUFFER_SZ 10
127#define WINDOW_FLAG_ACTIVE 0x01
128#define WINDOW_FLAG_DIRTY 0x04
132#define WINDOW_FLAG_MODAL 0x08
136#define WINDOW_FLAG_CHECKED 0x10
141#define WINDOW_FLAG_TEXT_NUM 0x10
143#define WINDOW_FLAG_TEXT_PTR 0x20
145#define WINDOW_FLAG_TEXT_MASK 0x30
147#define WINDOW_FLAG_SPRITE_DIR_MASK 0x30
149#define WINDOW_FLAG_SPRITE_SOUTH 0x00
150#define WINDOW_FLAG_SPRITE_NORTH 0x10
151#define WINDOW_FLAG_SPRITE_EAST 0x20
152#define WINDOW_FLAG_SPRITE_WEST 0x30
154#define WINDOW_FLAG_SPRITE_BORDER_SINGLE 0x40
158#define WINDOW_STRING_SZ_MAX 100
170#define WINDOW_PLACEMENT_CENTER 0x8000
175#define WINDOW_PLACEMENT_RIGHT_BOTTOM 0x2000
181#define WINDOW_PLACEMENT_GRID_RIGHT_DOWN 0xc000
186#define WINDOW_PLACEMENT_GRID 0x4000
192#define WINDOW_PLACEMENT_AUTO_MASK 0xe000
199#define WINDOW_PLACEMENT_PHYS_MASK 0x1fff
201#define WINDOW_SIZE_AUTO 0x8000
207#define WINDOW_SIZE_AUTO_MASK (WINDOW_PLACEMENT_AUTO_MASK)
214#define WINDOW_SIZE_PHYS_MASK (WINDOW_PLACEMENT_PHYS_MASK)
216#define window_screen_reset_grid() memory_zero_ptr( g_window_screen_grid, 4 * sizeof( int16_t ) );
223#define window_update_coords( window, x_y_w_h, coord ) (window)->coords[x_y_w_h] = ((window)->coords[x_y_w_h] & WINDOW_PLACEMENT_AUTO_MASK) | (WINDOW_PLACEMENT_PHYS_MASK & (coord));
229#define window_get_coords( window, x_y_w_h ) (((window)->coords[x_y_w_h] & WINDOW_PLACEMENT_PHYS_MASK))
234# define window_trace_printf( lvl, ... ) debug_printf( lvl, __VA_ARGS__ )
242# define window_trace_printf( ... )
246# define WINDOW_PREFAB_DEFAULT_FG() GRAPHICS_COLOR_WHITE
247# define WINDOW_PREFAB_DEFAULT_BG() GRAPHICS_COLOR_MAGENTA
248# define WINDOW_PREFAB_DEFAULT_HL() GRAPHICS_COLOR_CYAN
249#elif defined( DEPTH_CGA )
250# define WINDOW_PREFAB_DEFAULT_FG() GRAPHICS_COLOR_BLACK
251# define WINDOW_PREFAB_DEFAULT_BG() GRAPHICS_COLOR_MAGENTA
252# define WINDOW_PREFAB_DEFAULT_HL() GRAPHICS_COLOR_CYAN
253#elif defined( DEPTH_MONO )
255# define WINDOW_PREFAB_DEFAULT_FG() GRAPHICS_COLOR_WHITE
256# define WINDOW_PREFAB_DEFAULT_BG() GRAPHICS_COLOR_BLACK
257# define WINDOW_PREFAB_DEFAULT_HL() GRAPHICS_COLOR_WHITE
267 uint16_t auto_x, uint16_t auto_y, uint16_t auto_w, uint16_t auto_h
270int16_t window_reload_frames() SECTION_WINDOW;
277int16_t window_draw_all();
291 uint16_t
id, uint16_t parent_id, uint8_t type, uint8_t flags,
292 uint16_t x, uint16_t y, uint16_t w, uint16_t h,
294 int32_t data_scalar, const
char* data_string ) SECTION_WINDOW;
303void window_refresh( uint16_t w_id ) SECTION_WINDOW;
311int16_t window_modal();
314#define window_modal() (g_window_modals)
328#define WINDOW_CB_TABLE_4( f ) f( 4, WINDOW )
333#define WINDOW_CB_TABLE_3( f ) f( 3, SPRITE ) WINDOW_CB_TABLE_4( f )
340#define WINDOW_CB_TABLE_2( f ) f( 2, CHECK ) WINDOW_CB_TABLE_3( f )
347#define WINDOW_CB_TABLE_1( f ) f( 1, BUTTON ) WINDOW_CB_TABLE_2( f )
355#define WINDOW_CB_TABLE( f ) f( 0, LABEL ) WINDOW_CB_TABLE_1( f )
359typedef int16_t (*WINDOW_CB_DRAW)( uint16_t w_id,
struct WINDOW* windows );
365 uint16_t w_id,
struct WINDOW* windows, uint8_t w_h, uint16_t* out );
372uint8_t g_window_modals = 0;
374static uint16_t g_window_screen_coords[4] = {
375 0, 0, SCREEN_W, SCREEN_H
378static int16_t g_window_screen_grid[4] = {
382# define WINDOW_CB_DRAW_TABLE_PROTOTYPES( idx, name ) int16_t window_draw_ ## name( uint16_t w_id, struct WINDOW* windows );
386# define WINDOW_CB_SZ_TABLE_PROTOTYPES( idx, name ) uint8_t window_sz_ ## name( uint16_t w_id, struct WINDOW* windows, uint8_t w_h, uint16_t* out ) SECTION_WINDOW;
390# define WINDOW_CB_DRAW_TABLE_LIST( idx, name ) window_draw_ ## name,
392static const WINDOW_CB_DRAW gc_window_draw_callbacks[] = {
396# define WINDOW_CB_SZ_TABLE_LIST( idx, name ) window_sz_ ## name,
402# define WINDOW_CB_TABLE_CONSTS( idx, name ) RES_CONST uint16_t WINDOW_TYPE_ ## name = idx;
408extern uint8_t g_window_modals;
413# define WINDOW_CB_TABLE_CONSTS( idx, name ) extern RES_CONST uint16_t WINDOW_TYPE_ ## name;
int GRAPHICS_COLOR
Representation for specific colors on the current platform.
Definition: nullg.h:16
#define WINDOW_CB_TABLE(f)
WINDOW_TYPE_LABEL: A static text label.
Definition: window.h:355
#define WINDOW_CB_TABLE_CONSTS(idx, name)
Define extern constants that can be used e.g. in spawners.
Definition: window.h:413
int16_t window_push(uint16_t id, uint16_t parent_id, uint8_t type, uint8_t flags, uint16_t x, uint16_t y, uint16_t w, uint16_t h, GRAPHICS_COLOR fg, GRAPHICS_COLOR bg, uint8_t render_flags, int32_t data_scalar, const char *data_string) SECTION_WINDOW
Push a new window onto the global window stack.
void window_shutdown() SECTION_WINDOW
Global shutdown for the window subsystem. Runs at shutdown.
void window_pop(uint16_t id) SECTION_WINDOW
Destroy the top-most onscreen WINDOW with the given WINDOW::id.
uint8_t(* WINDOW_CB_SZ)(uint16_t w_id, struct WINDOW *windows, uint8_t w_h, uint16_t *out)
Definition: window.h:364
int16_t window_init(uint16_t auto_x, uint16_t auto_y, uint16_t auto_w, uint16_t auto_h) SECTION_WINDOW
Global initialization for the window subsystem. Runs at startup.
struct FAKE_MEMORY_HANDLE * MEMORY_HANDLE
A reference to a block of memory which the operating system may move around on its own to free up spa...
Definition: fakem.h:21
An emulated memory handle for modern systems. Overridden on most platforms.
Definition: memory.h:20
Defines a graphical window frame/background with a set of image assets.
Definition: window.h:33
uint16_t t
Top edge.
Definition: window.h:43
uint16_t r
Right edge.
Definition: window.h:47
uint16_t tl
Top-left corner.
Definition: window.h:37
uint16_t br
Bottom-right corner.
Definition: window.h:39
uint16_t tr
Top-right corner.
Definition: window.h:35
uint16_t b
Bottom edge.
Definition: window.h:45
uint16_t l
Left edge.
Definition: window.h:49
uint16_t c
Center fill.
Definition: window.h:51
uint16_t bl
Bottom-left corner.
Definition: window.h:41
Struct representing an on-screen graphical window.
Definition: window.h:55
GRAPHICS_COLOR bg
Background Unilayer Graphics Colors with which to draw this window.
Definition: window.h:78
uint16_t parent_id
Unique identifier of the parent window of this window.
Definition: window.h:59
union CONTROL_DATA data
Data specific to each GUI Window Types.
Definition: window.h:88
uint16_t id
Unique identifier used to find this window in the global stack.
Definition: window.h:57
GRAPHICS_COLOR fg
Foreground Unilayer Graphics Colors with which to draw this window's text.
Definition: window.h:73
uint16_t coords[4]
Pixel coordinates for this window on-screen; a tuple indexed as GUI_X, GUI_Y, GUI_W,...
Definition: window.h:86
uint8_t render_flags
Flags passed directly to rendering function, depending on GUI Window Types.
Definition: window.h:68
uint8_t flags
GUI Window Flags modifying window behavior.
Definition: window.h:63
uint8_t type
Type of window defined by a constant.
Definition: window.h:61
A piece of data attached to CONTROL::data.
Definition: window.h:23