2024-01-14 21:59:13 -05:00
|
|
|
//
|
|
|
|
// Created by william on 1/12/24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef NESEMULATOR_WINDOW_H
|
|
|
|
#define NESEMULATOR_WINDOW_H
|
|
|
|
|
|
|
|
#include <panel.h>
|
|
|
|
#include "cursor.h"
|
|
|
|
|
|
|
|
typedef struct window {
|
|
|
|
PANEL *panel;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
} Window;
|
|
|
|
|
|
|
|
typedef struct interact_window {
|
|
|
|
Window window;
|
|
|
|
Cursor cursor;
|
|
|
|
void *view;
|
|
|
|
|
|
|
|
void (*handle_cursor_move)(struct interact_window *window, int horizontal, int vertical);
|
|
|
|
|
|
|
|
void (*handle_key_down)(struct interact_window *window, int keycode);
|
2024-01-16 15:46:22 -05:00
|
|
|
|
|
|
|
void (*deinit)(struct interact_window *window);
|
2024-01-14 21:59:13 -05:00
|
|
|
} InteractWindow;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a window with a position, size and title.
|
|
|
|
*
|
|
|
|
* @param window The window to initialize
|
|
|
|
* @param x The horizontal position (left to right)
|
|
|
|
* @param y The vertical position (top to bottom)
|
|
|
|
* @param width The window width
|
|
|
|
* @param height The window height
|
|
|
|
* @param title The window title
|
|
|
|
*/
|
|
|
|
void window_init(Window *window, int x, int y, int width, int height, char *title);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes an interactable window with a position, size and title.
|
|
|
|
*
|
|
|
|
* @param window The window to initialize
|
|
|
|
* @param x The horizontal position (left to right)
|
|
|
|
* @param y The vertical position (top to bottom)
|
|
|
|
* @param width The window width
|
|
|
|
* @param height The window height
|
|
|
|
* @param title The window title
|
|
|
|
*/
|
|
|
|
void window_inter_init(InteractWindow *window, int x, int y, int width, int height, char *title);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the cursor of an interactable window.
|
|
|
|
*
|
|
|
|
* @param window The window
|
|
|
|
* @param max_x The cursor's maximum horizontal position
|
|
|
|
* @param max_y The cursor's maximum vertical position
|
|
|
|
*/
|
|
|
|
void window_inter_cursor_init(InteractWindow *window, int max_x, int max_y);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints text on a window.
|
|
|
|
*
|
|
|
|
* @param window The window
|
|
|
|
* @param x The horizontal position (left to right)
|
|
|
|
* @param y The vertical position (top to bottom)
|
|
|
|
* @param fmt A format string
|
|
|
|
* @param ... The format string arguments
|
|
|
|
*/
|
|
|
|
void window_print(Window *window, int x, int y, const char *fmt, ...);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints text on an interactable window.
|
|
|
|
*
|
|
|
|
* @param window The window
|
|
|
|
* @param x The horizontal position (left to right)
|
|
|
|
* @param y The vertical position (top to bottom)
|
|
|
|
* @param fmt A format string
|
|
|
|
* @param ... The format string arguments
|
|
|
|
*/
|
|
|
|
void window_inter_print(InteractWindow *window, int x, int y, const char *fmt, ...);
|
|
|
|
|
|
|
|
void window_inter_deinit(InteractWindow *window);
|
|
|
|
|
|
|
|
#endif //NESEMULATOR_WINDOW_H
|