DVX_GUI/dvx/dvxDialog.h

80 lines
3.3 KiB
C

// dvxDialog.h — Modal dialogs for DVX GUI
//
// Provides pre-built modal dialog boxes (message box, file dialog) that
// block the caller and run their own event loop via dvxUpdate() until the
// user dismisses them. Modal dialogs set ctx->modalWindow to prevent input
// from reaching other windows during the dialog's lifetime.
//
// The flag encoding uses separate bit fields for button configuration
// (low nibble) and icon type (high nibble) so they can be OR'd together
// in a single int32_t argument, matching the Win16 MessageBox() convention.
#ifndef DVX_DIALOG_H
#define DVX_DIALOG_H
#include "dvxApp.h"
// ============================================================
// Message box button flags (low nibble)
// ============================================================
#define MB_OK 0x0000
#define MB_OKCANCEL 0x0001
#define MB_YESNO 0x0002
#define MB_YESNOCANCEL 0x0003
#define MB_RETRYCANCEL 0x0004
// ============================================================
// Message box icon flags (high nibble, OR with button flags)
// ============================================================
#define MB_ICONINFO 0x0010
#define MB_ICONWARNING 0x0020
#define MB_ICONERROR 0x0030
#define MB_ICONQUESTION 0x0040
// ============================================================
// Message box return values
// ============================================================
#define ID_OK 1
#define ID_CANCEL 2
#define ID_YES 3
#define ID_NO 4
#define ID_RETRY 5
// Display a modal message box with the specified button and icon combination.
// Blocks the caller by running dvxUpdate() in a loop until a button is
// pressed or the dialog is closed. Returns the ID_xxx value of the button
// that was pressed. The dialog window is automatically destroyed on return.
int32_t dvxMessageBox(AppContextT *ctx, const char *title, const char *message, int32_t flags);
// ============================================================
// File dialog flags
// ============================================================
#define FD_OPEN 0x0000 // Open file (default)
#define FD_SAVE 0x0001 // Save file
// ============================================================
// File dialog filter
// ============================================================
//
// Filters are displayed in a dropdown at the bottom of the file dialog.
// Pattern matching is case-insensitive and supports only single glob
// patterns (no semicolon-separated lists). This keeps the matching code
// trivial for a DOS filesystem where filenames are short and simple.
typedef struct {
const char *label; // e.g. "Text Files (*.txt)"
const char *pattern; // e.g. "*.txt" (case-insensitive, single pattern)
} FileFilterT;
// Display a modal file open/save dialog. The dialog shows a directory
// listing with navigation (parent directory, drive letters on DOS), a
// filename text input, and an optional filter dropdown. Blocks the caller
// via dvxUpdate() loop. Returns true if the user selected a file (path
// written to outPath), false if cancelled or closed. initialDir may be
// NULL to start in the current working directory.
bool dvxFileDialog(AppContextT *ctx, const char *title, int32_t flags, const char *initialDir, const FileFilterT *filters, int32_t filterCount, char *outPath, int32_t outPathSize);
#endif // DVX_DIALOG_H