DVX_GUI/apps/about/about.c

99 lines
2.6 KiB
C

// about.c — "About DVX Shell" sample DXE application (callback-only)
//
// Demonstrates a simple callback-only app: creates a window with widgets,
// registers callbacks, and returns. The shell event loop handles the rest.
#include "dvxApp.h"
#include "dvxWidget.h"
#include "shellApp.h"
#include <stdint.h>
#include <stdbool.h>
// ============================================================
// Prototypes
// ============================================================
int32_t appMain(DxeAppContextT *ctx);
static void onClose(WindowT *win);
static void onOkClick(WidgetT *w);
// ============================================================
// App state
// ============================================================
static DxeAppContextT *sCtx = NULL;
static WindowT *sWin = NULL;
// ============================================================
// App descriptor (required DXE export)
// ============================================================
AppDescriptorT appDescriptor = {
.name = "About",
.hasMainLoop = false,
.stackSize = 0,
.priority = TS_PRIORITY_NORMAL
};
// ============================================================
// Callbacks
// ============================================================
static void onClose(WindowT *win) {
dvxDestroyWindow(sCtx->shellCtx, win);
sWin = NULL;
}
static void onOkClick(WidgetT *w) {
(void)w;
if (sWin) {
dvxDestroyWindow(sCtx->shellCtx, sWin);
sWin = NULL;
}
}
// ============================================================
// Entry point
// ============================================================
int32_t appMain(DxeAppContextT *ctx) {
sCtx = ctx;
AppContextT *ac = ctx->shellCtx;
int32_t screenW = ac->display.width;
int32_t screenH = ac->display.height;
int32_t winW = 280;
int32_t winH = 200;
int32_t winX = (screenW - winW) / 2;
int32_t winY = (screenH - winH) / 3;
sWin = dvxCreateWindow(ac, "About DVX Shell", winX, winY, winW, winH, false);
if (!sWin) {
return -1;
}
sWin->onClose = onClose;
WidgetT *root = wgtInitWindow(ac, sWin);
wgtLabel(root, "DVX Shell 1.0");
wgtHSeparator(root);
wgtLabel(root, "A DOS Visual eXecutive desktop shell for DJGPP/DPMI.");
wgtLabel(root, "Using DXE3 dynamic loading for application modules.");
wgtSpacer(root);
WidgetT *btnRow = wgtHBox(root);
btnRow->align = AlignCenterE;
WidgetT *okBtn = wgtButton(btnRow, "OK");
okBtn->onClick = onOkClick;
okBtn->prefW = wgtPixels(80);
dvxFitWindow(ac, sWin);
wgtInvalidate(root);
return 0;
}