DVX_GUI/docs/dvx_widget_system.html

134 lines
8.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Base WidgetT (Common Properties, Events, and Operations)</title>
<style>
body { font-family: sans-serif; margin: 0; padding: 0; display: flex; }
nav { width: 250px; min-width: 250px; background: #f0f0f0; padding: 16px;
border-right: 1px solid #ccc; height: 100vh; overflow-y: auto;
position: sticky; top: 0; box-sizing: border-box; }
nav ul { list-style: none; padding-left: 16px; margin: 4px 0; }
nav > ul { padding-left: 0; }
nav a { text-decoration: none; color: #0066cc; }
nav a:hover { text-decoration: underline; }
main { flex: 1; padding: 24px 32px; max-width: 800px; }
h1 { border-bottom: 2px solid #333; padding-bottom: 4px; }
h2 { border-bottom: 1px solid #999; padding-bottom: 2px; margin-top: 32px; }
h3 { margin-top: 24px; }
pre { background: #f8f8f8; border: 1px solid #ddd; padding: 8px;
overflow-x: auto; font-size: 14px; }
blockquote { background: #fffde7; border-left: 4px solid #ffc107;
padding: 8px 12px; margin: 12px 0; }
hr { border: none; border-top: 1px solid #ccc; margin: 24px 0; }
img { max-width: 100%; }
.topic { margin-bottom: 48px; }
</style>
</head>
<body>
<nav>
<h3>Contents</h3>
<ul>
<li><a href="#widget.base">Widget System</a></li>
</ul>
<h3>Index</h3>
<ul>
<li><a href="#widget.base">WidgetT</a></li>
<li><a href="#widget.base">Widget Base</a></li>
<li><a href="#widget.base">Common Properties</a></li>
<li><a href="#widget.base">Common Events</a></li>
<li><a href="#widget.base">wgtPixels</a></li>
<li><a href="#widget.base">wgtChars</a></li>
<li><a href="#widget.base">wgtPercent</a></li>
<li><a href="#widget.base">onClick</a></li>
<li><a href="#widget.base">onChange</a></li>
<li><a href="#widget.base">onKeyPress</a></li>
<li><a href="#widget.base">onKeyDown</a></li>
<li><a href="#widget.base">onMouseDown</a></li>
<li><a href="#widget.base">wgtInitWindow</a></li>
<li><a href="#widget.base">wgtGetContext</a></li>
<li><a href="#widget.base">wgtInvalidate</a></li>
<li><a href="#widget.base">wgtSetText</a></li>
<li><a href="#widget.base">wgtGetText</a></li>
<li><a href="#widget.base">wgtSetEnabled</a></li>
<li><a href="#widget.base">wgtSetFocused</a></li>
<li><a href="#widget.base">wgtSetVisible</a></li>
<li><a href="#widget.base">wgtFind</a></li>
<li><a href="#widget.base">wgtDestroy</a></li>
</ul>
</nav>
<main>
<div class="topic" id="widget.base">
<h1>Base WidgetT (Common Properties, Events, and Operations)</h1>
<h2>DVX Widget System</h2>
<p>Complete reference for the DVX GUI widget toolkit. All widgets are implemented as dynamically loaded DXE modules. They are created via convenience macros that wrap the per-widget API function tables. The base WidgetT structure is defined in core/dvxWidget.h; individual widget headers live in widgets/.</p>
<p>Individual widgets are documented in their own sections. See the table of contents for the full list.</p>
<h3>Base WidgetT (Common Properties, Events, and Operations)</h3>
<p>Every widget inherits from the WidgetT structure defined in core/dvxWidget.h. The fields and callbacks listed here are available on all widget types.</p>
<h4>Common Properties</h4>
<pre> Field Type Description
----- ---- -----------
name char[32] Widget name for lookup via wgtFind().
x, y, w, h int32_t Computed geometry relative to the window content area (set by layout).
minW, minH int32_t (tagged) Minimum size hints. Use wgtPixels(), wgtChars(), or wgtPercent(). 0 = auto.
maxW, maxH int32_t (tagged) Maximum size constraints. 0 = no limit.
prefW, prefH int32_t (tagged) Preferred size. 0 = auto.
weight int32_t Extra-space distribution weight. 0 = fixed, 100 = normal. A widget with weight=200 gets twice the extra space of one with weight=100.
align WidgetAlignE Main-axis alignment for children: AlignStartE, AlignCenterE, AlignEndE.
spacing int32_t (tagged) Spacing between children (containers only). 0 = default.
padding int32_t (tagged) Internal padding (containers only). 0 = default.
fgColor uint32_t Foreground color override. 0 = use color scheme default.
bgColor uint32_t Background color override. 0 = use color scheme default.
visible bool Visibility state.
enabled bool Enabled state. Disabled widgets are grayed out and ignore input.
readOnly bool Read-only mode: allows scrolling/selection but blocks editing.
swallowTab bool When true, Tab key goes to the widget instead of navigating focus.
accelKey char Lowercase accelerator character. 0 if none.
tooltip const char * Tooltip text. NULL = none. Caller owns the string.
contextMenu MenuT * Right-click context menu. NULL = none. Caller owns.
userData void * Application-defined user data pointer.</pre>
<h4>Size Specification Macros</h4>
<pre> Macro Description
----- -----------
wgtPixels(v) Size in pixels.
wgtChars(v) Size in character widths (multiplied by font charWidth).
wgtPercent(v) Size as a percentage of parent dimension.</pre>
<h4>Common Events (Callbacks)</h4>
<p>These callback function pointers are available on every WidgetT. Set them directly on the widget struct.</p>
<pre> Callback Signature Description
-------- --------- -----------
onClick void (*)(WidgetT *w) Fires on mouse click / activation.
onDblClick void (*)(WidgetT *w) Fires on double-click.
onChange void (*)(WidgetT *w) Fires when the widget's value changes (text, selection, check state, etc.).
onFocus void (*)(WidgetT *w) Fires when the widget receives keyboard focus.
onBlur void (*)(WidgetT *w) Fires when the widget loses keyboard focus.
onKeyPress void (*)(WidgetT *w, int32_t keyAscii) Fires on a printable key press (ASCII value).
onKeyDown void (*)(WidgetT *w, int32_t keyCode, int32_t shift) Fires on key down (scan code + shift state).
onKeyUp void (*)(WidgetT *w, int32_t keyCode, int32_t shift) Fires on key up.
onMouseDown void (*)(WidgetT *w, int32_t button, int32_t x, int32_t y) Fires on mouse button press.
onMouseUp void (*)(WidgetT *w, int32_t button, int32_t x, int32_t y) Fires on mouse button release.
onMouseMove void (*)(WidgetT *w, int32_t button, int32_t x, int32_t y) Fires on mouse movement over the widget.
onScroll void (*)(WidgetT *w, int32_t delta) Fires on mouse wheel scroll.
onValidate bool (*)(WidgetT *w) Validation callback. Return false to cancel a pending write.</pre>
<h4>Common Operations</h4>
<pre> Function Description
-------- -----------
WidgetT *wgtInitWindow(AppContextT *ctx, WindowT *win) Initialize widgets for a window. Returns the root VBox container.
AppContextT *wgtGetContext(const WidgetT *w) Walk up from any widget to retrieve the AppContextT.
void wgtInvalidate(WidgetT *w) Mark widget for re-layout and repaint. Propagates to ancestors.
void wgtInvalidatePaint(WidgetT *w) Mark widget for repaint only (no layout recalculation).
void wgtSetText(WidgetT *w, const char *text) Set widget text (label, button, textinput, etc.).
const char *wgtGetText(const WidgetT *w) Get widget text.
void wgtSetEnabled(WidgetT *w, bool enabled) Enable or disable a widget.
void wgtSetReadOnly(WidgetT *w, bool readOnly) Set read-only mode.
void wgtSetFocused(WidgetT *w) Set keyboard focus to a widget.
WidgetT *wgtGetFocused(void) Get the currently focused widget.
void wgtSetVisible(WidgetT *w, bool visible) Show or hide a widget.
void wgtSetName(WidgetT *w, const char *name) Set widget name for lookup.
WidgetT *wgtFind(WidgetT *root, const char *name) Find a widget by name in the subtree.
void wgtDestroy(WidgetT *w) Destroy a widget and all its children.
void wgtSetTooltip(WidgetT *w, const char *text) Set tooltip text. Pass NULL to remove.</pre>
</div>
</main>
</body>
</html>