87 lines
2.7 KiB
C
87 lines
2.7 KiB
C
// dvx_app.h — Layer 5: Application API for DV/X GUI
|
|
#ifndef DVX_APP_H
|
|
#define DVX_APP_H
|
|
|
|
#include "dvxTypes.h"
|
|
#include "dvxVideo.h"
|
|
#include "dvxDraw.h"
|
|
#include "dvxComp.h"
|
|
#include "dvxWm.h"
|
|
|
|
#include <time.h>
|
|
|
|
// ============================================================
|
|
// Application context
|
|
// ============================================================
|
|
|
|
typedef struct AppContextT {
|
|
DisplayT display;
|
|
WindowStackT stack;
|
|
DirtyListT dirty;
|
|
BlitOpsT blitOps;
|
|
BitmapFontT font;
|
|
ColorSchemeT colors;
|
|
PopupStateT popup;
|
|
CursorT cursors[5]; // indexed by CURSOR_xxx
|
|
int32_t cursorId; // active cursor shape
|
|
uint32_t cursorFg; // pre-packed cursor colors
|
|
uint32_t cursorBg;
|
|
bool running;
|
|
int32_t mouseX;
|
|
int32_t mouseY;
|
|
int32_t mouseButtons;
|
|
int32_t prevMouseX;
|
|
int32_t prevMouseY;
|
|
int32_t prevMouseButtons;
|
|
clock_t lastIconClickTime;
|
|
int32_t lastIconClickId; // window ID of last-clicked minimized icon (-1 = none)
|
|
clock_t lastCloseClickTime;
|
|
int32_t lastCloseClickId; // window ID of last-clicked close gadget (-1 = none)
|
|
} AppContextT;
|
|
|
|
// Initialize the application (VESA mode, input, etc.)
|
|
int32_t dvxInit(AppContextT *ctx, int32_t requestedW, int32_t requestedH, int32_t preferredBpp);
|
|
|
|
// Shut down and restore text mode
|
|
void dvxShutdown(AppContextT *ctx);
|
|
|
|
// Run the main event loop (returns when ctx->running is set to false)
|
|
void dvxRun(AppContextT *ctx);
|
|
|
|
// Create a window
|
|
WindowT *dvxCreateWindow(AppContextT *ctx, const char *title,
|
|
int32_t x, int32_t y, int32_t w, int32_t h,
|
|
bool resizable);
|
|
|
|
// Destroy a window
|
|
void dvxDestroyWindow(AppContextT *ctx, WindowT *win);
|
|
|
|
// Invalidate a region of a window's content area (triggers repaint)
|
|
void dvxInvalidateRect(AppContextT *ctx, WindowT *win,
|
|
int32_t x, int32_t y, int32_t w, int32_t h);
|
|
|
|
// Invalidate entire window content
|
|
void dvxInvalidateWindow(AppContextT *ctx, WindowT *win);
|
|
|
|
// Request exit from main loop
|
|
void dvxQuit(AppContextT *ctx);
|
|
|
|
// Set window title
|
|
void dvxSetTitle(AppContextT *ctx, WindowT *win, const char *title);
|
|
|
|
// Get the default font
|
|
const BitmapFontT *dvxGetFont(const AppContextT *ctx);
|
|
|
|
// Get the color scheme
|
|
const ColorSchemeT *dvxGetColors(const AppContextT *ctx);
|
|
|
|
// Get the display
|
|
DisplayT *dvxGetDisplay(AppContextT *ctx);
|
|
|
|
// Get blit ops
|
|
const BlitOpsT *dvxGetBlitOps(const AppContextT *ctx);
|
|
|
|
// Load an icon for a window from an image file
|
|
int32_t dvxSetWindowIcon(AppContextT *ctx, WindowT *win, const char *path);
|
|
|
|
#endif // DVX_APP_H
|