dvxVideo.h -- Layer 1: VESA VBE Video Backend
dvxVideo.h -- Layer 1: VESA VBE Video Backend
-
The lowest layer. Responsible for VESA VBE mode negotiation, LFB mapping via
-DPMI, system RAM backbuffer allocation, pixel format discovery, and color
-packing. LFB-only design: bank switching is deliberately unsupported.
+
The lowest layer. Responsible for VESA VBE mode negotiation, LFB mapping via DPMI, system RAM backbuffer allocation, pixel format discovery, and color packing. LFB-only design: bank switching is deliberately unsupported.
videoInit
int32_t videoInit(DisplayT *d, int32_t requestedW, int32_t requestedH, int32_t preferredBpp);
-
Probe VBE for a mode matching the requested resolution and depth, enable it,
-map the LFB into DPMI linear address space, and allocate a system RAM
-backbuffer. preferredBpp is a hint; the closest available depth is used if
-an exact match is not found.
+
Probe VBE for a mode matching the requested resolution and depth, enable it, map the LFB into DPMI linear address space, and allocate a system RAM backbuffer. preferredBpp is a hint; the closest available depth is used if an exact match is not found.
Parameter Description
--------- -----------
d Display context to initialize
@@ -541,17 +513,13 @@ an exact match is not found.
Returns: 0 on success, negative on failure.
videoShutdown
void videoShutdown(DisplayT *d);
-Restore VGA text mode (mode 3), unmap the LFB, and free the backbuffer. Safe
-to call even if videoInit() failed.
+Restore VGA text mode (mode 3), unmap the LFB, and free the backbuffer. Safe to call even if videoInit() failed.
Parameter Description
--------- -----------
d Display context to shut down
packColor
uint32_t packColor(const DisplayT *d, uint8_t r, uint8_t g, uint8_t b);
-Pack an RGB triplet into the display's native pixel format. For direct-color
-modes (15/16/32 bpp), returns a packed pixel value using shift/mask fields.
-For 8-bit mode, returns the nearest palette index via Euclidean distance in
-RGB space.
+Pack an RGB triplet into the display's native pixel format. For direct-color modes (15/16/32 bpp), returns a packed pixel value using shift/mask fields. For 8-bit mode, returns the nearest palette index via Euclidean distance in RGB space.
Parameter Description
--------- -----------
d Display context (provides pixel format)
@@ -559,9 +527,7 @@ RGB space.
Returns: Native pixel value suitable for direct framebuffer write.
setClipRect
void setClipRect(DisplayT *d, int32_t x, int32_t y, int32_t w, int32_t h);
-Set the clip rectangle on the display. All subsequent draw operations clip
-to this rectangle. The caller must save and restore the clip rect around
-scoped operations.
+Set the clip rectangle on the display. All subsequent draw operations clip to this rectangle. The caller must save and restore the clip rect around scoped operations.
Parameter Description
--------- -----------
d Display context
@@ -576,22 +542,17 @@ scoped operations.
dvxDraw.h -- Layer 2: Drawing Primitives
dvxDraw.h -- Layer 2: Drawing Primitives
-
All 2D drawing operations: rectangle fills, bitmap blits, text rendering,
-bevels, lines, and cursor rendering. Every function draws into the display's
-backbuffer and clips to the current clip rectangle. This layer is stateless
-beyond the clip rect on DisplayT.
+
All 2D drawing operations: rectangle fills, bitmap blits, text rendering, bevels, lines, and cursor rendering. Every function draws into the display's backbuffer and clips to the current clip rectangle. This layer is stateless beyond the clip rect on DisplayT.
drawInit
void drawInit(BlitOpsT *ops, const DisplayT *d);
-
Populate a BlitOpsT with the correct span functions for the display's pixel
-depth. Must be called once after videoInit().
+
Populate a BlitOpsT with the correct span functions for the display's pixel depth. Must be called once after videoInit().
Parameter Description
--------- -----------
ops BlitOpsT to populate
d Initialized display context
rectFill
void rectFill(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
-
Fill a rectangle with a solid color. Clips to the display clip rect.
-Workhorse for backgrounds, window fills, and clear operations.
+
Fill a rectangle with a solid color. Clips to the display clip rect. Workhorse for backgrounds, window fills, and clear operations.
Parameter Description
--------- -----------
d Display context
@@ -600,8 +561,7 @@ Workhorse for backgrounds, window fills, and clear operations.
color Packed pixel color
rectCopy
void rectCopy(DisplayT *d, const BlitOpsT *ops, int32_t dstX, int32_t dstY, const uint8_t *srcBuf, int32_t srcPitch, int32_t srcX, int32_t srcY, int32_t w, int32_t h);
-
Copy a rectangle from an arbitrary source buffer into the backbuffer. Used
-to blit per-window content buffers during compositing.
+
Copy a rectangle from an arbitrary source buffer into the backbuffer. Used to blit per-window content buffers during compositing.
Parameter Description
--------- -----------
d Display context
@@ -613,8 +573,7 @@ to blit per-window content buffers during compositing.
w, h Rectangle dimensions to copy
rectCopyGrayscale
void rectCopyGrayscale(DisplayT *d, const BlitOpsT *ops, int32_t dstX, int32_t dstY, const uint8_t *srcBuf, int32_t srcPitch, int32_t srcX, int32_t srcY, int32_t w, int32_t h);
-
Copy a rectangle with grayscale conversion. Each pixel's RGB is converted to
-luminance (0.299R + 0.587G + 0.114B) for a disabled/grayed appearance.
+
Copy a rectangle with grayscale conversion. Each pixel's RGB is converted to luminance (0.299R + 0.587G + 0.114B) for a disabled/grayed appearance.
Parameter Description
--------- -----------
d Display context
@@ -625,8 +584,7 @@ luminance (0.299R + 0.587G + 0.114B) for a disabled/grayed appearance.
w, h Rectangle dimensions
drawBevel
void drawBevel(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, int32_t h, const BevelStyleT *style);
-
Draw a beveled frame. Top/left edges in highlight color, bottom/right in
-shadow. Interior filled with face color if non-zero.
+
Draw a beveled frame. Top/left edges in highlight color, bottom/right in shadow. Interior filled with face color if non-zero.
Parameter Description
--------- -----------
d Display context
@@ -635,9 +593,7 @@ shadow. Interior filled with face color if non-zero.
style Bevel colors and width
drawChar
int32_t drawChar(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, char ch, uint32_t fg, uint32_t bg, bool opaque);
-
Draw a single character glyph. When opaque is true, the background fills the
-entire cell; when false, only foreground pixels are drawn (transparent
-background).
+
Draw a single character glyph. When opaque is true, the background fills the entire cell; when false, only foreground pixels are drawn (transparent background).
Parameter Description
--------- -----------
d Display context
@@ -662,10 +618,7 @@ background).
opaque true = fill background, false = transparent
drawTextN
void drawTextN(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, const char *text, int32_t count, uint32_t fg, uint32_t bg, bool opaque);
-
Optimized batch text rendering for a known character count. Computes clip
-bounds once, fills background in a single rectFill, then overlays glyph
-foreground pixels. Significantly faster than per-character drawChar for long
-runs (terminal rows, list items).
+
Optimized batch text rendering for a known character count. Computes clip bounds once, fills background in a single rectFill, then overlays glyph foreground pixels. Significantly faster than per-character drawChar for long runs (terminal rows, list items).
Parameter Description
--------- -----------
d Display context
@@ -678,8 +631,7 @@ runs (terminal rows, list items).
opaque true = fill background, false = transparent
textWidth
int32_t textWidth(const BitmapFontT *font, const char *text);
-
Return the pixel width of a null-terminated string (strlen(text) *
-charWidth).
+
Return the pixel width of a null-terminated string (strlen(text) * charWidth).
Parameter Description
--------- -----------
font Bitmap font
@@ -687,17 +639,14 @@ charWidth).
Returns: Width in pixels.
accelParse
char accelParse(const char *text);
-Scan text for an & prefix and return the following character as a lowercase
-accelerator key. "&File" returns 'f', "E&xit" returns 'x'.
+Scan text for an & prefix and return the following character as a lowercase accelerator key. "&File" returns 'f', "E&xit" returns 'x'.
Parameter Description
--------- -----------
text Text with optional & accelerator marker
Returns: Lowercase accelerator character, or 0 if none.
drawTextAccel
void drawTextAccel(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, const char *text, uint32_t fg, uint32_t bg, bool opaque);
-Draw text with & accelerator markers. The character after & is drawn
-underlined to indicate the keyboard shortcut. && produces a literal &. Used
-for menu items and button labels.
+Draw text with & accelerator markers. The character after & is drawn underlined to indicate the keyboard shortcut. && produces a literal &. Used for menu items and button labels.
Parameter Description
--------- -----------
d Display context
@@ -717,8 +666,7 @@ for menu items and button labels.
Returns: Width in pixels.
drawMaskedBitmap
void drawMaskedBitmap(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *andMask, const uint16_t *xorData, uint32_t fgColor, uint32_t bgColor);
-Draw a 1-bit AND/XOR masked bitmap. Used for software-rendered mouse
-cursors.
+Draw a 1-bit AND/XOR masked bitmap. Used for software-rendered mouse cursors.
Parameter Description
--------- -----------
d Display context
@@ -730,9 +678,7 @@ cursors.
fgColor, bgColor Cursor foreground and background packed colors
drawTermRow
void drawTermRow(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, int32_t cols, const uint8_t *lineData, const uint32_t *palette, bool blinkVisible, int32_t cursorCol);
-Render an entire row of terminal character cells (ch/attr byte pairs) in a
-single pass. Colors looked up from a 16-color palette. Attribute bit 7
-controls blink.
+Render an entire row of terminal character cells (ch/attr byte pairs) in a single pass. Colors looked up from a 16-color palette. Attribute bit 7 controls blink.
Parameter Description
--------- -----------
d Display context
@@ -746,8 +692,7 @@ controls blink.
cursorCol Column for inverted text cursor (-1 = none)
drawFocusRect
void drawFocusRect(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
-Draw a 1px dotted rectangle (alternating pixels). Used for keyboard focus
-indicators, matching the Windows 3.x focus rectangle convention.
+Draw a 1px dotted rectangle (alternating pixels). Used for keyboard focus indicators, matching the Windows 3.x focus rectangle convention.
Parameter Description
--------- -----------
d Display context
@@ -778,10 +723,7 @@ indicators, matching the Windows 3.x focus rectangle convention.
dvxComp.h -- Layer 3: Dirty Rectangle Compositor
dvxComp.h -- Layer 3: Dirty Rectangle Compositor
-
Tracks changed screen regions and ensures only dirty regions are redrawn and
-flushed to video memory. The compositing pipeline: mark dirty, merge
-overlapping rects, redraw desktop + windows (back-to-front, painter's
-algorithm), flush to LFB.
+
Tracks changed screen regions and ensures only dirty regions are redrawn and flushed to video memory. The compositing pipeline: mark dirty, merge overlapping rects, redraw desktop + windows (back-to-front, painter's algorithm), flush to LFB.
dirtyListInit
void dirtyListInit(DirtyListT *dl);
Zero the dirty rect count. Called at the start of each frame.
@@ -790,18 +732,14 @@ algorithm), flush to LFB.
dl Dirty list to initialize
dirtyListAdd
void dirtyListAdd(DirtyListT *dl, int32_t x, int32_t y, int32_t w, int32_t h);
-
Enqueue a dirty rectangle. Grows dynamically; triggers merge at a soft
-capacity limit.
+
Enqueue a dirty rectangle. Grows dynamically; triggers merge at a soft capacity limit.
Parameter Description
--------- -----------
dl Dirty list
x, y, w, h Dirty rectangle in screen coordinates
dirtyListMerge
void dirtyListMerge(DirtyListT *dl);
-
Consolidate the dirty list by merging overlapping and adjacent rects. Uses
-iterative pairwise merge: if combining two rects does not increase total
-area beyond a threshold, they are merged. Reduces compositor passes and LFB
-flush operations.
+
Consolidate the dirty list by merging overlapping and adjacent rects. Uses iterative pairwise merge: if combining two rects does not increase total area beyond a threshold, they are merged. Reduces compositor passes and LFB flush operations.
Parameter Description
--------- -----------
dl Dirty list to merge
@@ -813,9 +751,7 @@ flush operations.
dl Dirty list to clear
flushRect
void flushRect(DisplayT *d, const RectT *r);
-
Copy a rectangle from the system RAM backbuffer to the LFB (video memory).
-This is the only place the real framebuffer is written. Uses
-platform-specific fast copy (rep movsd on DOS) for each scanline.
+
Copy a rectangle from the system RAM backbuffer to the LFB (video memory). This is the only place the real framebuffer is written. Uses platform-specific fast copy (rep movsd on DOS) for each scanline.
Parameter Description
--------- -----------
d Display context
@@ -839,10 +775,7 @@ platform-specific fast copy (rep movsd on DOS) for each scanline.
dvxWm.h -- Layer 4: Window Manager
dvxWm.h -- Layer 4: Window Manager
-
Manages the window lifecycle, Z-order stack, chrome drawing, hit testing,
-and interactive operations (drag, resize, scroll). The WM owns window
-geometry and chrome; content is owned by the application via callbacks or
-the widget system.
+
Manages the window lifecycle, Z-order stack, chrome drawing, hit testing, and interactive operations (drag, resize, scroll). The WM owns window geometry and chrome; content is owned by the application via callbacks or the widget system.
Initialization
wmInit
void wmInit(WindowStackT *stack);
@@ -853,9 +786,7 @@ the widget system.
Window Lifecycle
wmCreateWindow
WindowT *wmCreateWindow(WindowStackT *stack, DisplayT *d, const char *title, int32_t x, int32_t y, int32_t w, int32_t h, bool resizable);
-
Allocate a new window, initialize its geometry and content buffer, and push
-it to the top of the Z-order stack. Returns with all callbacks NULL; the
-caller should set onPaint/onKey/etc. before the next event loop iteration.
+
Allocate a new window, initialize its geometry and content buffer, and push it to the top of the Z-order stack. Returns with all callbacks NULL; the caller should set onPaint/onKey/etc. before the next event loop iteration.
Parameter Description
--------- -----------
stack Window stack
@@ -867,9 +798,7 @@ caller should set onPaint/onKey/etc. before the next event loop iteration.
Returns: Pointer to new WindowT, or NULL on failure.
wmDestroyWindow
void wmDestroyWindow(WindowStackT *stack, WindowT *win);
-Free the window's content buffer and all attached resources (menu bar,
-scrollbars, widget tree), remove it from the stack, and dirty the vacated
-region.
+Free the window's content buffer and all attached resources (menu bar, scrollbars, widget tree), remove it from the stack, and dirty the vacated region.
Parameter Description
--------- -----------
stack Window stack
@@ -877,8 +806,7 @@ region.
Z-Order and Focus
wmRaiseWindow
void wmRaiseWindow(WindowStackT *stack, DirtyListT *dl, int32_t idx);
-Move window at stack index idx to the top of the Z-order. Dirties both old
-and new top positions so overlapping windows get repainted.
+Move window at stack index idx to the top of the Z-order. Dirties both old and new top positions so overlapping windows get repainted.
Parameter Description
--------- -----------
stack Window stack
@@ -886,8 +814,7 @@ and new top positions so overlapping windows get repainted.
idx Stack index of window to raise
wmSetFocus
void wmSetFocus(WindowStackT *stack, DirtyListT *dl, int32_t idx);
-Transfer keyboard focus to the window at stack index idx. Unfocuses the
-previously focused window and dirties both title bars.
+Transfer keyboard focus to the window at stack index idx. Unfocuses the previously focused window and dirties both title bars.
Parameter Description
--------- -----------
stack Window stack
@@ -896,17 +823,13 @@ previously focused window and dirties both title bars.
Geometry
wmUpdateContentRect
void wmUpdateContentRect(WindowT *win);
-Recompute contentX/Y/W/H from the window's outer frame dimensions,
-accounting for chrome borders, title bar, menu bar, and scrollbars. Must be
-called after any change to frame size or chrome configuration.
+Recompute contentX/Y/W/H from the window's outer frame dimensions, accounting for chrome borders, title bar, menu bar, and scrollbars. Must be called after any change to frame size or chrome configuration.
Parameter Description
--------- -----------
win Window to update
wmReallocContentBuf
int32_t wmReallocContentBuf(WindowT *win, const DisplayT *d);
-Reallocate the per-window content backbuffer to match current contentW/H.
-Old buffer contents are lost; caller should trigger a full repaint via
-onPaint afterward.
+Reallocate the per-window content backbuffer to match current contentW/H. Old buffer contents are lost; caller should trigger a full repaint via onPaint afterward.
Parameter Description
--------- -----------
win Window to reallocate
@@ -922,8 +845,7 @@ onPaint afterward.
Menu Bar
wmAddMenuBar
MenuBarT *wmAddMenuBar(WindowT *win);
-Allocate and attach a menu bar to a window. Adjusts content area to make
-room (CHROME_MENU_HEIGHT pixels). One menu bar per window.
+Allocate and attach a menu bar to a window. Adjusts content area to make room (CHROME_MENU_HEIGHT pixels). One menu bar per window.
Parameter Description
--------- -----------
win Window to add menu bar to
@@ -936,8 +858,7 @@ room (CHROME_MENU_HEIGHT pixels). One menu bar per window.
win Window to remove menu bar from
wmAddMenu
MenuT *wmAddMenu(MenuBarT *bar, const char *label);
-Append a dropdown menu to the menu bar. The label supports & accelerator
-markers (e.g. "&File").
+Append a dropdown menu to the menu bar. The label supports & accelerator markers (e.g. "&File").
Parameter Description
--------- -----------
bar Menu bar
@@ -945,8 +866,7 @@ markers (e.g. "&File").
Returns: Pointer to the new MenuT to populate with items.
wmAddMenuItem
void wmAddMenuItem(MenuT *menu, const char *label, int32_t id);
-Append a clickable item to a menu. The id is passed to the window's onMenu
-callback when selected.
+Append a clickable item to a menu. The id is passed to the window's onMenu callback when selected.
Parameter Description
--------- -----------
menu Menu to append to
@@ -954,8 +874,7 @@ callback when selected.
id Application-defined command ID
wmAddMenuCheckItem
void wmAddMenuCheckItem(MenuT *menu, const char *label, int32_t id, bool checked);
-Add a checkbox-style menu item. Check state toggles on click; rendered with
-a checkmark glyph.
+Add a checkbox-style menu item. Check state toggles on click; rendered with a checkmark glyph.
Parameter Description
--------- -----------
menu Menu to append to
@@ -964,8 +883,7 @@ a checkmark glyph.
checked Initial checked state
wmAddMenuRadioItem
void wmAddMenuRadioItem(MenuT *menu, const char *label, int32_t id, bool checked);
-Add a radio-style menu item. Radio groups are defined implicitly by
-consecutive radio items; selecting one unchecks the others in the group.
+Add a radio-style menu item. Radio groups are defined implicitly by consecutive radio items; selecting one unchecks the others in the group.
Parameter Description
--------- -----------
menu Menu to append to
@@ -980,8 +898,7 @@ consecutive radio items; selecting one unchecks the others in the group.
menu Menu to append separator to
wmMenuItemIsChecked
bool wmMenuItemIsChecked(MenuBarT *bar, int32_t id);
-Query the checked state of a menu item by command ID. Searches all menus in
-the bar.
+Query the checked state of a menu item by command ID. Searches all menus in the bar.
Parameter Description
--------- -----------
bar Menu bar
@@ -989,8 +906,7 @@ the bar.
Returns: true if checked.
wmMenuItemSetChecked
void wmMenuItemSetChecked(MenuBarT *bar, int32_t id, bool checked);
-Set the checked state of a menu item by command ID. For radio items, setting
-checked=true also unchecks other radio items in the same group.
+Set the checked state of a menu item by command ID. For radio items, setting checked=true also unchecks other radio items in the same group.
Parameter Description
--------- -----------
bar Menu bar
@@ -1006,8 +922,7 @@ checked=true also unchecks other radio items in the same group.
enabled true = enabled, false = grayed out
wmAddSubMenu
MenuT *wmAddSubMenu(MenuT *parentMenu, const char *label);
-Create a cascading submenu attached to a parent menu. The child MenuT is
-heap-allocated and freed when the parent window is destroyed.
+Create a cascading submenu attached to a parent menu. The child MenuT is heap-allocated and freed when the parent window is destroyed.
Parameter Description
--------- -----------
parentMenu Parent menu to attach submenu to
@@ -1015,22 +930,18 @@ heap-allocated and freed when the parent window is destroyed.
Returns: Pointer to the child MenuT, or NULL on allocation failure.
wmCreateMenu
MenuT *wmCreateMenu(void);
-Allocate a heap-resident MenuT for use as a context menu (right-click).
-Unlike menu bar menus, context menus are standalone allocations. Free with
-wmFreeMenu().
+Allocate a heap-resident MenuT for use as a context menu (right-click). Unlike menu bar menus, context menus are standalone allocations. Free with wmFreeMenu().
Returns: Pointer to the new MenuT.
wmFreeMenu
void wmFreeMenu(MenuT *menu);
-Free a standalone menu allocated with wmCreateMenu(). Also frees any
-heap-allocated submenu children recursively.
+Free a standalone menu allocated with wmCreateMenu(). Also frees any heap-allocated submenu children recursively.
Parameter Description
--------- -----------
menu Menu to free
Scrollbars
wmAddVScrollbar
ScrollbarT *wmAddVScrollbar(WindowT *win, int32_t min, int32_t max, int32_t pageSize);
-Attach a vertical scrollbar to the right edge of the window's content area.
-Shrinks contentW by SCROLLBAR_WIDTH pixels.
+Attach a vertical scrollbar to the right edge of the window's content area. Shrinks contentW by SCROLLBAR_WIDTH pixels.
Parameter Description
--------- -----------
win Window
@@ -1039,8 +950,7 @@ Shrinks contentW by SCROLLBAR_WIDTH pixels.
Returns: Pointer to the new ScrollbarT.
wmAddHScrollbar
ScrollbarT *wmAddHScrollbar(WindowT *win, int32_t min, int32_t max, int32_t pageSize);
-Attach a horizontal scrollbar to the bottom edge. Shrinks contentH by
-SCROLLBAR_WIDTH pixels.
+Attach a horizontal scrollbar to the bottom edge. Shrinks contentH by SCROLLBAR_WIDTH pixels.
Parameter Description
--------- -----------
win Window
@@ -1050,9 +960,7 @@ SCROLLBAR_WIDTH pixels.
Drawing
wmDrawChrome
void wmDrawChrome(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors, WindowT *win, const RectT *clipTo);
-Draw the window frame: outer bevel, title bar with text,
-close/minimize/maximize gadgets, and menu bar if present. Drawing is clipped
-to the intersection with clipTo.
+Draw the window frame: outer bevel, title bar with text, close/minimize/maximize gadgets, and menu bar if present. Drawing is clipped to the intersection with clipTo.
Parameter Description
--------- -----------
d Display context
@@ -1063,8 +971,7 @@ to the intersection with clipTo.
clipTo Dirty rectangle to clip drawing to
wmDrawContent
void wmDrawContent(DisplayT *d, const BlitOpsT *ops, WindowT *win, const RectT *clipTo);
-Blit the window's content backbuffer into the display backbuffer, clipped to
-the dirty rect. Pure copy operation (no drawing).
+Blit the window's content backbuffer into the display backbuffer, clipped to the dirty rect. Pure copy operation (no drawing).
Parameter Description
--------- -----------
d Display context
@@ -1073,8 +980,7 @@ the dirty rect. Pure copy operation (no drawing).
clipTo Dirty rectangle
wmDrawScrollbars
void wmDrawScrollbars(DisplayT *d, const BlitOpsT *ops, const ColorSchemeT *colors, WindowT *win, const RectT *clipTo);
-Draw scrollbars (track, arrows, proportional thumb) for a window. Drawn
-after content so scrollbars overlay the content area edge.
+Draw scrollbars (track, arrows, proportional thumb) for a window. Drawn after content so scrollbars overlay the content area edge.
Parameter Description
--------- -----------
d Display context
@@ -1084,8 +990,7 @@ after content so scrollbars overlay the content area edge.
clipTo Dirty rectangle
wmDrawMinimizedIcons
void wmDrawMinimizedIcons(DisplayT *d, const BlitOpsT *ops, const ColorSchemeT *colors, const WindowStackT *stack, const RectT *clipTo);
-Draw icons for all minimized windows along the bottom of the screen. Each
-icon shows a scaled preview of the window's content with a beveled border.
+Draw icons for all minimized windows along the bottom of the screen. Each icon shows a scaled preview of the window's content with a beveled border.
Parameter Description
--------- -----------
d Display context
@@ -1096,9 +1001,7 @@ icon shows a scaled preview of the window's content with a beveled border.
Hit Testing
wmHitTest
int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hitPart);
-Determine which window and chrome region is under the given screen
-coordinates. Iterates front-to-back (highest Z first) so the topmost window
-wins.
+Determine which window and chrome region is under the given screen coordinates. Iterates front-to-back (highest Z first) so the topmost window wins.
Parameter Description
--------- -----------
stack Window stack
@@ -1125,8 +1028,7 @@ wins.
Drag and Resize
wmDragBegin
void wmDragBegin(WindowStackT *stack, int32_t idx, int32_t mouseX, int32_t mouseY);
-Begin a window drag operation. Records the mouse offset from the window
-origin.
+Begin a window drag operation. Records the mouse offset from the window origin.
Parameter Description
--------- -----------
stack Window stack
@@ -1134,8 +1036,7 @@ origin.
mouseX/Y Current mouse position
wmDragMove
void wmDragMove(WindowStackT *stack, DirtyListT *dl, int32_t mouseX, int32_t mouseY, int32_t screenW, int32_t screenH);
-Update window position during an active drag. Dirties both old and new
-positions.
+Update window position during an active drag. Dirties both old and new positions.
Parameter Description
--------- -----------
stack Window stack
@@ -1159,10 +1060,7 @@ positions.
mouseX/Y Current mouse position
wmResizeMove
void wmResizeMove(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, int32_t *mouseX, int32_t *mouseY);
-Update window dimensions during an active resize. Enforces MIN_WINDOW_W/H
-and maxW/maxH constraints. Reallocates content buffer and calls onResize if
-size changed. mouseX/mouseY are in/out: clamped on return for cursor
-warping.
+Update window dimensions during an active resize. Enforces MIN_WINDOW_W/H and maxW/maxH constraints. Reallocates content buffer and calls onResize if size changed. mouseX/mouseY are in/out: clamped on return for cursor warping.
Parameter Description
--------- -----------
stack Window stack
@@ -1178,9 +1076,7 @@ warping.
Scrollbar Interaction
wmScrollbarClick
void wmScrollbarClick(WindowStackT *stack, DirtyListT *dl, int32_t idx, int32_t orient, int32_t mx, int32_t my);
-Handle an initial click on a scrollbar. Determines what was hit (arrows,
-trough, or thumb) and either adjusts the value immediately or begins a thumb
-drag.
+Handle an initial click on a scrollbar. Determines what was hit (arrows, trough, or thumb) and either adjusts the value immediately or begins a thumb drag.
Parameter Description
--------- -----------
stack Window stack
@@ -1190,8 +1086,7 @@ drag.
mx, my Click screen coordinates
wmScrollbarDrag
void wmScrollbarDrag(WindowStackT *stack, DirtyListT *dl, int32_t mx, int32_t my);
-Update the scroll value during an active thumb drag. Maps mouse position
-along the track to a proportional scroll value.
+Update the scroll value during an active thumb drag. Maps mouse position along the track to a proportional scroll value.
Parameter Description
--------- -----------
stack Window stack
@@ -1206,8 +1101,7 @@ along the track to a proportional scroll value.
Minimize / Maximize / Restore
wmMaximize
void wmMaximize(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, WindowT *win);
-Maximize a window. Saves current geometry, then expands to screen or
-maxW/maxH bounds.
+Maximize a window. Saves current geometry, then expands to screen or maxW/maxH bounds.
Parameter Description
--------- -----------
stack Window stack
@@ -1216,8 +1110,7 @@ maxW/maxH bounds.
win Window to maximize
wmMinimize
void wmMinimize(WindowStackT *stack, DirtyListT *dl, WindowT *win);
-Minimize a window. Hides the window and shows an icon at the bottom of the
-screen.
+Minimize a window. Hides the window and shows an icon at the bottom of the screen.
Parameter Description
--------- -----------
stack Window stack
@@ -1244,8 +1137,7 @@ screen.
Minimized Icon Layout
wmMinimizedIconPos
void wmMinimizedIconPos(const DisplayT *d, int32_t index, int32_t *x, int32_t *y);
-Compute the screen position of a minimized icon by ordinal index. Icons wrap
-into rows from bottom to top when the screen fills up.
+Compute the screen position of a minimized icon by ordinal index. Icons wrap into rows from bottom to top when the screen fills up.
Parameter Description
--------- -----------
d Display context
@@ -1253,8 +1145,7 @@ into rows from bottom to top when the screen fills up.
x, y Output: screen position
wmMinimizedIconRect
void wmMinimizedIconRect(const WindowStackT *stack, const DisplayT *d, int32_t *y, int32_t *h);
-Compute the screen rect covering all minimized icon rows. Used to dirty the
-icon area when windows are minimized or restored.
+Compute the screen rect covering all minimized icon rows. Used to dirty the icon area when windows are minimized or restored.
Parameter Description
--------- -----------
stack Window stack
@@ -1271,8 +1162,7 @@ icon area when windows are minimized or restored.
title New title text
wmSetIcon
int32_t wmSetIcon(WindowT *win, const char *path, const DisplayT *d);
-Load an icon image for a window from a file. Converts to display pixel
-format.
+Load an icon image for a window from a file. Converts to display pixel format.
Parameter Description
--------- -----------
win Window
@@ -1283,22 +1173,13 @@ format.
dvxApp.h -- Layer 5: Application API
dvxApp.h -- Layer 5: Application API
-
The topmost layer and the public-facing API. Aggregates all lower layers
-into a single AppContextT. Applications interact exclusively through dvx*()
-functions and window callbacks. The event loop follows a cooperative model:
-poll, dispatch, composite, yield.
+
The topmost layer and the public-facing API. Aggregates all lower layers into a single AppContextT. Applications interact exclusively through dvx*() functions and window callbacks. The event loop follows a cooperative model: poll, dispatch, composite, yield.
AppContextT
-
Single monolithic context that owns all GUI state. Contains the display,
-window stack, dirty list, blit ops, font, color scheme, popup state, cursor
-state, mouse/keyboard state, tooltip state, wallpaper buffer, video mode
-list, and various configuration fields. Allocated on the caller's stack or
-statically.
+
Single monolithic context that owns all GUI state. Contains the display, window stack, dirty list, blit ops, font, color scheme, popup state, cursor state, mouse/keyboard state, tooltip state, wallpaper buffer, video mode list, and various configuration fields. Allocated on the caller's stack or statically.
Initialization and Shutdown
dvxInit
int32_t dvxInit(AppContextT *ctx, int32_t requestedW, int32_t requestedH, int32_t preferredBpp);
-
Initialize the entire GUI stack: video mode, input devices, font, color
-scheme, cursor shapes, and internal state. Single entry point for starting a
-DVX application.
+
Initialize the entire GUI stack: video mode, input devices, font, color scheme, cursor shapes, and internal state. Single entry point for starting a DVX application.
Parameter Description
--------- -----------
ctx Application context to initialize
@@ -1307,16 +1188,13 @@ DVX application.
Returns: 0 on success, negative on failure.
dvxShutdown
void dvxShutdown(AppContextT *ctx);
-Tear down the GUI stack in reverse order: destroy all windows, restore text
-mode, release input devices. Safe to call after a failed dvxInit().
+Tear down the GUI stack in reverse order: destroy all windows, restore text mode, release input devices. Safe to call after a failed dvxInit().
Parameter Description
--------- -----------
ctx Application context
dvxChangeVideoMode
int32_t dvxChangeVideoMode(AppContextT *ctx, int32_t requestedW, int32_t requestedH, int32_t preferredBpp);
-Switch to a new video mode live. Reallocates the backbuffer, all window
-content buffers, repacks colors, rescales wallpaper, and repositions
-off-screen windows.
+Switch to a new video mode live. Reallocates the backbuffer, all window content buffers, repacks colors, rescales wallpaper, and repositions off-screen windows.
Parameter Description
--------- -----------
ctx Application context
@@ -1326,16 +1204,13 @@ off-screen windows.
Event Loop
dvxRun
void dvxRun(AppContextT *ctx);
-Enter the main event loop. Polls input, dispatches events, composites dirty
-regions, and yields on each iteration. Returns when ctx->running becomes
-false.
+Enter the main event loop. Polls input, dispatches events, composites dirty regions, and yields on each iteration. Returns when ctx->running becomes false.
Parameter Description
--------- -----------
ctx Application context
dvxUpdate
bool dvxUpdate(AppContextT *ctx);
-Process exactly one frame of the event loop. For applications that integrate
-the GUI into their own main loop (e.g. polling serial ports between frames).
+Process exactly one frame of the event loop. For applications that integrate the GUI into their own main loop (e.g. polling serial ports between frames).
Parameter Description
--------- -----------
ctx Application context
@@ -1349,8 +1224,7 @@ the GUI into their own main loop (e.g. polling serial ports between frames).
Window Management
dvxCreateWindow
WindowT *dvxCreateWindow(AppContextT *ctx, const char *title, int32_t x, int32_t y, int32_t w, int32_t h, bool resizable);
-Create a window at an explicit screen position. The window is raised to the
-top, focused, and its entire region is dirtied.
+Create a window at an explicit screen position. The window is raised to the top, focused, and its entire region is dirtied.
Parameter Description
--------- -----------
ctx Application context
@@ -1385,8 +1259,7 @@ top, focused, and its entire region is dirtied.
win Window to raise
dvxFitWindow
void dvxFitWindow(AppContextT *ctx, WindowT *win);
-Resize a window to exactly fit its widget tree's computed minimum size (plus
-chrome). Used for dialog boxes and fixed-layout windows.
+Resize a window to exactly fit its widget tree's computed minimum size (plus chrome). Used for dialog boxes and fixed-layout windows.
Parameter Description
--------- -----------
ctx Application context
@@ -1444,9 +1317,7 @@ chrome). Used for dialog boxes and fixed-layout windows.
Invalidation
dvxInvalidateRect
void dvxInvalidateRect(AppContextT *ctx, WindowT *win, int32_t x, int32_t y, int32_t w, int32_t h);
-Mark a sub-region of a window's content area as needing repaint. Coordinates
-are relative to the content area, not the screen. Triggers onPaint during
-the next composite pass.
+Mark a sub-region of a window's content area as needing repaint. Coordinates are relative to the content area, not the screen. Triggers onPaint during the next composite pass.
Parameter Description
--------- -----------
ctx Application context
@@ -1479,8 +1350,7 @@ the next composite pass.
Returns: 0 on success, -1 on failure.
dvxSetBusy
void dvxSetBusy(AppContextT *ctx, bool busy);
-Set or clear busy state. While busy, the hourglass cursor is shown and input
-is blocked.
+Set or clear busy state. While busy, the hourglass cursor is shown and input is blocked.
Parameter Description
--------- -----------
ctx Application context
@@ -1525,8 +1395,7 @@ is blocked.
Color Scheme
dvxSetColor
void dvxSetColor(AppContextT *ctx, ColorIdE id, uint8_t r, uint8_t g, uint8_t b);
-Set a single color by ID. Repacks to native pixel format and invalidates the
-entire screen.
+Set a single color by ID. Repacks to native pixel format and invalidates the entire screen.
Parameter Description
--------- -----------
ctx Application context
@@ -1585,8 +1454,7 @@ entire screen.
Wallpaper
dvxSetWallpaper
bool dvxSetWallpaper(AppContextT *ctx, const char *path);
-Load and apply a wallpaper image using the current wallpaperMode
-(stretch/tile/center). Pass NULL to clear the wallpaper.
+Load and apply a wallpaper image using the current wallpaperMode (stretch/tile/center). Pass NULL to clear the wallpaper.
Parameter Description
--------- -----------
ctx Application context
@@ -1594,8 +1462,7 @@ entire screen.
Returns: true on success.
dvxSetWallpaperMode
void dvxSetWallpaperMode(AppContextT *ctx, WallpaperModeE mode);
-Change the wallpaper display mode and re-render. No effect if no wallpaper
-is loaded.
+Change the wallpaper display mode and re-render. No effect if no wallpaper is loaded.
Parameter Description
--------- -----------
ctx Application context
@@ -1623,8 +1490,7 @@ is loaded.
table Table to free
dvxAddAccel
void dvxAddAccel(AccelTableT *table, int32_t key, int32_t modifiers, int32_t cmdId);
-Register a keyboard shortcut. On match, fires the window's onMenu callback
-with cmdId.
+Register a keyboard shortcut. On match, fires the window's onMenu callback with cmdId.
Parameter Description
--------- -----------
table Accelerator table
@@ -1634,8 +1500,7 @@ with cmdId.
Window Arrangement
dvxCascadeWindows
void dvxCascadeWindows(AppContextT *ctx);
-Cascade all visible, non-minimized windows. Each is offset diagonally by the
-title bar height.
+Cascade all visible, non-minimized windows. Each is offset diagonally by the title bar height.
Parameter Description
--------- -----------
ctx Application context
@@ -1660,8 +1525,7 @@ title bar height.
Image I/O
dvxLoadImage
uint8_t *dvxLoadImage(const AppContextT *ctx, const char *path, int32_t *outW, int32_t *outH, int32_t *outPitch);
-Load an image file (BMP, PNG, JPEG, GIF) and convert to the display's native
-pixel format. Caller must free with dvxFreeImage().
+Load an image file (BMP, PNG, JPEG, GIF) and convert to the display's native pixel format. Caller must free with dvxFreeImage().
Parameter Description
--------- -----------
ctx Application context
@@ -1671,8 +1535,7 @@ pixel format. Caller must free with dvxFreeImage().
Returns: Pixel buffer, or NULL on failure.
dvxLoadImageFromMemory
uint8_t *dvxLoadImageFromMemory(const AppContextT *ctx, const uint8_t *data, int32_t dataLen, int32_t *outW, int32_t *outH, int32_t *outPitch);
-Load an image from a memory buffer. Same output format as dvxLoadImage().
-Caller must free with dvxFreeImage().
+Load an image from a memory buffer. Same output format as dvxLoadImage(). Caller must free with dvxFreeImage().
Parameter Description
--------- -----------
ctx Application context
@@ -1709,8 +1572,7 @@ Caller must free with dvxFreeImage().
Screenshots
dvxScreenshot
int32_t dvxScreenshot(AppContextT *ctx, const char *path);
-Save the entire screen (backbuffer contents) to a PNG file. Converts from
-native pixel format to RGB.
+Save the entire screen (backbuffer contents) to a PNG file. Converts from native pixel format to RGB.
Parameter Description
--------- -----------
ctx Application context
@@ -1728,16 +1590,14 @@ native pixel format to RGB.
Clipboard
dvxClipboardCopy
void dvxClipboardCopy(const char *text, int32_t len);
-Copy text to the process-wide clipboard buffer. Simple static buffer (not
-inter-process).
+Copy text to the process-wide clipboard buffer. Simple static buffer (not inter-process).
Parameter Description
--------- -----------
text Text to copy
len Length in bytes
dvxClipboardGet
const char *dvxClipboardGet(int32_t *outLen);
-Retrieve the current clipboard contents. Returns a pointer to the internal
-buffer (valid until the next dvxClipboardCopy), or NULL if empty.
+Retrieve the current clipboard contents. Returns a pointer to the internal buffer (valid until the next dvxClipboardCopy), or NULL if empty.
Parameter Description
--------- -----------
outLen Output: length of clipboard text
@@ -1745,8 +1605,7 @@ buffer (valid until the next dvxClipboardCopy), or NULL if empty.
Resource Loading
dvxResLoadIcon
uint8_t *dvxResLoadIcon(AppContextT *ctx, const char *dxePath, const char *resName, int32_t *outW, int32_t *outH, int32_t *outPitch);
-Load an icon/image resource from a DXE file and decode to native pixel
-format. Caller must free with dvxFreeImage().
+Load an icon/image resource from a DXE file and decode to native pixel format. Caller must free with dvxFreeImage().
Parameter Description
--------- -----------
ctx Application context
@@ -1757,8 +1616,7 @@ format. Caller must free with dvxFreeImage().
Returns: Pixel buffer, or NULL if not found.
dvxResLoadText
bool dvxResLoadText(const char *dxePath, const char *resName, char *buf, int32_t bufSize);
-Load a text resource from a DXE file into a caller-provided buffer.
-Null-terminated and truncated to fit bufSize.
+Load a text resource from a DXE file into a caller-provided buffer. Null-terminated and truncated to fit bufSize.
Parameter Description
--------- -----------
dxePath Path to DXE file
@@ -1768,8 +1626,7 @@ Null-terminated and truncated to fit bufSize.
Returns: true on success.
dvxResLoadData
void *dvxResLoadData(const char *dxePath, const char *resName, uint32_t *outSize);
-Load a raw binary resource from a DXE file. Returns a malloc'd buffer that
-the caller must free.
+Load a raw binary resource from a DXE file. Returns a malloc'd buffer that the caller must free.
Parameter Description
--------- -----------
dxePath Path to DXE file
@@ -1779,8 +1636,7 @@ the caller must free.
Utilities
dvxTextHash
uint32_t dvxTextHash(const char *text);
-Compute a djb2-xor hash for cheap dirty detection. Compare at save time with
-the current hash to detect changes without a shadow copy. Not cryptographic.
+Compute a djb2-xor hash for cheap dirty detection. Compare at save time with the current hash to detect changes without a shadow copy. Not cryptographic.
Parameter Description
--------- -----------
text Null-terminated string to hash
@@ -1789,14 +1645,9 @@ the current hash to detect changes without a shadow copy. Not cryptographic.
dvxWidget.h -- Widget System
dvxWidget.h -- Widget System
-
Retained-mode widget toolkit layered on the DVX window manager. Widgets form
-a tree (parent-child) rooted at a per-window VBox container. Layout is
-automatic: measure minimum sizes bottom-up, then allocate space top-down
-with flexbox-like weighted distribution. Widget types are registered
-dynamically at runtime via DXE plugins.
+
Retained-mode widget toolkit layered on the DVX window manager. Widgets form a tree (parent-child) rooted at a per-window VBox container. Layout is automatic: measure minimum sizes bottom-up, then allocate space top-down with flexbox-like weighted distribution. Widget types are registered dynamically at runtime via DXE plugins.
WidgetT Structure
-
Core widget structure. Generic across all widget types; type-specific data
-lives in the void *data pointer managed by each widget's DXE.
+
Core widget structure. Generic across all widget types; type-specific data lives in the void *data pointer managed by each widget's DXE.
Field Description
----- -----------
int32_t type Widget type ID (assigned by wgtRegisterClass)
@@ -1858,10 +1709,7 @@ lives in the void *data pointer managed by each widget's DXE.
Window Integration
wgtInitWindow
WidgetT *wgtInitWindow(AppContextT *ctx, WindowT *win);
-Initialize the widget system for a window. Creates a root VBox container
-that fills the content area, and installs callback handlers (onPaint,
-onMouse, onKey, onResize) for widget-based event dispatch. The window's
-userData is set to the AppContextT pointer.
+Initialize the widget system for a window. Creates a root VBox container that fills the content area, and installs callback handlers (onPaint, onMouse, onKey, onResize) for widget-based event dispatch. The window's userData is set to the AppContextT pointer.
Parameter Description
--------- -----------
ctx Application context
@@ -1870,25 +1718,20 @@ userData is set to the AppContextT pointer.
Widget Operations
wgtGetContext
AppContextT *wgtGetContext(const WidgetT *w);
-Walk from any widget up the tree to the root, then retrieve the AppContextT
-stored in the window's userData. Lets any widget access the full application
-context.
+Walk from any widget up the tree to the root, then retrieve the AppContextT stored in the window's userData. Lets any widget access the full application context.
Parameter Description
--------- -----------
w Any widget in the tree
Returns: Pointer to the AppContextT.
wgtInvalidate
void wgtInvalidate(WidgetT *w);
-Mark a widget as needing both re-layout (measure + position) and repaint.
-Propagates upward to ancestors. Use after structural changes
-(adding/removing children, text changes that affect size).
+Mark a widget as needing both re-layout (measure + position) and repaint. Propagates upward to ancestors. Use after structural changes (adding/removing children, text changes that affect size).
Parameter Description
--------- -----------
w Widget to invalidate
wgtInvalidatePaint
void wgtInvalidatePaint(WidgetT *w);
-Mark a widget as needing repaint only, without re-layout. Use for
-visual-only changes (checkbox toggle, selection highlight, cursor blink).
+Mark a widget as needing repaint only, without re-layout. Use for visual-only changes (checkbox toggle, selection highlight, cursor blink).
Parameter Description
--------- -----------
w Widget to repaint
@@ -1908,8 +1751,7 @@ visual-only changes (checkbox toggle, selection highlight, cursor blink).
Returns: Text string (empty string if no handler).
wgtSetEnabled
void wgtSetEnabled(WidgetT *w, bool enabled);
-Enable or disable a widget. Disabled widgets are grayed out and do not
-receive input.
+Enable or disable a widget. Disabled widgets are grayed out and do not receive input.
Parameter Description
--------- -----------
w Widget
@@ -1961,17 +1803,14 @@ receive input.
w Widget to destroy
wgtSetTooltip
void wgtSetTooltip(WidgetT *w, const char *text);
-Set tooltip text for a widget. Pass NULL to remove. Caller owns the string
-and it must outlive the widget.
+Set tooltip text for a widget. Pass NULL to remove. Caller owns the string and it must outlive the widget.
Parameter Description
--------- -----------
w Widget
text Tooltip text, or NULL
widgetOnResize
void widgetOnResize(WindowT *win, int32_t newW, int32_t newH);
-Default window resize handler installed by wgtInitWindow(). Re-evaluates
-scrollbars and relayouts the widget tree. Call from custom onResize handlers
-to chain to the widget system.
+Default window resize handler installed by wgtInitWindow(). Re-evaluates scrollbars and relayouts the widget tree. Call from custom onResize handlers to chain to the widget system.
Parameter Description
--------- -----------
win Window being resized
@@ -1979,8 +1818,7 @@ to chain to the widget system.
Layout
wgtResolveSize
int32_t wgtResolveSize(int32_t taggedSize, int32_t parentSize, int32_t charWidth);
-Decode a tagged size value (WGT_SIZE_PIXELS/CHARS/PERCENT) into a concrete
-pixel count. Returns 0 for a raw 0 input (meaning "auto").
+Decode a tagged size value (WGT_SIZE_PIXELS/CHARS/PERCENT) into a concrete pixel count. Returns 0 for a raw 0 input (meaning "auto").
Parameter Description
--------- -----------
taggedSize Tagged size value
@@ -1989,10 +1827,7 @@ pixel count. Returns 0 for a raw 0 input (meaning "auto").
Returns: Size in pixels.
wgtLayout
void wgtLayout(WidgetT *root, int32_t availW, int32_t availH, const BitmapFontT *font);
-Execute the full two-pass layout algorithm. Pass 1 (bottom-up): compute
-minimum sizes. Pass 2 (top-down): allocate space with weighted distribution.
-Normally called automatically; exposed for cases where layout must be forced
-before the next paint.
+Execute the full two-pass layout algorithm. Pass 1 (bottom-up): compute minimum sizes. Pass 2 (top-down): allocate space with weighted distribution. Normally called automatically; exposed for cases where layout must be forced before the next paint.
Parameter Description
--------- -----------
root Root widget
@@ -2000,9 +1835,7 @@ before the next paint.
font Bitmap font (for character-based sizing)
wgtPaint
void wgtPaint(WidgetT *root, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
-Paint the entire widget tree by depth-first traversal. Each widget's clip
-rect is set to its bounds. Overlays (popups, tooltips) are painted in a
-second pass on top.
+Paint the entire widget tree by depth-first traversal. Each widget's clip rect is set to its bounds. Overlays (popups, tooltips) are painted in a second pass on top.
Parameter Description
--------- -----------
root Root widget
@@ -2021,18 +1854,14 @@ second pass on top.
Dynamic Widget Registration
wgtRegisterClass
int32_t wgtRegisterClass(const WidgetClassT *wclass);
-Register a new widget class at runtime. Appends to widgetClassTable. The
-WidgetClassT must remain valid for the lifetime of the process (typically
-static const in a DXE).
+Register a new widget class at runtime. Appends to widgetClassTable. The WidgetClassT must remain valid for the lifetime of the process (typically static const in a DXE).
Parameter Description
--------- -----------
wclass Widget class vtable to register
Returns: Assigned type ID.
wgtRegisterApi
void wgtRegisterApi(const char *name, const void *api);
-Register a widget API struct under a name. Each widget DXE registers its API
-during initialization. Callers retrieve it via wgtGetApi() and cast to the
-widget-specific type.
+Register a widget API struct under a name. Each widget DXE registers its API during initialization. Callers retrieve it via wgtGetApi() and cast to the widget-specific type.
Parameter Description
--------- -----------
name Widget type name (e.g. "button", "listbox")
@@ -2047,8 +1876,7 @@ widget-specific type.
Widget Interface Descriptors
wgtRegisterIface
void wgtRegisterIface(const char *name, const WgtIfaceT *iface);
-Register an interface descriptor for a widget type. Used by the BASIC form
-runtime and IDE for generic property/method dispatch.
+Register an interface descriptor for a widget type. Used by the BASIC form runtime and IDE for generic property/method dispatch.
Parameter Description
--------- -----------
name Widget type name
@@ -2062,8 +1890,7 @@ runtime and IDE for generic property/method dispatch.
Returns: Interface descriptor, or NULL.
wgtFindByBasName
const char *wgtFindByBasName(const char *basName);
-Find a widget type name by its VB-style name (e.g. "CommandButton" ->
-"button"). Case-insensitive search.
+Find a widget type name by its VB-style name (e.g. "CommandButton" -> "button"). Case-insensitive search.
Parameter Description
--------- -----------
basName VB-style widget name
@@ -2096,16 +1923,13 @@ runtime and IDE for generic property/method dispatch.
path DXE file path
wgtIfaceGetPathIndex
int32_t wgtIfaceGetPathIndex(const char *name);
-Get the 1-based index of this widget within its .wgt file. Used to construct
-suffixed resource names (e.g. "name-2", "icon16-2").
+Get the 1-based index of this widget within its .wgt file. Used to construct suffixed resource names (e.g. "name-2", "icon16-2").
Parameter Description
--------- -----------
name Widget type name
Returns: 1-based index within the DXE file.
Typed Dispatch Helpers
-The following inline functions provide type-safe dispatch through the
-WidgetClassT handler table. Each checks for a non-NULL handler before
-calling.
+The following inline functions provide type-safe dispatch through the WidgetClassT handler table. Each checks for a non-NULL handler before calling.
Function Method ID Description
-------- --------- -----------
wclsHas(w, methodId) -- Check if handler exists
diff --git a/docs/dvx_architecture.html b/docs/dvx_architecture.html
index 2035eab..c993f94 100644
--- a/docs/dvx_architecture.html
+++ b/docs/dvx_architecture.html
@@ -29,7 +29,8 @@ img { max-width: 100%; }
Contents
Index
DVX
@@ -131,49 +134,32 @@ img { max-width: 100%; }
DVX Architecture Overview
DVX Architecture Overview
DOS Visual eXecutive -- A Windowing GUI for DJGPP/DPMI
-DVX (DOS Visual eXecutive) is a complete windowing GUI compositor targeting
-DJGPP/DPMI on DOS. It provides overlapping windows with Motif-style chrome,
-a retained-mode widget toolkit, cooperative multitasking of DXE-loaded
-applications, and a dirty-rectangle compositor optimized for 486/Pentium
-hardware.
+DVX (DOS Visual eXecutive) is a complete windowing GUI compositor targeting DJGPP/DPMI on DOS. It provides overlapping windows with Motif-style chrome, a retained-mode widget toolkit, cooperative multitasking of DXE-loaded applications, and a dirty-rectangle compositor optimized for 486/Pentium hardware.
Key Design Constraints
-VESA VBE 2.0+ LFB only -- no bank switching. If the hardware cannot
- provide a linear framebuffer, initialization fails.
-486 baseline -- all hot paths are written to be fast on a 486, with
- Pentium-specific paths where the gain is significant.
-Single-tasking cooperative model -- applications yield the CPU via
- tsYield(); there is no preemptive scheduler.
-86Box is the trusted reference platform for testing. DOSBox-X is not used;
- any bugs observed are treated as DVX bugs.
+VESA VBE 2.0+ LFB only -- no bank switching. If the hardware cannot provide a linear framebuffer, initialization fails.
+486 baseline -- all hot paths are written to be fast on a 486, with Pentium-specific paths where the gain is significant.
+Single-tasking cooperative model -- applications yield the CPU via tsYield(); there is no preemptive scheduler.
+86Box is the trusted reference platform for testing. DOSBox-X is not used; any bugs observed are treated as DVX bugs.
-No external font or cursor files -- all bitmaps are compiled in as static
-const data.
-The runtime environment consists of a bootstrap loader (dvx.exe) that loads
-core DXE libraries, widget plugins, and the shell, which in turn loads and
-manages DXE application modules.
+No external font or cursor files -- all bitmaps are compiled in as static const data.
+The runtime environment consists of a bootstrap loader (dvx.exe) that loads core DXE libraries, widget plugins, and the shell, which in turn loads and manages DXE application modules.
Contents
-
-.link arch.overview System Overview
-.link arch.layers Five-Layer Architecture
-.link arch.pipeline Display Pipeline
-.link arch.windows Window System
-.link arch.widgets Widget System
-.link arch.dxe DXE Module System
-.link arch.events Event Model
-.link arch.fonts Font System
-.link arch.colors Color System
-.link arch.platform Platform Layer
-
-.link arch.build Build System
+Five-Layer Architecture
+Display Pipeline
+Window System
+Widget System
+DXE Module System
+Event Model
+Font System
+Color System
+Platform Layer
+Build System
Five-Layer Architecture
Five-Layer Architecture
-
DVX is organized into five layers, each implemented as a single .h/.c pair.
-Every header includes dvxTypes.h (the shared type definitions) to avoid
-circular dependencies. The layers are strictly stacked: each layer depends
-only on the layers below it.
+
DVX is organized into five layers, each implemented as a single .h/.c pair. Every header includes dvxTypes.h (the shared type definitions) to avoid circular dependencies. The layers are strictly stacked: each layer depends only on the layers below it.
Applications (DXE .app modules)
==================================================
| |
@@ -216,13 +202,8 @@ only on the layers below it.
Display Pipeline
Display Pipeline
-
The double-buffer strategy is the single most important performance decision
-in DVX. All drawing goes to a system RAM backbuffer (DisplayT.backBuf); only
-dirty rectangles are flushed to the linear framebuffer (DisplayT.lfb) in
-video memory.
-
This matters because writes to video memory over the PCI bus are 10-50x
-slower than writes to main RAM on 486/Pentium hardware for random-access
-patterns.
+
The double-buffer strategy is the single most important performance decision in DVX. All drawing goes to a system RAM backbuffer (DisplayT.backBuf); only dirty rectangles are flushed to the linear framebuffer (DisplayT.lfb) in video memory.
+
This matters because writes to video memory over the PCI bus are 10-50x slower than writes to main RAM on 486/Pentium hardware for random-access patterns.
Per-Frame Compositing Pipeline
1. Input poll (mouse, keyboard)
|
@@ -246,27 +227,16 @@ patterns.
|
7. Yield (platformYield)
Key Data Structures
-
DisplayT -- Central display context: width, height, pitch, pixel format, LFB
-pointer, backbuffer pointer, palette, clip rectangle. Passed by pointer
-through every layer -- no globals.
-
BlitOpsT -- Vtable of span fill/copy function pointers resolved at init time
-for the active pixel depth. On DOS these dispatch to hand-written rep stosl
-/ rep movsd asm inner loops.
-
DirtyListT -- Fixed-capacity dynamic array of RectT. Linear scanning for
-merge candidates is cache-friendly at typical sizes (under 128 rects). If
-the list fills up, the compositor merges aggressively or falls back to
-full-screen repaint.
+
DisplayT -- Central display context: width, height, pitch, pixel format, LFB pointer, backbuffer pointer, palette, clip rectangle. Passed by pointer through every layer -- no globals.
+
BlitOpsT -- Vtable of span fill/copy function pointers resolved at init time for the active pixel depth. On DOS these dispatch to hand-written rep stosl / rep movsd asm inner loops.
+
DirtyListT -- Fixed-capacity dynamic array of RectT. Linear scanning for merge candidates is cache-friendly at typical sizes (under 128 rects). If the list fills up, the compositor merges aggressively or falls back to full-screen repaint.
Why This Works on a 486
-A full 640x480x32bpp frame is 1.2 MB -- far too much to flush every frame
- over a slow PCI bus.
-A typical dirty region during normal interaction (typing, menu open) is a
- few KB.
-Merging overlapping dirty rects into larger rects reduces per-rect
- overhead and improves bus utilization.
+A full 640x480x32bpp frame is 1.2 MB -- far too much to flush every frame over a slow PCI bus.
+A typical dirty region during normal interaction (typing, menu open) is a few KB.
+Merging overlapping dirty rects into larger rects reduces per-rect overhead and improves bus utilization.
-
Per-window content buffers persist across frames, so windows don't repaint
-on expose -- only when their own content changes.
+
Per-window content buffers persist across frames, so windows don't repaint on expose -- only when their own content changes.
Window System
@@ -282,15 +252,13 @@ on expose -- only when their own content changes.
Widget tree (widgetRoot) Root of the retained-mode widget tree (NULL if using raw callbacks).
Callbacks onPaint, onKey, onKeyUp, onMouse, onResize, onClose, onMenu, onScroll, onFocus, onBlur, onCursorQuery.
Window Stack (Z-Order)
-
WindowStackT is an array of WindowT* ordered front-to-back: index count-1 is
-the topmost window. This allows:
+
WindowStackT is an array of WindowT* ordered front-to-back: index count-1 is the topmost window. This allows:
Back-to-front iteration for painting (painter's algorithm).
Front-to-back iteration for hit testing (first hit wins).
Reordering by pointer swap (no copying of large WindowT structs).
-
Only one drag/resize/scroll operation can be active system-wide at a time
-(single mouse), so that state lives on the stack, not on individual windows.
+
Only one drag/resize/scroll operation can be active system-wide at a time (single mouse), so that state lives on the stack, not on individual windows.
Chrome Layout
+-------------------------------------------+
| 4px outer border (raised bevel) |
@@ -319,56 +287,29 @@ the topmost window. This allows:
SCROLLBAR_WIDTH = 16px
CHROME_CLOSE_BTN_SIZE = 16px
Hit Test Regions
-
wmHitTest() iterates the stack front-to-back and returns a hit-part
-identifier: HIT_CONTENT, HIT_TITLE, HIT_CLOSE, HIT_RESIZE, HIT_MENU,
-HIT_VSCROLL, HIT_HSCROLL, HIT_MINIMIZE, HIT_MAXIMIZE. Resize edge detection
-returns a bitmask of RESIZE_LEFT, RESIZE_RIGHT, RESIZE_TOP, RESIZE_BOTTOM
-(corners combine two edges).
+
wmHitTest() iterates the stack front-to-back and returns a hit-part identifier: HIT_CONTENT, HIT_TITLE, HIT_CLOSE, HIT_RESIZE, HIT_MENU, HIT_VSCROLL, HIT_HSCROLL, HIT_MINIMIZE, HIT_MAXIMIZE. Resize edge detection returns a bitmask of RESIZE_LEFT, RESIZE_RIGHT, RESIZE_TOP, RESIZE_BOTTOM (corners combine two edges).
Menu System
-
Menus use fixed-size arrays with inline char buffers (no heap strings). Up
-to 8 menus per bar, items dynamically allocated. Supports cascading submenus
-via MenuItemT.subMenu pointer. Item types: normal, checkbox, radio.
-Separators are non-interactive items. The popup state (PopupStateT) tracks a
-stack of parent frames for cascading submenu nesting.
+
Menus use fixed-size arrays with inline char buffers (no heap strings). Up to 8 menus per bar, items dynamically allocated. Supports cascading submenus via MenuItemT.subMenu pointer. Item types: normal, checkbox, radio. Separators are non-interactive items. The popup state (PopupStateT) tracks a stack of parent frames for cascading submenu nesting.
Minimized Windows
-
Minimized windows display as 64x64 icons at the bottom of the screen with
-beveled borders, similar to a classic desktop icon bar. Icons show a
-scaled-down preview of the window's content buffer, refreshed one per frame
-in a round-robin fashion to amortize the scaling cost.
+
Minimized windows display as 64x64 icons at the bottom of the screen with beveled borders, similar to a classic desktop icon bar. Icons show a scaled-down preview of the window's content buffer, refreshed one per frame in a round-robin fashion to amortize the scaling cost.
Widget System
Widget System
-
The widget system (dvxWidget.h) is a retained-mode toolkit layered on top of
-the window manager. Widgets form a tree rooted at a per-window VBox
-container.
+
The widget system (dvxWidget.h) is a retained-mode toolkit layered on top of the window manager. Widgets form a tree rooted at a per-window VBox container.
WidgetT Base Structure
-
Every widget shares the same WidgetT struct. The type field is a
-runtime-assigned integer ID. The wclass pointer references the widget's
-WidgetClassT vtable. Widget-specific private data is stored in w->data
-(opaque void*).
-
Tree linkage: parent, firstChild, lastChild, nextSibling. No prevSibling --
-this halves pointer overhead and removal is still O(n) for typical tree
-depths of 5-10.
+
Every widget shares the same WidgetT struct. The type field is a runtime-assigned integer ID. The wclass pointer references the widget's WidgetClassT vtable. Widget-specific private data is stored in w->data (opaque void*).
+
Tree linkage: parent, firstChild, lastChild, nextSibling. No prevSibling -- this halves pointer overhead and removal is still O(n) for typical tree depths of 5-10.
Layout Engine
Two-pass flexbox-like algorithm:
-Bottom-up (calcMinSize) -- compute minimum sizes for every widget,
- starting from leaves.
+Bottom-up (calcMinSize) -- compute minimum sizes for every widget, starting from leaves.
-
Top-down (layout) -- allocate space within available bounds, distributing
-extra space according to weight values (0 = fixed, 100 = normal stretch).
-
Size hints use a tagged encoding: the top 2 bits of an int32_t select the
-unit (pixels, character widths, or percentage of parent), the low 30 bits
-hold the value. Macros: wgtPixels(v), wgtChars(v), wgtPercent(v).
+
Top-down (layout) -- allocate space within available bounds, distributing extra space according to weight values (0 = fixed, 100 = normal stretch).
+
Size hints use a tagged encoding: the top 2 bits of an int32_t select the unit (pixels, character widths, or percentage of parent), the low 30 bits hold the value. Macros: wgtPixels(v), wgtChars(v), wgtPercent(v).
Widget Class Dispatch (WidgetClassT)
-
Each widget type provides a WidgetClassT with a handlers[] array indexed by
-stable method IDs. Method IDs are never reordered or reused -- new methods
-append at the end. This provides ABI-stable dispatch so that widget DXEs
-compiled against an older DVX version continue to work.
-
Methods include: PAINT, PAINT_OVERLAY, CALC_MIN_SIZE, LAYOUT, ON_MOUSE,
-ON_KEY, ON_ACCEL_ACTIVATE, DESTROY, GET_TEXT, SET_TEXT, POLL, and more (21
-defined, room for 32).
+
Each widget type provides a WidgetClassT with a handlers[] array indexed by stable method IDs. Method IDs are never reordered or reused -- new methods append at the end. This provides ABI-stable dispatch so that widget DXEs compiled against an older DVX version continue to work.
+
Methods include: PAINT, PAINT_OVERLAY, CALC_MIN_SIZE, LAYOUT, ON_MOUSE, ON_KEY, ON_ACCEL_ACTIVATE, DESTROY, GET_TEXT, SET_TEXT, POLL, and more (21 defined, room for 32).
Class Flags
Flag Meaning
---- -------
@@ -414,26 +355,14 @@ defined, room for 32).
TreeView Hierarchical tree display
WrapBox Flow layout (wrapping horizontal container)
Widget API Registry
-
Each widget DXE registers a small API struct under a name during
-wgtRegister(). Callers retrieve it via wgtGetApi("button") and cast to the
-widget-specific API type. Per-widget headers provide typed accessors so
-callers avoid manual casts. Adding a new widget requires zero changes to the
-core.
+
Each widget DXE registers a small API struct under a name during wgtRegister(). Callers retrieve it via wgtGetApi("button") and cast to the widget-specific API type. Per-widget headers provide typed accessors so callers avoid manual casts. Adding a new widget requires zero changes to the core.
Widget Interface Descriptors (WgtIfaceT)
-
Each widget can register an interface descriptor that describes its
-BASIC-facing properties, methods, and events. These descriptors are used by
-the form runtime and IDE for generic dispatch and property panel
-enumeration. Properties have typed getters/setters (WGT_IFACE_STRING,
-WGT_IFACE_INT, WGT_IFACE_BOOL, WGT_IFACE_ENUM).
+
Each widget can register an interface descriptor that describes its BASIC-facing properties, methods, and events. These descriptors are used by the form runtime and IDE for generic dispatch and property panel enumeration. Properties have typed getters/setters (WGT_IFACE_STRING, WGT_IFACE_INT, WGT_IFACE_BOOL, WGT_IFACE_ENUM).
DXE Module System
DXE Module System
-
DVX uses DJGPP's DXE3 (Dynamic eXtension) format for all loadable modules.
-DXE3 supports RTLD_GLOBAL symbol sharing -- symbols exported by one module
-are visible to all subsequently loaded modules. This is critical: widget
-DXEs call core API functions (e.g. rectFill, wgtInvalidate) that are
-exported by the core library DXE.
+
DVX uses DJGPP's DXE3 (Dynamic eXtension) format for all loadable modules. DXE3 supports RTLD_GLOBAL symbol sharing -- symbols exported by one module are visible to all subsequently loaded modules. This is critical: widget DXEs call core API functions (e.g. rectFill, wgtInvalidate) that are exported by the core library DXE.
Module Types
Extension Directory Purpose Examples
--------- --------- ------- --------
@@ -464,41 +393,22 @@ exported by the core library DXE.
Application Lifecycle
Two kinds of DXE apps:
Callback-only (hasMainLoop = false)
-appMain() creates windows, registers callbacks, and returns. The app lives
-through GUI callbacks driven by the shell's main loop. Lifecycle ends when
-the last window is closed. No extra task stack needed -- simpler and
-cheaper.
+appMain() creates windows, registers callbacks, and returns. The app lives through GUI callbacks driven by the shell's main loop. Lifecycle ends when the last window is closed. No extra task stack needed -- simpler and cheaper.
Main-loop (hasMainLoop = true)
-A dedicated cooperative task is created. appMain() runs in that task with
-its own loop, calling tsYield() to share CPU. Needed for apps with
-continuous work (terminal emulators, games). Lifecycle ends when appMain()
-returns.
+A dedicated cooperative task is created. appMain() runs in that task with its own loop, calling tsYield() to share CPU. Needed for apps with continuous work (terminal emulators, games). Lifecycle ends when appMain() returns.
Crash Recovery
-The platform layer installs signal handlers for SIGSEGV, SIGFPE, SIGILL. On
-crash, the handler logs platform-specific diagnostics (register dump on
-DJGPP), then longjmps back to the shell's main loop. The crashed app is
-killed; other apps and the shell survive. This provides Windows 3.1-style
-fault tolerance.
+The platform layer installs signal handlers for SIGSEGV, SIGFPE, SIGILL. On crash, the handler logs platform-specific diagnostics (register dump on DJGPP), then longjmps back to the shell's main loop. The crashed app is killed; other apps and the shell survive. This provides Windows 3.1-style fault tolerance.
Per-App Memory Tracking
-All allocations route through dvxMalloc/dvxFree wrappers that prepend a
-16-byte header recording the owning app ID and allocation size. The Task
-Manager displays per-app memory usage, and leaks are detected at app
-termination.
+All allocations route through dvxMalloc/dvxFree wrappers that prepend a 16-byte header recording the owning app ID and allocation size. The Task Manager displays per-app memory usage, and leaks are detected at app termination.
Event Model
Event Model
-
DVX uses a cooperative polling model. The main loop (dvxRun / dvxUpdate)
-runs this cycle each frame:
+
DVX uses a cooperative polling model. The main loop (dvxRun / dvxUpdate) runs this cycle each frame:
-Poll mouse -- platformMousePoll() returns position and button bitmask.
- Compare with previous frame for press/release edge detection.
-Poll keyboard -- platformKeyboardRead() returns ASCII + scancode.
- Non-blocking; returns false if buffer is empty.
-Dispatch to focused window -- the event loop fires window callbacks
- (onKey, onMouse, etc.) on the focused window. If the window has a widget
- tree, the widget system's installed handlers dispatch to individual
- widgets.
+Poll mouse -- platformMousePoll() returns position and button bitmask. Compare with previous frame for press/release edge detection.
+Poll keyboard -- platformKeyboardRead() returns ASCII + scancode. Non-blocking; returns false if buffer is empty.
+Dispatch to focused window -- the event loop fires window callbacks (onKey, onMouse, etc.) on the focused window. If the window has a widget tree, the widget system's installed handlers dispatch to individual widgets.
Compositor pass -- merge dirty rects, composite, flush to LFB.
Yield -- platformYield() or idle callback.
@@ -521,27 +431,16 @@ runs this cycle each frame:
|
Universal callbacks (onClick, onChange, etc.)
Accelerator Tables
-
Per-window accelerator tables map key + modifier combinations to command
-IDs. The runtime normalizes key/modifier at registration time (uppercase
-key, strip shift from modifiers) so matching at dispatch time is two integer
-comparisons per entry. Matched accelerators fire the window's onMenu
-callback with the command ID, unifying the menu and hotkey code paths.
+
Per-window accelerator tables map key + modifier combinations to command IDs. The runtime normalizes key/modifier at registration time (uppercase key, strip shift from modifiers) so matching at dispatch time is two integer comparisons per entry. Matched accelerators fire the window's onMenu callback with the command ID, unifying the menu and hotkey code paths.
Mouse Cursor
-
Software-rendered cursor using the classic AND/XOR mask approach. Seven
-cursor shapes are compiled in: arrow, horizontal resize, vertical resize,
-NW-SE diagonal resize, NE-SW diagonal resize, busy (hourglass), and
-crosshair. The cursor is painted into the backbuffer on top of the
-composited frame and the affected region is flushed to the LFB each frame.
+
Software-rendered cursor using the classic AND/XOR mask approach. Seven cursor shapes are compiled in: arrow, horizontal resize, vertical resize, NW-SE diagonal resize, NE-SW diagonal resize, busy (hourglass), and crosshair. The cursor is painted into the backbuffer on top of the composited frame and the affected region is flushed to the LFB each frame.
Double-Click Detection
-
Timestamp-based: two clicks on the same target (title bar, minimized icon,
-close gadget) within the configurable double-click interval trigger the
-double-click action. Separate tracking for each target type.
+
Timestamp-based: two clicks on the same target (title bar, minimized icon, close gadget) within the configurable double-click interval trigger the double-click action. Separate tracking for each target type.
Font System
Font System
-
DVX uses fixed-width 8-pixel-wide bitmap fonts only. One size is provided:
-8x16, matching the standard VGA ROM font and CP437 encoding (256 glyphs).
+
DVX uses fixed-width 8-pixel-wide bitmap fonts only. One size is provided: 8x16, matching the standard VGA ROM font and CP437 encoding (256 glyphs).
BitmapFontT
typedef struct {
int32_t charWidth; // fixed width per glyph (always 8)
@@ -557,35 +456,20 @@ double-click action. Separate tracking for each target type.
Each scanline of a glyph is exactly one byte (1bpp at 8 pixels wide).
No glyph-width tables, kerning, or per-character positioning needed.
-8-pixel width aligns with byte boundaries -- no bit shifting in per-scanline
-rendering.
+8-pixel width aligns with byte boundaries -- no bit shifting in per-scanline rendering.
Text Rendering Functions
-drawChar() -- Renders a single character. Supports opaque (background fill)
-and transparent modes.
-drawTextN() -- Optimized batch rendering for a known character count. Clips
-once for the entire run, fills background in a single rectFill, then
-overlays glyph foreground pixels. Significantly faster than per-character
-rendering for long runs.
-drawTermRow() -- Renders an 80-column terminal row in a single pass, with
-per-cell foreground/background from a 16-color palette, blink attribute
-support, and cursor rendering. Exists because per-character terminal
-rendering is unacceptably slow on target hardware.
-drawTextAccel() -- Renders text with & accelerator markers. The character
-after & is underlined to indicate the keyboard shortcut.
+drawChar() -- Renders a single character. Supports opaque (background fill) and transparent modes.
+drawTextN() -- Optimized batch rendering for a known character count. Clips once for the entire run, fills background in a single rectFill, then overlays glyph foreground pixels. Significantly faster than per-character rendering for long runs.
+drawTermRow() -- Renders an 80-column terminal row in a single pass, with per-cell foreground/background from a 16-color palette, blink attribute support, and cursor rendering. Exists because per-character terminal rendering is unacceptably slow on target hardware.
+drawTextAccel() -- Renders text with & accelerator markers. The character after & is underlined to indicate the keyboard shortcut.
Performance Optimization
-AppContextT stores a fixed-point 16.16 reciprocal of font.charHeight
-(charHeightRecip) so that dividing by charHeight (for pixel-to-row
-conversion in terminal/text widgets) becomes a multiply+shift instead of an
-integer divide, which costs 40+ cycles on a 486.
+AppContextT stores a fixed-point 16.16 reciprocal of font.charHeight (charHeightRecip) so that dividing by charHeight (for pixel-to-row conversion in terminal/text widgets) becomes a multiply+shift instead of an integer divide, which costs 40+ cycles on a 486.
Color System
Color System
Pixel Format
-
PixelFormatT describes the active VESA mode's pixel encoding. Populated once
-from the VBE mode info block. Stores shift, mask, and bit count for each
-channel so packColor() can convert RGB to native format with shift-and-mask
-arithmetic -- no per-pixel computation.
+
PixelFormatT describes the active VESA mode's pixel encoding. Populated once from the VBE mode info block. Stores shift, mask, and bit count for each channel so packColor() can convert RGB to native format with shift-and-mask arithmetic -- no per-pixel computation.
Supported depths:
Depth Bytes/Pixel Notes
----- ----------- -----
@@ -594,10 +478,7 @@ arithmetic -- no per-pixel computation.
16 bpp 2 5-6-5 RGB.
32 bpp 4 8-8-8 RGB (8 bits unused).
ColorSchemeT -- Theming
-
All 20 UI colors are pre-packed into display pixel format at init time.
-Every color is a uint32_t that can be written directly to the framebuffer
-with zero per-pixel conversion. The scheme must be regenerated on video mode
-change, but mode changes require re-init anyway.
+
All 20 UI colors are pre-packed into display pixel format at init time. Every color is a uint32_t that can be written directly to the framebuffer with zero per-pixel conversion. The scheme must be regenerated on video mode change, but mode changes require re-init anyway.
Color roles mirror classic Motif/Windows 3.x conventions:
desktop -- desktop background
@@ -609,13 +490,9 @@ change, but mode changes require re-init anyway.
scrollbarBg/Fg/Trough -- scrollbar components
cursorFg/Bg -- mouse cursor colors
-
Source RGB values are kept in AppContextT.colorRgb[] for theme save/load.
-Themes are stored as INI files with a [colors] section. The API provides
-dvxLoadTheme(), dvxSaveTheme(), dvxSetColor(), and dvxResetColorScheme().
+
Source RGB values are kept in AppContextT.colorRgb[] for theme save/load. Themes are stored as INI files with a [colors] section. The API provides dvxLoadTheme(), dvxSaveTheme(), dvxSetColor(), and dvxResetColorScheme().
Bevel Styles
-
Bevels are the defining visual element of the Motif aesthetic. Convenience
-macros create bevel style descriptors by swapping highlight and shadow
-colors:
+
Bevels are the defining visual element of the Motif aesthetic. Convenience macros create bevel style descriptors by swapping highlight and shadow colors:
BEVEL_RAISED(colorScheme, borderWidth) -- raised 3D look
BEVEL_SUNKEN(colorScheme, face, borderWidth) -- sunken/inset look
BEVEL_TROUGH(colorScheme) -- 1px scrollbar trough
@@ -624,47 +501,32 @@ colors:
Platform Layer
Platform Layer
-
All OS-specific and CPU-specific code is isolated behind dvxPlatform.h. To
-port DVX, implement a new dvxPlatformXxx.c against this header.
+
All OS-specific and CPU-specific code is isolated behind dvxPlatform.h. To port DVX, implement a new dvxPlatformXxx.c against this header.
Implementations
File Target Details
---- ------ -------
dvxPlatformDos.c DJGPP/DPMI Real VESA VBE, INT 33h mouse, INT 16h keyboard, rep movsd/rep stosl asm spans, DPMI physical memory mapping for LFB, INT 9 hook for key-up, CuteMouse Wheel API.
Abstraction Areas
Video
-
platformVideoInit() -- mode probe and framebuffer setup.
-platformVideoShutdown() -- restore previous mode. platformVideoEnumModes()
--- enumerate available modes.
+
platformVideoInit() -- mode probe and framebuffer setup. platformVideoShutdown() -- restore previous mode. platformVideoEnumModes() -- enumerate available modes.
Framebuffer Flush
-
platformFlushRect() -- copy dirty rect from backBuf to LFB. On DOS, each
-scanline uses rep movsd for near-optimal aligned 32-bit writes over the PCI
-bus.
+
platformFlushRect() -- copy dirty rect from backBuf to LFB. On DOS, each scanline uses rep movsd for near-optimal aligned 32-bit writes over the PCI bus.
Optimized Memory Spans
-
Six functions: platformSpanFill8/16/32() and platformSpanCopy8/16/32().
-Called once per scanline of every rectangle fill, blit, and text draw. On
-DOS these use inline assembly for critical inner loops.
+
Six functions: platformSpanFill8/16/32() and platformSpanCopy8/16/32(). Called once per scanline of every rectangle fill, blit, and text draw. On DOS these use inline assembly for critical inner loops.
Mouse Input
-
Polling model. platformMousePoll() returns position and button bitmask.
-Wheel support via CuteMouse API.
+
Polling model. platformMousePoll() returns position and button bitmask. Wheel support via CuteMouse API.
Keyboard Input
-
platformKeyboardRead() -- non-blocking key read. platformKeyUpRead() -- key
-release detection (requires INT 9 hook on DOS). platformAltScanToChar() --
-scancode-to-ASCII lookup for Alt+key combinations.
+
platformKeyboardRead() -- non-blocking key read. platformKeyUpRead() -- key release detection (requires INT 9 hook on DOS). platformAltScanToChar() -- scancode-to-ASCII lookup for Alt+key combinations.
Crash Recovery
-
platformInstallCrashHandler() -- signal handlers + longjmp for fault
-tolerance.
+
platformInstallCrashHandler() -- signal handlers + longjmp for fault tolerance.
DXE Support
-
platformRegisterDxeExports() -- register C runtime and platform symbols for
-DXE resolution. platformRegisterSymOverrides() -- register function pointer
-overrides for module loader.
+
platformRegisterDxeExports() -- register C runtime and platform symbols for DXE resolution. platformRegisterSymOverrides() -- register function pointer overrides for module loader.
Build System
Build System
Cross-Compilation
-
DVX is cross-compiled from Linux using a DJGPP cross-compiler
-(i586-pc-msdosdjgpp-gcc). The top-level Makefile orchestrates building all
-subsystems in dependency order.
+
DVX is cross-compiled from Linux using a DJGPP cross-compiler (i586-pc-msdosdjgpp-gcc). The top-level Makefile orchestrates building all subsystems in dependency order.
make -- build everything
./mkcd.sh -- build + create ISO for 86Box
Build Targets
@@ -684,8 +546,7 @@ subsystems in dependency order.
serial serial DXE libs UART driver, HDLC packets, security, seclink
sql SQL DXE lib SQLite integration
DXE3 Build Process
-
Each DXE module is compiled to an object file with GCC, then linked with
-dxe3gen:
+
Each DXE module is compiled to an object file with GCC, then linked with dxe3gen:
# Compile
i586-pc-msdosdjgpp-gcc -O2 -march=i486 -mtune=i586 -c -o widget.o widget.c
@@ -694,21 +555,15 @@ dxe3gen:
# Optionally append resources
dvxres build widget.wgt widget.res
-
The -E flag specifies exported symbols (prefixed with underscore per DJGPP
-convention). -U marks unresolved symbols as OK (they'll be resolved at load
-time from previously loaded DXEs).
+
The -E flag specifies exported symbols (prefixed with underscore per DJGPP convention). -U marks unresolved symbols as OK (they'll be resolved at load time from previously loaded DXEs).
Deployment (mkcd.sh)
Runs make all.
-Verifies critical outputs exist (dvx.exe, libtasks.lib, libdvx.lib,
- dvxshell.lib).
+Verifies critical outputs exist (dvx.exe, libtasks.lib, libdvx.lib, dvxshell.lib).
Counts widget modules.
-Creates an ISO 9660 image from bin/ using mkisofs: -iso-level 1 (strict
- 8.3 filenames for DOS), -J (Joliet extensions for long names), -V DVX
- (volume label).
+Creates an ISO 9660 image from bin/ using mkisofs: -iso-level 1 (strict 8.3 filenames for DOS), -J (Joliet extensions for long names), -V DVX (volume label).
-
Places the ISO at ~/.var/app/net._86box._86Box/data/86Box/dvx.iso for 86Box
-to mount as CD-ROM.
+
Places the ISO at ~/.var/app/net._86box._86Box/data/86Box/dvx.iso for 86Box to mount as CD-ROM.
Compiler Flags
-O2 Optimization level 2
-march=i486 486 instruction set baseline
diff --git a/docs/dvx_help.html b/docs/dvx_help.html
new file mode 100644
index 0000000..6193005
--- /dev/null
+++ b/docs/dvx_help.html
@@ -0,0 +1,3699 @@
+
+
+
+
+DVX Architecture Overview
+
+
+
+
+Contents
+
+Index
+
+
+
+
+
DVX Architecture Overview
+
DVX Architecture Overview
+
DOS Visual eXecutive -- A Windowing GUI for DJGPP/DPMI
+
DVX (DOS Visual eXecutive) is a complete windowing GUI compositor targeting DJGPP/DPMI on DOS. It provides overlapping windows with Motif-style chrome, a retained-mode widget toolkit, cooperative multitasking of DXE-loaded applications, and a dirty-rectangle compositor optimized for 486/Pentium hardware.
+
Key Design Constraints
+
+VESA VBE 2.0+ LFB only -- no bank switching. If the hardware cannot provide a linear framebuffer, initialization fails.
+486 baseline -- all hot paths are written to be fast on a 486, with Pentium-specific paths where the gain is significant.
+Single-tasking cooperative model -- applications yield the CPU via tsYield(); there is no preemptive scheduler.
+86Box is the trusted reference platform for testing. DOSBox-X is not used; any bugs observed are treated as DVX bugs.
+
+
No external font or cursor files -- all bitmaps are compiled in as static const data.
+
The runtime environment consists of a bootstrap loader (dvx.exe) that loads core DXE libraries, widget plugins, and the shell, which in turn loads and manages DXE application modules.
+
Contents
+
Five-Layer Architecture
+
Display Pipeline
+
Window System
+
Widget System
+
DXE Module System
+
Event Model
+
Font System
+
Color System
+
Platform Layer
+
Build System
+
+
+
Five-Layer Architecture
+
Five-Layer Architecture
+
DVX is organized into five layers, each implemented as a single .h/.c pair. Every header includes dvxTypes.h (the shared type definitions) to avoid circular dependencies. The layers are strictly stacked: each layer depends only on the layers below it.
+
Applications (DXE .app modules)
+ ==================================================
+ | |
+ | +------------------------------------------+ |
+ | | Layer 5: dvxApp (Application API) | | dvxApp.h / dvxApp.c
+ | | Event loop, window creation, public API | |
+ | +------------------------------------------+ |
+ | | Layer 4: dvxWm (Window Manager) | | dvxWm.h / dvxWm.c
+ | | Window stack, chrome, drag, resize | |
+ | +------------------------------------------+ |
+ | | Layer 3: dvxComp (Compositor) | | dvxComp.h / dvxComp.c
+ | | Dirty rect tracking, merge, LFB flush | |
+ | +------------------------------------------+ |
+ | | Layer 2: dvxDraw (Drawing Primitives) | | dvxDraw.h / dvxDraw.c
+ | | Rects, bevels, text, blits, cursors | |
+ | +------------------------------------------+ |
+ | | Layer 1: dvxVideo (Video Backend) | | dvxVideo.h / dvxVideo.c
+ | | VESA VBE, LFB mapping, pixel format | |
+ | +------------------------------------------+ |
+ | |
+ | +------------------------------------------+ |
+ | | Platform Layer (dvxPlatform.h) | | dvxPlatformDos.c
+ | | OS-specific: video, input, asm spans | |
+ | +------------------------------------------+ |
+ | |
+ | +------------------------------------------+ |
+ | | Shared Types (dvxTypes.h) | |
+ | | DisplayT, WindowT, RectT, ColorSchemeT | |
+ | +------------------------------------------+ |
+ ==================================================
+
Layer Summary
+
Layer Header Responsibility
+ ----- ------ --------------
+ 1 - Video dvxVideo.h VESA VBE mode negotiation, LFB mapping via DPMI, backbuffer allocation, packColor() (RGB to native pixel format), display-wide clip rectangle.
+ 2 - Draw dvxDraw.h All 2D drawing: rectFill, rectCopy, drawBevel, drawText/drawTextN, drawMaskedBitmap (cursor), drawTermRow (batch terminal row). Stateless beyond clip rect. Dispatches hot inner loops through BlitOpsT function pointers.
+ 3 - Compositor dvxComp.h Dirty rectangle tracking (dirtyListAdd), pairwise merge of overlapping rects (dirtyListMerge), and flushRect to copy dirty regions from backBuf to LFB.
+ 4 - Window Manager dvxWm.h Window lifecycle, Z-order stack, chrome drawing (title bars, bevels, close/minimize/maximize gadgets), hit testing, drag/resize, menu bars, scrollbars, system menu, keyboard move/resize, minimized icon bar.
+ 5 - Application dvxApp.h Public API aggregating all layers into AppContextT. Provides dvxInit/dvxShutdown, dvxRun/dvxUpdate, window creation helpers, image loading, clipboard, accelerator tables, theme management, wallpaper, video mode switching, screenshot capture.
+
+
+
Display Pipeline
+
Display Pipeline
+
The double-buffer strategy is the single most important performance decision in DVX. All drawing goes to a system RAM backbuffer (DisplayT.backBuf); only dirty rectangles are flushed to the linear framebuffer (DisplayT.lfb) in video memory.
+
This matters because writes to video memory over the PCI bus are 10-50x slower than writes to main RAM on 486/Pentium hardware for random-access patterns.
+
Per-Frame Compositing Pipeline
+
1. Input poll (mouse, keyboard)
+ |
+ 2. Event dispatch (focus window callbacks)
+ |
+ 3. Layers call dirtyListAdd() for changed regions
+ |
+ 4. dirtyListMerge() consolidates overlapping rects
+ |
+ 5. For each merged dirty rect:
+ a. Clip and redraw desktop background (or wallpaper)
+ b. For each window (back-to-front, painter's algorithm):
+ - wmDrawChrome() -- frame, title bar, gadgets, menu bar
+ - wmDrawContent() -- blit per-window content buffer
+ - wmDrawScrollbars()
+ c. Draw minimized window icons
+ d. Draw popup menus / tooltips (overlay pass)
+ e. Draw software mouse cursor
+ |
+ 6. flushRect() -- copy each dirty rect from backBuf to LFB
+ |
+ 7. Yield (platformYield)
+
Key Data Structures
+
DisplayT -- Central display context: width, height, pitch, pixel format, LFB pointer, backbuffer pointer, palette, clip rectangle. Passed by pointer through every layer -- no globals.
+
BlitOpsT -- Vtable of span fill/copy function pointers resolved at init time for the active pixel depth. On DOS these dispatch to hand-written rep stosl / rep movsd asm inner loops.
+
DirtyListT -- Fixed-capacity dynamic array of RectT. Linear scanning for merge candidates is cache-friendly at typical sizes (under 128 rects). If the list fills up, the compositor merges aggressively or falls back to full-screen repaint.
+
Why This Works on a 486
+
+A full 640x480x32bpp frame is 1.2 MB -- far too much to flush every frame over a slow PCI bus.
+A typical dirty region during normal interaction (typing, menu open) is a few KB.
+Merging overlapping dirty rects into larger rects reduces per-rect overhead and improves bus utilization.
+
+
Per-window content buffers persist across frames, so windows don't repaint on expose -- only when their own content changes.
+
+
+
Window System
+
Window System
+
WindowT Structure
+
Each WindowT is the central object of the window manager. Key fields:
+
Field Group Purpose
+ ----------- -------
+ Geometry (x, y, w, h) Outer frame rectangle (including chrome).
+ Content area (contentX/Y/W/H) Computed from frame minus chrome. Where application content lives.
+ Content buffer (contentBuf, contentPitch) Per-window backbuffer in native pixel format. Persists across frames.
+ Chrome state (menuBar, vScroll, hScroll) Optional menu bar and scrollbars. Affect content area computation.
+ Widget tree (widgetRoot) Root of the retained-mode widget tree (NULL if using raw callbacks).
+ Callbacks onPaint, onKey, onKeyUp, onMouse, onResize, onClose, onMenu, onScroll, onFocus, onBlur, onCursorQuery.
+
Window Stack (Z-Order)
+
WindowStackT is an array of WindowT* ordered front-to-back: index count-1 is the topmost window. This allows:
+
+Back-to-front iteration for painting (painter's algorithm).
+Front-to-back iteration for hit testing (first hit wins).
+
+
Reordering by pointer swap (no copying of large WindowT structs).
+
Only one drag/resize/scroll operation can be active system-wide at a time (single mouse), so that state lives on the stack, not on individual windows.
+
Chrome Layout
+
+-------------------------------------------+
+ | 4px outer border (raised bevel) |
+ | +-------------------------------------+ |
+ | | [X] Title Bar Text [_] [^] [X] | | 20px title height
+ | +-------------------------------------+ |
+ | | 2px inner border | |
+ | +-------------------------------------+ |
+ | | Menu Bar (optional, 20px) | |
+ | +-------------------------------------+ |
+ | | | |
+ | | Content Area | |
+ | | | |
+ | | | S | | S = vertical scrollbar
+ | | | B | | (16px wide)
+ | +-------------------------------------+ |
+ | | Horizontal Scrollbar (optional) | | 16px tall
+ | +-------------------------------------+ |
+ | 4px outer border |
+ +-------------------------------------------+
+
Chrome constants are compile-time defines:
+
CHROME_BORDER_WIDTH = 4px
+ CHROME_TITLE_HEIGHT = 20px
+ CHROME_INNER_BORDER = 2px
+ CHROME_MENU_HEIGHT = 20px
+ SCROLLBAR_WIDTH = 16px
+ CHROME_CLOSE_BTN_SIZE = 16px
+
Hit Test Regions
+
wmHitTest() iterates the stack front-to-back and returns a hit-part identifier: HIT_CONTENT, HIT_TITLE, HIT_CLOSE, HIT_RESIZE, HIT_MENU, HIT_VSCROLL, HIT_HSCROLL, HIT_MINIMIZE, HIT_MAXIMIZE. Resize edge detection returns a bitmask of RESIZE_LEFT, RESIZE_RIGHT, RESIZE_TOP, RESIZE_BOTTOM (corners combine two edges).
+
Menu System
+
Menus use fixed-size arrays with inline char buffers (no heap strings). Up to 8 menus per bar, items dynamically allocated. Supports cascading submenus via MenuItemT.subMenu pointer. Item types: normal, checkbox, radio. Separators are non-interactive items. The popup state (PopupStateT) tracks a stack of parent frames for cascading submenu nesting.
+
Minimized Windows
+
Minimized windows display as 64x64 icons at the bottom of the screen with beveled borders, similar to a classic desktop icon bar. Icons show a scaled-down preview of the window's content buffer, refreshed one per frame in a round-robin fashion to amortize the scaling cost.
+
+
+
Widget System
+
Widget System
+
The widget system (dvxWidget.h) is a retained-mode toolkit layered on top of the window manager. Widgets form a tree rooted at a per-window VBox container.
+
WidgetT Base Structure
+
Every widget shares the same WidgetT struct. The type field is a runtime-assigned integer ID. The wclass pointer references the widget's WidgetClassT vtable. Widget-specific private data is stored in w->data (opaque void*).
+
Tree linkage: parent, firstChild, lastChild, nextSibling. No prevSibling -- this halves pointer overhead and removal is still O(n) for typical tree depths of 5-10.
+
Layout Engine
+
Two-pass flexbox-like algorithm:
+
+Bottom-up (calcMinSize) -- compute minimum sizes for every widget, starting from leaves.
+
+
Top-down (layout) -- allocate space within available bounds, distributing extra space according to weight values (0 = fixed, 100 = normal stretch).
+
Size hints use a tagged encoding: the top 2 bits of an int32_t select the unit (pixels, character widths, or percentage of parent), the low 30 bits hold the value. Macros: wgtPixels(v), wgtChars(v), wgtPercent(v).
+
Widget Class Dispatch (WidgetClassT)
+
Each widget type provides a WidgetClassT with a handlers[] array indexed by stable method IDs. Method IDs are never reordered or reused -- new methods append at the end. This provides ABI-stable dispatch so that widget DXEs compiled against an older DVX version continue to work.
+
Methods include: PAINT, PAINT_OVERLAY, CALC_MIN_SIZE, LAYOUT, ON_MOUSE, ON_KEY, ON_ACCEL_ACTIVATE, DESTROY, GET_TEXT, SET_TEXT, POLL, and more (21 defined, room for 32).
+
Class Flags
+
Flag Meaning
+ ---- -------
+ WCLASS_FOCUSABLE Can receive keyboard focus (Tab navigation)
+ WCLASS_HORIZ_CONTAINER Lays out children horizontally (HBox)
+ WCLASS_PAINTS_CHILDREN Widget handles child rendering itself
+ WCLASS_SCROLLABLE Accepts mouse wheel events
+ WCLASS_SCROLL_CONTAINER ScrollPane -- scrolling viewport
+ WCLASS_NEEDS_POLL Needs periodic polling (e.g. AnsiTerm comms)
+ WCLASS_SWALLOWS_TAB Tab key goes to widget, not focus navigation
+ WCLASS_PRESS_RELEASE Click = press + release (buttons)
+
Available Widget Types
+
Each widget is a separate .wgt DXE module. 29 widget types are included:
+
Widget Description
+ ------ -----------
+ Box (VBox/HBox) Vertical and horizontal layout containers
+ Button Clickable push button with label
+ Canvas Raw drawing surface for custom painting
+ Checkbox Boolean toggle with checkmark
+ ComboBox Text input with dropdown list
+ DataCtrl Data-bound control for database operations
+ DbGrid Database grid (tabular data display)
+ Dropdown Dropdown selection list
+ Image Static image display
+ ImageButton Button with bitmap icon
+ Label Static text label
+ ListBox Scrollable selection list
+ ListView Multi-column list with headers and sorting
+ ProgressBar Determinate progress indicator
+ Radio Radio button (mutual exclusion group)
+ ScrollPane Scrollable viewport container
+ Separator Visual divider line
+ Slider Value selection via draggable thumb
+ Spacer Empty space for layout
+ Spinner Numeric input with up/down arrows
+ Splitter Resizable split pane
+ StatusBar Window status bar with sections
+ TabControl Tabbed page container
+ Terminal (AnsiTerm) ANSI terminal emulator widget
+ TextInput Single-line text entry field
+ Timer Periodic timer events
+ Toolbar Toolbar with icon buttons
+ TreeView Hierarchical tree display
+ WrapBox Flow layout (wrapping horizontal container)
+
Widget API Registry
+
Each widget DXE registers a small API struct under a name during wgtRegister(). Callers retrieve it via wgtGetApi("button") and cast to the widget-specific API type. Per-widget headers provide typed accessors so callers avoid manual casts. Adding a new widget requires zero changes to the core.
+
Widget Interface Descriptors (WgtIfaceT)
+
Each widget can register an interface descriptor that describes its BASIC-facing properties, methods, and events. These descriptors are used by the form runtime and IDE for generic dispatch and property panel enumeration. Properties have typed getters/setters (WGT_IFACE_STRING, WGT_IFACE_INT, WGT_IFACE_BOOL, WGT_IFACE_ENUM).
+
+
+
DXE Module System
+
DXE Module System
+
DVX uses DJGPP's DXE3 (Dynamic eXtension) format for all loadable modules. DXE3 supports RTLD_GLOBAL symbol sharing -- symbols exported by one module are visible to all subsequently loaded modules. This is critical: widget DXEs call core API functions (e.g. rectFill, wgtInvalidate) that are exported by the core library DXE.
+
Module Types
+
Extension Directory Purpose Examples
+ --------- --------- ------- --------
+ .lib LIBS/ Core libraries loaded first. Provide infrastructure APIs. libtasks.lib, libdvx.lib, dvxshell.lib
+ .wgt WIDGETS/ Widget type plugins. Each exports wgtRegister(). button.wgt, listview.wgt, terminal.wgt
+ .app APPS/*/ Application modules. Each exports appDescriptor and appMain(). Loaded on demand by the shell. progman.app, notepad.app, cpanel.app
+
Boot Sequence
+
dvx.exe (loader)
+ |
+ +-- Enter VGA mode 13h, display splash screen with progress bar
+ |
+ +-- Scan LIBS/ for *.lib, WIDGETS/ for *.wgt
+ |
+ +-- Read .dep files for each module (dependency base names)
+ |
+ +-- Topological sort: load modules in dependency order
+ | - dlopen() with RTLD_GLOBAL
+ | - Each .wgt that exports wgtRegister() has it called
+ |
+ +-- Find and call shellMain() (exported by dvxshell.lib)
+ |
+ +-- dvxInit() -- video mode, input, font, colors, cursors
+ |
+ +-- Load desktop app (progman.app)
+ |
+ +-- Main loop:
+ dvxUpdate() -> tsYield() -> shellReapApps()
+
Application Lifecycle
+
Two kinds of DXE apps:
+
Callback-only (hasMainLoop = false)
+
appMain() creates windows, registers callbacks, and returns. The app lives through GUI callbacks driven by the shell's main loop. Lifecycle ends when the last window is closed. No extra task stack needed -- simpler and cheaper.
+
Main-loop (hasMainLoop = true)
+
A dedicated cooperative task is created. appMain() runs in that task with its own loop, calling tsYield() to share CPU. Needed for apps with continuous work (terminal emulators, games). Lifecycle ends when appMain() returns.
+
Crash Recovery
+
The platform layer installs signal handlers for SIGSEGV, SIGFPE, SIGILL. On crash, the handler logs platform-specific diagnostics (register dump on DJGPP), then longjmps back to the shell's main loop. The crashed app is killed; other apps and the shell survive. This provides Windows 3.1-style fault tolerance.
+
Per-App Memory Tracking
+
All allocations route through dvxMalloc/dvxFree wrappers that prepend a 16-byte header recording the owning app ID and allocation size. The Task Manager displays per-app memory usage, and leaks are detected at app termination.
+
+
+
Event Model
+
Event Model
+
DVX uses a cooperative polling model. The main loop (dvxRun / dvxUpdate) runs this cycle each frame:
+
+Poll mouse -- platformMousePoll() returns position and button bitmask. Compare with previous frame for press/release edge detection.
+Poll keyboard -- platformKeyboardRead() returns ASCII + scancode. Non-blocking; returns false if buffer is empty.
+Dispatch to focused window -- the event loop fires window callbacks (onKey, onMouse, etc.) on the focused window. If the window has a widget tree, the widget system's installed handlers dispatch to individual widgets.
+Compositor pass -- merge dirty rects, composite, flush to LFB.
+
+
Yield -- platformYield() or idle callback.
+
Event Dispatch Chain
+
Mouse/Keyboard Input
+ |
+ Global handlers (Ctrl+Esc, modal filter)
+ |
+ Accelerator table check (focused window)
+ |
+ Window callback (onMouse / onKey)
+ |
+ [If widget tree installed:]
+ |
+ widgetOnMouse / widgetOnKey
+ |
+ Widget hit test (widgetHitTest)
+ |
+ wclsOnMouse / wclsOnKey (vtable dispatch)
+ |
+ Universal callbacks (onClick, onChange, etc.)
+
Accelerator Tables
+
Per-window accelerator tables map key + modifier combinations to command IDs. The runtime normalizes key/modifier at registration time (uppercase key, strip shift from modifiers) so matching at dispatch time is two integer comparisons per entry. Matched accelerators fire the window's onMenu callback with the command ID, unifying the menu and hotkey code paths.
+
Mouse Cursor
+
Software-rendered cursor using the classic AND/XOR mask approach. Seven cursor shapes are compiled in: arrow, horizontal resize, vertical resize, NW-SE diagonal resize, NE-SW diagonal resize, busy (hourglass), and crosshair. The cursor is painted into the backbuffer on top of the composited frame and the affected region is flushed to the LFB each frame.
+
Double-Click Detection
+
Timestamp-based: two clicks on the same target (title bar, minimized icon, close gadget) within the configurable double-click interval trigger the double-click action. Separate tracking for each target type.
+
+
+
Font System
+
Font System
+
DVX uses fixed-width 8-pixel-wide bitmap fonts only. One size is provided: 8x16, matching the standard VGA ROM font and CP437 encoding (256 glyphs).
+
BitmapFontT
+
typedef struct {
+ int32_t charWidth; // fixed width per glyph (always 8)
+ int32_t charHeight; // 16
+ int32_t firstChar; // typically 0
+ int32_t numChars; // typically 256
+ const uint8_t *glyphData; // packed 1bpp, charHeight bytes per glyph
+ } BitmapFontT;
+
Design rationale:
+
+Character positions are pure multiplication (x = col * 8).
+Glyph lookup is a single array index.
+Each scanline of a glyph is exactly one byte (1bpp at 8 pixels wide).
+No glyph-width tables, kerning, or per-character positioning needed.
+
+
8-pixel width aligns with byte boundaries -- no bit shifting in per-scanline rendering.
+
Text Rendering Functions
+
drawChar() -- Renders a single character. Supports opaque (background fill) and transparent modes.
+
drawTextN() -- Optimized batch rendering for a known character count. Clips once for the entire run, fills background in a single rectFill, then overlays glyph foreground pixels. Significantly faster than per-character rendering for long runs.
+
drawTermRow() -- Renders an 80-column terminal row in a single pass, with per-cell foreground/background from a 16-color palette, blink attribute support, and cursor rendering. Exists because per-character terminal rendering is unacceptably slow on target hardware.
+
drawTextAccel() -- Renders text with & accelerator markers. The character after & is underlined to indicate the keyboard shortcut.
+
Performance Optimization
+
AppContextT stores a fixed-point 16.16 reciprocal of font.charHeight (charHeightRecip) so that dividing by charHeight (for pixel-to-row conversion in terminal/text widgets) becomes a multiply+shift instead of an integer divide, which costs 40+ cycles on a 486.
+
+
+
Color System
+
Color System
+
Pixel Format
+
PixelFormatT describes the active VESA mode's pixel encoding. Populated once from the VBE mode info block. Stores shift, mask, and bit count for each channel so packColor() can convert RGB to native format with shift-and-mask arithmetic -- no per-pixel computation.
+
Supported depths:
+
Depth Bytes/Pixel Notes
+ ----- ----------- -----
+ 8 bpp 1 Palette mode. Nearest-index via 6x6x6 color cube + grey ramp.
+ 15 bpp 2 5-5-5 RGB (1 bit unused).
+ 16 bpp 2 5-6-5 RGB.
+ 32 bpp 4 8-8-8 RGB (8 bits unused).
+
ColorSchemeT -- Theming
+
All 20 UI colors are pre-packed into display pixel format at init time. Every color is a uint32_t that can be written directly to the framebuffer with zero per-pixel conversion. The scheme must be regenerated on video mode change, but mode changes require re-init anyway.
+
Color roles mirror classic Motif/Windows 3.x conventions:
+
+desktop -- desktop background
+windowFace, windowHighlight, windowShadow -- window chrome bevel triplet
+activeTitleBg/Fg, inactiveTitleBg/Fg -- focused vs. unfocused title bar
+contentBg/Fg -- window content area
+menuBg/Fg, menuHighlightBg/Fg -- menus
+buttonFace -- button background
+scrollbarBg/Fg/Trough -- scrollbar components
+
+
cursorFg/Bg -- mouse cursor colors
+
Source RGB values are kept in AppContextT.colorRgb[] for theme save/load. Themes are stored as INI files with a [colors] section. The API provides dvxLoadTheme(), dvxSaveTheme(), dvxSetColor(), and dvxResetColorScheme().
+
Bevel Styles
+
Bevels are the defining visual element of the Motif aesthetic. Convenience macros create bevel style descriptors by swapping highlight and shadow colors:
+
BEVEL_RAISED(colorScheme, borderWidth) -- raised 3D look
+ BEVEL_SUNKEN(colorScheme, face, borderWidth) -- sunken/inset look
+ BEVEL_TROUGH(colorScheme) -- 1px scrollbar trough
+ BEVEL_SB_BUTTON(colorScheme) -- scrollbar button
+
+
+
+
Build System
+
Build System
+
Cross-Compilation
+
DVX is cross-compiled from Linux using a DJGPP cross-compiler (i586-pc-msdosdjgpp-gcc). The top-level Makefile orchestrates building all subsystems in dependency order.
+
make -- build everything
+ ./mkcd.sh -- build + create ISO for 86Box
+
Build Targets
+
all: core tasks loader texthelp listhelp tools widgets shell taskmgr serial sql apps
+
Target Output Description
+ ------ ------ -----------
+ core bin/libs/libdvx.lib GUI core library (draw, comp, wm, app, widget infrastructure)
+ tasks bin/libs/libtasks.lib Cooperative task switcher
+ loader bin/dvx.exe Bootstrap loader (the DOS executable)
+ widgets bin/widgets/*.wgt 29 widget type plugins
+ shell bin/libs/dvxshell.lib DVX Shell (app management, desktop)
+ taskmgr bin/libs/taskmgr.lib Task Manager (loaded as a separate DXE)
+ texthelp shared library Shared text editing helpers (clipboard, word boundaries)
+ listhelp shared library Shared dropdown/list helpers
+ apps bin/apps/*/*.app Application modules (progman, notepad, clock, etc.)
+ tools bin/dvxres Resource compiler (runs on Linux, builds resource sections into DXEs)
+ serial serial DXE libs UART driver, HDLC packets, security, seclink
+ sql SQL DXE lib SQLite integration
+
DXE3 Build Process
+
Each DXE module is compiled to an object file with GCC, then linked with dxe3gen:
+
# Compile
+ i586-pc-msdosdjgpp-gcc -O2 -march=i486 -mtune=i586 -c -o widget.o widget.c
+
+ # Link as DXE with exported symbols
+ dxe3gen -o widget.wgt -E _wgtRegister -U widget.o
+
+ # Optionally append resources
+ dvxres build widget.wgt widget.res
+
The -E flag specifies exported symbols (prefixed with underscore per DJGPP convention). -U marks unresolved symbols as OK (they'll be resolved at load time from previously loaded DXEs).
+
Deployment (mkcd.sh)
+
+Runs make all.
+Verifies critical outputs exist (dvx.exe, libtasks.lib, libdvx.lib, dvxshell.lib).
+Counts widget modules.
+Creates an ISO 9660 image from bin/ using mkisofs: -iso-level 1 (strict 8.3 filenames for DOS), -J (Joliet extensions for long names), -V DVX (volume label).
+
+
Places the ISO at ~/.var/app/net._86box._86Box/data/86Box/dvx.iso for 86Box to mount as CD-ROM.
+
Compiler Flags
+
-O2 Optimization level 2
+ -march=i486 486 instruction set baseline
+ -mtune=i586 Optimize scheduling for Pentium
+ -Wall -Wextra Full warnings
+
Directory Layout
+
dvxgui/
+ +-- core/ Core library sources (dvxVideo, dvxDraw, dvxComp, dvxWm, dvxApp, widget infra)
+ | +-- platform/ Platform abstraction (dvxPlatform.h, dvxPlatformDos.c)
+ | +-- thirdparty/ stb_image, stb_ds, stb_image_write
+ +-- loader/ Bootstrap loader (dvx.exe)
+ +-- tasks/ Cooperative task switcher (libtasks.lib)
+ +-- shell/ DVX Shell (dvxshell.lib)
+ +-- widgets/ Widget DXE modules (*.wgt), each in its own subdirectory
+ | +-- box/ VBox/HBox layout containers
+ | +-- button/ Push button
+ | +-- textInput/ Text entry field
+ | +-- listView/ Multi-column list
+ | +-- ... (29 widget types total)
+ +-- texthelp/ Shared text editing helpers
+ +-- listhelp/ Shared dropdown/list helpers
+ +-- apps/ Application DXE modules (*.app)
+ | +-- progman/ Program Manager (desktop)
+ | +-- notepad/ Text editor
+ | +-- cpanel/ Control Panel
+ | +-- imgview/ Image viewer
+ | +-- clock/ Clock
+ | +-- dvxdemo/ Demo / showcase app
+ | +-- dvxbasic/ DVX BASIC compiler and VM
+ +-- tools/ Build tools (dvxres resource compiler)
+ +-- rs232/ ISR-driven UART driver
+ +-- packet/ HDLC framing, CRC-16, sliding window
+ +-- security/ DH key exchange, XTEA cipher, DRBG RNG
+ +-- seclink/ Encrypted channel wrapper
+ +-- serial/ Combined serial stack DXE
+ +-- proxy/ Linux proxy (86Box <-> secLink <-> telnet)
+ +-- sql/ SQLite integration
+ +-- bin/ Build output (dvx.exe, libs/, widgets/, apps/, config/)
+ +-- obj/ Intermediate object files
+ +-- docs/ Documentation
+
+
+
+
dvxTypes.h -- Shared Type Definitions
+
dvxTypes.h -- Shared Type Definitions
+
Central type definitions shared across all five layers of the DVX GUI stack. Every header includes this file. Contains no function definitions -- only structs, enums, typedefs, and compile-time constants.
+
Core Structures
+
PixelFormatT
+
Describes the pixel encoding for the active VESA video mode. Populated once at startup from the VBE mode info block, then treated as read-only.
+
Field Description
+ ----- -----------
+ int32_t bitsPerPixel 8, 15, 16, or 32
+ int32_t bytesPerPixel 1, 2, 2, or 4
+ uint32_t redMask, greenMask, blueMask Bitmasks for each color channel
+ int32_t redShift, greenShift, blueShift Bit position of each color field
+ int32_t redBits, greenBits, blueBits Number of bits per channel
+
DisplayT
+
Single display context passed by pointer through every layer. All drawing targets the backBuf; only dirty rects are flushed to lfb.
+
Field Description
+ ----- -----------
+ int32_t width, height Screen dimensions in pixels
+ int32_t pitch Bytes per scanline
+ PixelFormatT format Active pixel format
+ uint8_t *lfb Mapped linear framebuffer (VESA LFB)
+ uint8_t *backBuf System RAM backbuffer
+ uint8_t *palette 768 bytes for 8-bit mode, NULL otherwise
+ int32_t clipX, clipY, clipW, clipH Current clip rectangle
+
RectT
+
Rectangle in origin + extent form. Used throughout the compositor, window manager, and widget layout engine.
+
Field Description
+ ----- -----------
+ int32_t x, y Top-left corner
+ int32_t w, h Width and height
+
BlitOpsT
+
Vtable for hot-path span operations. Resolved at init time based on pixel depth. On DOS, these dispatch to hand-written asm (rep stosl / rep movsd).
+
Field Description
+ ----- -----------
+ SpanFillFnT spanFill Fill a horizontal span with a solid color
+ SpanCopyFnT spanCopy Copy a horizontal span between buffers
+ int32_t bytesPerPixel Bytes per pixel for the active mode
+ int32_t pitch Bytes per scanline
+
BevelStyleT
+
Bevel drawing parameters. Swapping highlight/shadow flips raised vs. sunken appearance.
+
Field Description
+ ----- -----------
+ uint32_t highlight Lighter color (top/left edges)
+ uint32_t shadow Darker color (bottom/right edges)
+ uint32_t face Interior fill color (0 = no fill)
+ int32_t width Border thickness in pixels (typically 2)
+
BitmapFontT
+
Fixed-width 8-pixel-wide bitmap font descriptor. One size provided: 8x16 (standard VGA ROM font, CP437 encoding).
+
Field Description
+ ----- -----------
+ int32_t charWidth Fixed width per glyph (always 8)
+ int32_t charHeight Glyph height (14 or 16)
+ int32_t firstChar ASCII code of first glyph (typically 0)
+ int32_t numChars Number of glyphs (typically 256)
+ const uint8_t *glyphData Packed 1bpp data, charHeight bytes per glyph
+
ColorSchemeT
+
All UI colors pre-packed into display pixel format at init time. Theme support is achieved by swapping this struct.
+
Field Description
+ ----- -----------
+ uint32_t desktop Desktop background color
+ uint32_t windowFace Window body / chrome face
+ uint32_t windowHighlight Bevel highlight (top/left edge)
+ uint32_t windowShadow Bevel shadow (bottom/right edge)
+ uint32_t activeTitleBg, activeTitleFg Focused window title bar
+ uint32_t inactiveTitleBg, inactiveTitleFg Unfocused window title bar
+ uint32_t contentBg, contentFg Window content area default colors
+ uint32_t menuBg, menuFg Menu bar and popup background/text
+ uint32_t menuHighlightBg, menuHighlightFg Menu item highlight
+ uint32_t buttonFace Button face color
+ uint32_t scrollbarBg, scrollbarFg, scrollbarTrough Scrollbar element colors
+ uint32_t cursorFg, cursorBg Mouse cursor colors
+
ColorIdE
+
Enum for addressing individual colors in ColorSchemeT. Order matches struct field order.
+
Values: ColorDesktopE, ColorWindowFaceE, ColorWindowHighlightE, ColorWindowShadowE, ColorActiveTitleBgE, ColorActiveTitleFgE, ColorInactiveTitleBgE, ColorInactiveTitleFgE, ColorContentBgE, ColorContentFgE, ColorMenuBgE, ColorMenuFgE, ColorMenuHighlightBgE, ColorMenuHighlightFgE, ColorButtonFaceE, ColorScrollbarBgE, ColorScrollbarFgE, ColorScrollbarTroughE, ColorCursorFgE, ColorCursorBgE, ColorCountE.
+
DirtyListT
+
Fixed-capacity list of dirty rectangles. Dynamic array, grows on demand.
+
Field Description
+ ----- -----------
+ RectT *rects Dynamic array of dirty rectangles
+ int32_t count Current number of dirty rects
+ int32_t cap Allocated capacity
+
WindowT
+
Central window object. Each window owns a persistent content backbuffer and receives events through callback function pointers.
+
Field Description
+ ----- -----------
+ int32_t id Unique window identifier
+ int32_t appId Shell app ID (0 = shell itself)
+ int32_t x, y, w, h Outer frame position and dimensions
+ int32_t contentX, contentY, contentW, contentH Content area inset from frame
+ char title[MAX_TITLE_LEN] Window title text (max 128 chars)
+ bool visible, focused, minimized, maximized, resizable, modal Window state flags
+ bool contentDirty true when contentBuf has changed
+ bool needsPaint true until first onPaint call
+ int32_t maxW, maxH Maximum dimensions
+ int32_t preMaxX, preMaxY, preMaxW, preMaxH Saved geometry before maximize
+ uint8_t *contentBuf Per-window content backbuffer
+ int32_t contentPitch Content buffer bytes per row
+ uint8_t *iconData Icon pixel data, NULL if none
+ int32_t iconW, iconH, iconPitch Icon image dimensions and pitch
+ MenuBarT *menuBar Menu bar (NULL if no menus)
+ ScrollbarT *vScroll, *hScroll Scrollbars (NULL if not present)
+ struct WidgetT *widgetRoot Widget tree root (NULL if none)
+ MenuT *contextMenu Right-click context menu
+ AccelTableT *accelTable Keyboard accelerator table
+ void *userData Application-defined data pointer
+
Callbacks:
+
Callback Description
+ -------- -----------
+ onPaint(WindowT *win, RectT *dirtyArea) Content repaint requested
+ onKey(WindowT *win, int32_t key, int32_t mod) Key press
+ onKeyUp(WindowT *win, int32_t scancode, int32_t mod) Key release
+ onMouse(WindowT *win, int32_t x, int32_t y, int32_t btn) Mouse event (content-relative)
+ onResize(WindowT *win, int32_t newW, int32_t newH) Window resized
+ onClose(WindowT *win) Close requested
+ onMenu(WindowT *win, int32_t menuId) Menu item or accelerator activated
+ onScroll(WindowT *win, ScrollbarOrientE orient, int32_t val) Scrollbar value changed
+ onCursorQuery(WindowT *win, int32_t x, int32_t y) Return CURSOR_* for hit position
+ onFocus(WindowT *win) Window gained focus
+ onBlur(WindowT *win) Window lost focus
+
WindowStackT
+
Z-ordered window stack (front-to-back: index count-1 is topmost). Owns system-wide drag/resize/scroll interaction state.
+
Field Description
+ ----- -----------
+ WindowT **windows Dynamic array of window pointers
+ int32_t count, cap Current count and allocated capacity
+ int32_t focusedIdx Stack index of focused window
+ int32_t dragWindow, dragOffX, dragOffY Active drag state
+ int32_t resizeWindow, resizeEdge Active resize state
+ int32_t scrollWindow, scrollOrient, scrollDragOff Active scroll drag state
+
MenuT / MenuItemT / MenuBarT
+
Menu system types. Fixed-size label buffers (MAX_MENU_LABEL = 32). Cascading submenus supported via MenuItemT.subMenu pointer.
+
Field Description
+ ----- -----------
+ MenuItemT.label Item text (supports & accelerator markers)
+ MenuItemT.id Application-defined command ID
+ MenuItemT.type MenuItemNormalE, MenuItemCheckE, or MenuItemRadioE
+ MenuItemT.separator true = horizontal divider line
+ MenuItemT.enabled, checked Item state
+ MenuItemT.subMenu Child menu for cascading (NULL if leaf)
+ MenuBarT.activeIdx Open popup index (-1 = none)
+
ScrollbarT
+
Window-level scrollbar state. Managed by the WM layer, drawn after content.
+
Field Description
+ ----- -----------
+ ScrollbarOrientE orient ScrollbarVerticalE or ScrollbarHorizontalE
+ int32_t min, max Scroll range
+ int32_t value Current position
+ int32_t pageSize Visible portion (for proportional thumb sizing)
+ int32_t x, y, length Computed screen position and track length
+
AccelTableT / AccelEntryT
+
Per-window keyboard accelerator table. Entries are matched against keystrokes in the event loop and fire onMenu(cmdId) on match.
+
Field Description
+ ----- -----------
+ AccelEntryT.key ASCII character or KEY_Fxx constant
+ AccelEntryT.modifiers Bitmask of ACCEL_CTRL, ACCEL_SHIFT, ACCEL_ALT
+ AccelEntryT.cmdId Command ID passed to onMenu
+
VideoModeInfoT
+
Describes an available video mode (enumerated at init).
+
Field Description
+ ----- -----------
+ int32_t w, h Resolution
+ int32_t bpp Bits per pixel
+
CursorT
+
Software-rendered 16x16 cursor using AND/XOR mask encoding.
+
Field Description
+ ----- -----------
+ int32_t width, height Cursor dimensions (always 16x16)
+ int32_t hotX, hotY Hot spot coordinates
+ const uint16_t *andMask AND mask (0 = draw pixel, 1 = transparent)
+ const uint16_t *xorData XOR data (0 = black, 1 = white where AND = 0)
+
Bevel Convenience Macros
+
Macro Description
+ ----- -----------
+ BEVEL_RAISED(cs, bw) Raised bevel style from ColorSchemeT ptr and border width
+ BEVEL_SUNKEN(cs, face, bw) Sunken bevel style with explicit face color
+ BEVEL_TROUGH(cs) 1px sunken trough (for scrollbar tracks)
+ BEVEL_SB_BUTTON(cs) 1px raised scrollbar button
+
Chrome Constants
+
Define Value Description
+ ------ ----- -----------
+ CHROME_BORDER_WIDTH 4 Outer frame border width
+ CHROME_TITLE_HEIGHT 20 Title bar height
+ CHROME_TITLE_PAD 4 Title text padding
+ CHROME_INNER_BORDER 2 Inner chrome border
+ CHROME_MENU_HEIGHT 20 Menu bar height
+ CHROME_TOTAL_TOP 26 Total inset from top of frame to content
+ CHROME_TOTAL_SIDE 6 Total inset from side of frame to content
+ CHROME_TOTAL_BOTTOM 6 Total inset from bottom of frame to content
+ CHROME_CLOSE_BTN_SIZE 16 Close button gadget size
+
Hit Test Constants
+
Define Value Description
+ ------ ----- -----------
+ HIT_CONTENT 0 Content area
+ HIT_TITLE 1 Title bar
+ HIT_CLOSE 2 Close gadget
+ HIT_RESIZE 3 Resize border
+ HIT_MENU 4 Menu bar
+ HIT_VSCROLL 5 Vertical scrollbar
+ HIT_HSCROLL 6 Horizontal scrollbar
+ HIT_MINIMIZE 7 Minimize gadget
+ HIT_MAXIMIZE 8 Maximize gadget
+ HIT_NONE -1 No window hit (desktop)
+
Mouse Button Flags
+
Define Value Description
+ ------ ----- -----------
+ MOUSE_LEFT 1 Left mouse button
+ MOUSE_RIGHT 2 Right mouse button
+ MOUSE_MIDDLE 4 Middle mouse button
+
Accelerator Modifier Flags
+
Define Value Description
+ ------ ----- -----------
+ ACCEL_SHIFT 0x03 Shift key (matches BIOS shift state bits)
+ ACCEL_CTRL 0x04 Ctrl key
+ ACCEL_ALT 0x08 Alt key
+
Extended Key Codes
+
Define Description
+ ------ -----------
+ KEY_F1 .. KEY_F12 Function keys (scancode | 0x100)
+ KEY_INSERT Insert key
+ KEY_DELETE Delete key
+ KEY_HOME Home key
+ KEY_END End key
+ KEY_PGUP Page Up key
+ KEY_PGDN Page Down key
+
Resize Edge Flags
+
Define Value Description
+ ------ ----- -----------
+ RESIZE_NONE 0 No resize edge
+ RESIZE_LEFT 1 Left edge
+ RESIZE_RIGHT 2 Right edge
+ RESIZE_TOP 4 Top edge
+ RESIZE_BOTTOM 8 Bottom edge (combinable via OR for corners)
+
Utility Macros
+
Macro Description
+ ----- -----------
+ DVX_MIN(a, b) Return the smaller of two values
+ DVX_MAX(a, b) Return the larger of two values
+
+
+
dvxCursor.h -- Cursor Definitions
+
dvxCursor.h -- Cursor Definitions
+
Embedded 16x16 mouse cursor bitmaps compiled as static const data. No external cursor files. Uses the standard AND/XOR mask encoding from the IBM VGA hardware cursor spec.
+
Cursor Shape IDs
+
Define Value Description
+ ------ ----- -----------
+ CURSOR_ARROW 0 Standard arrow (hot spot at tip)
+ CURSOR_RESIZE_H 1 Horizontal resize (left/right arrows)
+ CURSOR_RESIZE_V 2 Vertical resize (up/down arrows)
+ CURSOR_RESIZE_DIAG_NWSE 3 NW-SE diagonal resize
+ CURSOR_RESIZE_DIAG_NESW 4 NE-SW diagonal resize
+ CURSOR_BUSY 5 Hourglass (wait)
+ CURSOR_CROSSHAIR 6 Crosshair for placement
+ CURSOR_COUNT 7 Total number of cursor shapes
+
Data
+
dvxCursors[CURSOR_COUNT]
+
Static const array of CursorT structs, indexed by CURSOR_xxx constants. Each entry includes the AND mask, XOR data, dimensions, and hot spot coordinates.
+
+
+
dvxVideo.h -- Layer 1: VESA VBE Video Backend
+
dvxVideo.h -- Layer 1: VESA VBE Video Backend
+
The lowest layer. Responsible for VESA VBE mode negotiation, LFB mapping via DPMI, system RAM backbuffer allocation, pixel format discovery, and color packing. LFB-only design: bank switching is deliberately unsupported.
+
videoInit
+
int32_t videoInit(DisplayT *d, int32_t requestedW, int32_t requestedH, int32_t preferredBpp);
+
Probe VBE for a mode matching the requested resolution and depth, enable it, map the LFB into DPMI linear address space, and allocate a system RAM backbuffer. preferredBpp is a hint; the closest available depth is used if an exact match is not found.
+
Parameter Description
+ --------- -----------
+ d Display context to initialize
+ requestedW/H Desired screen resolution
+ preferredBpp Preferred bits per pixel (8, 15, 16, or 32)
+
Returns: 0 on success, negative on failure.
+
videoShutdown
+
void videoShutdown(DisplayT *d);
+
Restore VGA text mode (mode 3), unmap the LFB, and free the backbuffer. Safe to call even if videoInit() failed.
+
Parameter Description
+ --------- -----------
+ d Display context to shut down
+
packColor
+
uint32_t packColor(const DisplayT *d, uint8_t r, uint8_t g, uint8_t b);
+
Pack an RGB triplet into the display's native pixel format. For direct-color modes (15/16/32 bpp), returns a packed pixel value using shift/mask fields. For 8-bit mode, returns the nearest palette index via Euclidean distance in RGB space.
+
Parameter Description
+ --------- -----------
+ d Display context (provides pixel format)
+ r, g, b Color components (0-255)
+
Returns: Native pixel value suitable for direct framebuffer write.
+
setClipRect
+
void setClipRect(DisplayT *d, int32_t x, int32_t y, int32_t w, int32_t h);
+
Set the clip rectangle on the display. All subsequent draw operations clip to this rectangle. The caller must save and restore the clip rect around scoped operations.
+
Parameter Description
+ --------- -----------
+ d Display context
+ x, y, w, h Clip rectangle in screen coordinates
+
resetClipRect
+
void resetClipRect(DisplayT *d);
+
Reset the clip rectangle to the full display dimensions.
+
Parameter Description
+ --------- -----------
+ d Display context
+
+
+
dvxDraw.h -- Layer 2: Drawing Primitives
+
dvxDraw.h -- Layer 2: Drawing Primitives
+
All 2D drawing operations: rectangle fills, bitmap blits, text rendering, bevels, lines, and cursor rendering. Every function draws into the display's backbuffer and clips to the current clip rectangle. This layer is stateless beyond the clip rect on DisplayT.
+
drawInit
+
void drawInit(BlitOpsT *ops, const DisplayT *d);
+
Populate a BlitOpsT with the correct span functions for the display's pixel depth. Must be called once after videoInit().
+
Parameter Description
+ --------- -----------
+ ops BlitOpsT to populate
+ d Initialized display context
+
rectFill
+
void rectFill(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
+
Fill a rectangle with a solid color. Clips to the display clip rect. Workhorse for backgrounds, window fills, and clear operations.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ x, y, w, h Rectangle to fill
+ color Packed pixel color
+
rectCopy
+
void rectCopy(DisplayT *d, const BlitOpsT *ops, int32_t dstX, int32_t dstY, const uint8_t *srcBuf, int32_t srcPitch, int32_t srcX, int32_t srcY, int32_t w, int32_t h);
+
Copy a rectangle from an arbitrary source buffer into the backbuffer. Used to blit per-window content buffers during compositing.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ dstX, dstY Destination position in backbuffer
+ srcBuf Source pixel buffer
+ srcPitch Source buffer bytes per row
+ srcX, srcY Origin within source buffer
+ w, h Rectangle dimensions to copy
+
rectCopyGrayscale
+
void rectCopyGrayscale(DisplayT *d, const BlitOpsT *ops, int32_t dstX, int32_t dstY, const uint8_t *srcBuf, int32_t srcPitch, int32_t srcX, int32_t srcY, int32_t w, int32_t h);
+
Copy a rectangle with grayscale conversion. Each pixel's RGB is converted to luminance (0.299R + 0.587G + 0.114B) for a disabled/grayed appearance.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ dstX, dstY Destination position
+ srcBuf, srcPitch Source buffer and pitch
+ srcX, srcY Source origin
+ w, h Rectangle dimensions
+
drawBevel
+
void drawBevel(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, int32_t h, const BevelStyleT *style);
+
Draw a beveled frame. Top/left edges in highlight color, bottom/right in shadow. Interior filled with face color if non-zero.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ x, y, w, h Outer bevel rectangle
+ style Bevel colors and width
+
drawChar
+
int32_t drawChar(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, char ch, uint32_t fg, uint32_t bg, bool opaque);
+
Draw a single character glyph. When opaque is true, the background fills the entire cell; when false, only foreground pixels are drawn (transparent background).
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ font Bitmap font
+ x, y Character position
+ ch Character to draw
+ fg, bg Foreground and background packed colors
+ opaque true = fill background, false = transparent
+
Returns: Advance width (always charWidth).
+
drawText
+
void drawText(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, const char *text, uint32_t fg, uint32_t bg, bool opaque);
+
Draw a null-terminated string. Calls drawChar per character.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ font Bitmap font
+ x, y Start position
+ text Null-terminated string
+ fg, bg Foreground and background packed colors
+ opaque true = fill background, false = transparent
+
drawTextN
+
void drawTextN(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, const char *text, int32_t count, uint32_t fg, uint32_t bg, bool opaque);
+
Optimized batch text rendering for a known character count. Computes clip bounds once, fills background in a single rectFill, then overlays glyph foreground pixels. Significantly faster than per-character drawChar for long runs (terminal rows, list items).
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ font Bitmap font
+ x, y Start position
+ text Character buffer (not required to be null-terminated)
+ count Number of characters to render
+ fg, bg Foreground and background packed colors
+ opaque true = fill background, false = transparent
+
textWidth
+
int32_t textWidth(const BitmapFontT *font, const char *text);
+
Return the pixel width of a null-terminated string (strlen(text) * charWidth).
+
Parameter Description
+ --------- -----------
+ font Bitmap font
+ text Null-terminated string
+
Returns: Width in pixels.
+
accelParse
+
char accelParse(const char *text);
+
Scan text for an & prefix and return the following character as a lowercase accelerator key. "&File" returns 'f', "E&xit" returns 'x'.
+
Parameter Description
+ --------- -----------
+ text Text with optional & accelerator marker
+
Returns: Lowercase accelerator character, or 0 if none.
+
drawTextAccel
+
void drawTextAccel(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, const char *text, uint32_t fg, uint32_t bg, bool opaque);
+
Draw text with & accelerator markers. The character after & is drawn underlined to indicate the keyboard shortcut. && produces a literal &. Used for menu items and button labels.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ font Bitmap font
+ x, y Start position
+ text Text with & markers
+ fg, bg Foreground and background packed colors
+ opaque true = fill background, false = transparent
+
textWidthAccel
+
int32_t textWidthAccel(const BitmapFontT *font, const char *text);
+
Measure text width excluding & markers (so "&File" measures as 4 chars).
+
Parameter Description
+ --------- -----------
+ font Bitmap font
+ text Text with optional & markers
+
Returns: Width in pixels.
+
drawMaskedBitmap
+
void drawMaskedBitmap(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *andMask, const uint16_t *xorData, uint32_t fgColor, uint32_t bgColor);
+
Draw a 1-bit AND/XOR masked bitmap. Used for software-rendered mouse cursors.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ x, y Screen position
+ w, h Bitmap dimensions
+ andMask AND transparency mask (one uint16_t per row)
+ xorData XOR color data
+ fgColor, bgColor Cursor foreground and background packed colors
+
drawTermRow
+
void drawTermRow(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, int32_t x, int32_t y, int32_t cols, const uint8_t *lineData, const uint32_t *palette, bool blinkVisible, int32_t cursorCol);
+
Render an entire row of terminal character cells (ch/attr byte pairs) in a single pass. Colors looked up from a 16-color palette. Attribute bit 7 controls blink.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ font Bitmap font
+ x, y Row start position
+ cols Number of columns
+ lineData Packed ch/attr byte pairs (2 bytes per cell)
+ palette 16-entry packed color palette
+ blinkVisible false = hide blinking characters
+ cursorCol Column for inverted text cursor (-1 = none)
+
drawFocusRect
+
void drawFocusRect(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
+
Draw a 1px dotted rectangle (alternating pixels). Used for keyboard focus indicators, matching the Windows 3.x focus rectangle convention.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ x, y, w, h Focus rectangle bounds
+ color Dot color (packed)
+
drawHLine
+
void drawHLine(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t w, uint32_t color);
+
Draw a horizontal line (1px tall).
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ x, y Start position
+ w Width in pixels
+ color Packed pixel color
+
drawVLine
+
void drawVLine(DisplayT *d, const BlitOpsT *ops, int32_t x, int32_t y, int32_t h, uint32_t color);
+
Draw a vertical line (1px wide).
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ x, y Start position
+ h Height in pixels
+ color Packed pixel color
+
+
+
dvxComp.h -- Layer 3: Dirty Rectangle Compositor
+
dvxComp.h -- Layer 3: Dirty Rectangle Compositor
+
Tracks changed screen regions and ensures only dirty regions are redrawn and flushed to video memory. The compositing pipeline: mark dirty, merge overlapping rects, redraw desktop + windows (back-to-front, painter's algorithm), flush to LFB.
+
dirtyListInit
+
void dirtyListInit(DirtyListT *dl);
+
Zero the dirty rect count. Called at the start of each frame.
+
Parameter Description
+ --------- -----------
+ dl Dirty list to initialize
+
dirtyListAdd
+
void dirtyListAdd(DirtyListT *dl, int32_t x, int32_t y, int32_t w, int32_t h);
+
Enqueue a dirty rectangle. Grows dynamically; triggers merge at a soft capacity limit.
+
Parameter Description
+ --------- -----------
+ dl Dirty list
+ x, y, w, h Dirty rectangle in screen coordinates
+
dirtyListMerge
+
void dirtyListMerge(DirtyListT *dl);
+
Consolidate the dirty list by merging overlapping and adjacent rects. Uses iterative pairwise merge: if combining two rects does not increase total area beyond a threshold, they are merged. Reduces compositor passes and LFB flush operations.
+
Parameter Description
+ --------- -----------
+ dl Dirty list to merge
+
dirtyListClear
+
void dirtyListClear(DirtyListT *dl);
+
Reset the dirty list to empty (sets count to 0).
+
Parameter Description
+ --------- -----------
+ dl Dirty list to clear
+
flushRect
+
void flushRect(DisplayT *d, const RectT *r);
+
Copy a rectangle from the system RAM backbuffer to the LFB (video memory). This is the only place the real framebuffer is written. Uses platform-specific fast copy (rep movsd on DOS) for each scanline.
+
Parameter Description
+ --------- -----------
+ d Display context
+ r Rectangle to flush
+
rectIntersect
+
bool rectIntersect(const RectT *a, const RectT *b, RectT *result);
+
Compute the intersection of two rectangles.
+
Parameter Description
+ --------- -----------
+ a, b Input rectangles
+ result Output: intersection rectangle (valid only when return is true)
+
Returns: true if the rectangles overlap, false if disjoint.
+
rectIsEmpty
+
bool rectIsEmpty(const RectT *r);
+
Test whether a rectangle has zero or negative area.
+
Parameter Description
+ --------- -----------
+ r Rectangle to test
+
Returns: true if w <= 0 or h <= 0.
+
+
+
dvxWm.h -- Layer 4: Window Manager
+
dvxWm.h -- Layer 4: Window Manager
+
Manages the window lifecycle, Z-order stack, chrome drawing, hit testing, and interactive operations (drag, resize, scroll). The WM owns window geometry and chrome; content is owned by the application via callbacks or the widget system.
+
Initialization
+
wmInit
+
void wmInit(WindowStackT *stack);
+
Zero the window stack. Must be called before any other WM function.
+
Parameter Description
+ --------- -----------
+ stack Window stack to initialize
+
Window Lifecycle
+
wmCreateWindow
+
WindowT *wmCreateWindow(WindowStackT *stack, DisplayT *d, const char *title, int32_t x, int32_t y, int32_t w, int32_t h, bool resizable);
+
Allocate a new window, initialize its geometry and content buffer, and push it to the top of the Z-order stack. Returns with all callbacks NULL; the caller should set onPaint/onKey/etc. before the next event loop iteration.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ d Display context
+ title Window title text
+ x, y Initial position
+ w, h Initial outer frame dimensions
+ resizable true = allow user resize
+
Returns: Pointer to new WindowT, or NULL on failure.
+
wmDestroyWindow
+
void wmDestroyWindow(WindowStackT *stack, WindowT *win);
+
Free the window's content buffer and all attached resources (menu bar, scrollbars, widget tree), remove it from the stack, and dirty the vacated region.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ win Window to destroy
+
Z-Order and Focus
+
wmRaiseWindow
+
void wmRaiseWindow(WindowStackT *stack, DirtyListT *dl, int32_t idx);
+
Move window at stack index idx to the top of the Z-order. Dirties both old and new top positions so overlapping windows get repainted.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list for repaint marking
+ idx Stack index of window to raise
+
wmSetFocus
+
void wmSetFocus(WindowStackT *stack, DirtyListT *dl, int32_t idx);
+
Transfer keyboard focus to the window at stack index idx. Unfocuses the previously focused window and dirties both title bars.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ idx Stack index of window to focus
+
Geometry
+
wmUpdateContentRect
+
void wmUpdateContentRect(WindowT *win);
+
Recompute contentX/Y/W/H from the window's outer frame dimensions, accounting for chrome borders, title bar, menu bar, and scrollbars. Must be called after any change to frame size or chrome configuration.
+
Parameter Description
+ --------- -----------
+ win Window to update
+
wmReallocContentBuf
+
int32_t wmReallocContentBuf(WindowT *win, const DisplayT *d);
+
Reallocate the per-window content backbuffer to match current contentW/H. Old buffer contents are lost; caller should trigger a full repaint via onPaint afterward.
+
Parameter Description
+ --------- -----------
+ win Window to reallocate
+ d Display context (for bytes-per-pixel)
+
Returns: 0 on success, -1 on allocation failure.
+
wmMinWindowSize
+
void wmMinWindowSize(const WindowT *win, int32_t *minW, int32_t *minH);
+
Get the minimum window size. Accounts for chrome, gadgets, and menu bar.
+
Parameter Description
+ --------- -----------
+ win Window
+ minW, minH Output: minimum width and height
+
Menu Bar
+
wmAddMenuBar
+
MenuBarT *wmAddMenuBar(WindowT *win);
+
Allocate and attach a menu bar to a window. Adjusts content area to make room (CHROME_MENU_HEIGHT pixels). One menu bar per window.
+
Parameter Description
+ --------- -----------
+ win Window to add menu bar to
+
Returns: Pointer to the new MenuBarT.
+
wmDestroyMenuBar
+
void wmDestroyMenuBar(WindowT *win);
+
Free the menu bar and reclaim the content area.
+
Parameter Description
+ --------- -----------
+ win Window to remove menu bar from
+
wmAddMenu
+
MenuT *wmAddMenu(MenuBarT *bar, const char *label);
+
Append a dropdown menu to the menu bar. The label supports & accelerator markers (e.g. "&File").
+
Parameter Description
+ --------- -----------
+ bar Menu bar
+ label Menu label text
+
Returns: Pointer to the new MenuT to populate with items.
+
wmAddMenuItem
+
void wmAddMenuItem(MenuT *menu, const char *label, int32_t id);
+
Append a clickable item to a menu. The id is passed to the window's onMenu callback when selected.
+
Parameter Description
+ --------- -----------
+ menu Menu to append to
+ label Item label (supports & markers)
+ id Application-defined command ID
+
wmAddMenuCheckItem
+
void wmAddMenuCheckItem(MenuT *menu, const char *label, int32_t id, bool checked);
+
Add a checkbox-style menu item. Check state toggles on click; rendered with a checkmark glyph.
+
Parameter Description
+ --------- -----------
+ menu Menu to append to
+ label Item label
+ id Command ID
+ checked Initial checked state
+
wmAddMenuRadioItem
+
void wmAddMenuRadioItem(MenuT *menu, const char *label, int32_t id, bool checked);
+
Add a radio-style menu item. Radio groups are defined implicitly by consecutive radio items; selecting one unchecks the others in the group.
+
Parameter Description
+ --------- -----------
+ menu Menu to append to
+ label Item label
+ id Command ID
+ checked Initial checked state
+
wmAddMenuSeparator
+
void wmAddMenuSeparator(MenuT *menu);
+
Insert a horizontal separator line. Separators are not interactive.
+
Parameter Description
+ --------- -----------
+ menu Menu to append separator to
+
wmMenuItemIsChecked
+
bool wmMenuItemIsChecked(MenuBarT *bar, int32_t id);
+
Query the checked state of a menu item by command ID. Searches all menus in the bar.
+
Parameter Description
+ --------- -----------
+ bar Menu bar
+ id Command ID to query
+
Returns: true if checked.
+
wmMenuItemSetChecked
+
void wmMenuItemSetChecked(MenuBarT *bar, int32_t id, bool checked);
+
Set the checked state of a menu item by command ID. For radio items, setting checked=true also unchecks other radio items in the same group.
+
Parameter Description
+ --------- -----------
+ bar Menu bar
+ id Command ID
+ checked New checked state
+
wmMenuItemSetEnabled
+
void wmMenuItemSetEnabled(MenuBarT *bar, int32_t id, bool enabled);
+
Enable or disable a menu item by command ID.
+
Parameter Description
+ --------- -----------
+ bar Menu bar
+ id Command ID
+ enabled true = enabled, false = grayed out
+
wmAddSubMenu
+
MenuT *wmAddSubMenu(MenuT *parentMenu, const char *label);
+
Create a cascading submenu attached to a parent menu. The child MenuT is heap-allocated and freed when the parent window is destroyed.
+
Parameter Description
+ --------- -----------
+ parentMenu Parent menu to attach submenu to
+ label Submenu label text
+
Returns: Pointer to the child MenuT, or NULL on allocation failure.
+
wmCreateMenu
+
MenuT *wmCreateMenu(void);
+
Allocate a heap-resident MenuT for use as a context menu (right-click). Unlike menu bar menus, context menus are standalone allocations. Free with wmFreeMenu().
+
Returns: Pointer to the new MenuT.
+
wmFreeMenu
+
void wmFreeMenu(MenuT *menu);
+
Free a standalone menu allocated with wmCreateMenu(). Also frees any heap-allocated submenu children recursively.
+
Parameter Description
+ --------- -----------
+ menu Menu to free
+
Scrollbars
+
wmAddVScrollbar
+
ScrollbarT *wmAddVScrollbar(WindowT *win, int32_t min, int32_t max, int32_t pageSize);
+
Attach a vertical scrollbar to the right edge of the window's content area. Shrinks contentW by SCROLLBAR_WIDTH pixels.
+
Parameter Description
+ --------- -----------
+ win Window
+ min, max Scroll value range
+ pageSize Visible portion (controls thumb size)
+
Returns: Pointer to the new ScrollbarT.
+
wmAddHScrollbar
+
ScrollbarT *wmAddHScrollbar(WindowT *win, int32_t min, int32_t max, int32_t pageSize);
+
Attach a horizontal scrollbar to the bottom edge. Shrinks contentH by SCROLLBAR_WIDTH pixels.
+
Parameter Description
+ --------- -----------
+ win Window
+ min, max Scroll value range
+ pageSize Visible portion
+
Returns: Pointer to the new ScrollbarT.
+
Drawing
+
wmDrawChrome
+
void wmDrawChrome(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors, WindowT *win, const RectT *clipTo);
+
Draw the window frame: outer bevel, title bar with text, close/minimize/maximize gadgets, and menu bar if present. Drawing is clipped to the intersection with clipTo.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ font Bitmap font for title text
+ colors Color scheme
+ win Window to draw chrome for
+ clipTo Dirty rectangle to clip drawing to
+
wmDrawContent
+
void wmDrawContent(DisplayT *d, const BlitOpsT *ops, WindowT *win, const RectT *clipTo);
+
Blit the window's content backbuffer into the display backbuffer, clipped to the dirty rect. Pure copy operation (no drawing).
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ win Window
+ clipTo Dirty rectangle
+
wmDrawScrollbars
+
void wmDrawScrollbars(DisplayT *d, const BlitOpsT *ops, const ColorSchemeT *colors, WindowT *win, const RectT *clipTo);
+
Draw scrollbars (track, arrows, proportional thumb) for a window. Drawn after content so scrollbars overlay the content area edge.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ colors Color scheme
+ win Window
+ clipTo Dirty rectangle
+
wmDrawMinimizedIcons
+
void wmDrawMinimizedIcons(DisplayT *d, const BlitOpsT *ops, const ColorSchemeT *colors, const WindowStackT *stack, const RectT *clipTo);
+
Draw icons for all minimized windows along the bottom of the screen. Each icon shows a scaled preview of the window's content with a beveled border.
+
Parameter Description
+ --------- -----------
+ d Display context
+ ops Blit operations vtable
+ colors Color scheme
+ stack Window stack
+ clipTo Dirty rectangle
+
Hit Testing
+
wmHitTest
+
int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hitPart);
+
Determine which window and chrome region is under the given screen coordinates. Iterates front-to-back (highest Z first) so the topmost window wins.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ mx, my Screen coordinates
+ hitPart Output: HIT_CONTENT, HIT_TITLE, HIT_CLOSE, etc.
+
Returns: Stack index of hit window, or -1 for desktop.
+
wmResizeEdgeHit
+
int32_t wmResizeEdgeHit(const WindowT *win, int32_t mx, int32_t my);
+
Determine which edge(s) of a window's border zone are targeted for resize.
+
Parameter Description
+ --------- -----------
+ win Window
+ mx, my Screen coordinates
+
Returns: Bitmask of RESIZE_LEFT / RESIZE_RIGHT / RESIZE_TOP / RESIZE_BOTTOM.
+
wmMinimizedIconHit
+
int32_t wmMinimizedIconHit(const WindowStackT *stack, const DisplayT *d, int32_t mx, int32_t my);
+
Hit-test minimized icons at the bottom of the screen.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ d Display context
+ mx, my Screen coordinates
+
Returns: Stack index of the minimized window, or -1.
+
Drag and Resize
+
wmDragBegin
+
void wmDragBegin(WindowStackT *stack, int32_t idx, int32_t mouseX, int32_t mouseY);
+
Begin a window drag operation. Records the mouse offset from the window origin.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ idx Stack index of window to drag
+ mouseX/Y Current mouse position
+
wmDragMove
+
void wmDragMove(WindowStackT *stack, DirtyListT *dl, int32_t mouseX, int32_t mouseY, int32_t screenW, int32_t screenH);
+
Update window position during an active drag. Dirties both old and new positions.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ mouseX/Y Current mouse position
+ screenW/H Screen dimensions (for clamping)
+
wmDragEnd
+
void wmDragEnd(WindowStackT *stack);
+
End the current drag operation. Clears dragWindow state.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+
wmResizeBegin
+
void wmResizeBegin(WindowStackT *stack, int32_t idx, int32_t edge, int32_t mouseX, int32_t mouseY);
+
Begin a window resize operation. Records which edge(s) are being dragged.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ idx Stack index
+ edge Bitmask of RESIZE_xxx flags
+ mouseX/Y Current mouse position
+
wmResizeMove
+
void wmResizeMove(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, int32_t *mouseX, int32_t *mouseY);
+
Update window dimensions during an active resize. Enforces MIN_WINDOW_W/H and maxW/maxH constraints. Reallocates content buffer and calls onResize if size changed. mouseX/mouseY are in/out: clamped on return for cursor warping.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ d Display context
+ mouseX/Y In/out: mouse position (clamped on return)
+
wmResizeEnd
+
void wmResizeEnd(WindowStackT *stack);
+
End the current resize operation. Clears resizeWindow state.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+
Scrollbar Interaction
+
wmScrollbarClick
+
void wmScrollbarClick(WindowStackT *stack, DirtyListT *dl, int32_t idx, int32_t orient, int32_t mx, int32_t my);
+
Handle an initial click on a scrollbar. Determines what was hit (arrows, trough, or thumb) and either adjusts the value immediately or begins a thumb drag.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ idx Stack index of window
+ orient SCROLL_VERTICAL or SCROLL_HORIZONTAL
+ mx, my Click screen coordinates
+
wmScrollbarDrag
+
void wmScrollbarDrag(WindowStackT *stack, DirtyListT *dl, int32_t mx, int32_t my);
+
Update the scroll value during an active thumb drag. Maps mouse position along the track to a proportional scroll value.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ mx, my Current mouse position
+
wmScrollbarEnd
+
void wmScrollbarEnd(WindowStackT *stack);
+
End an active scrollbar thumb drag.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+
Minimize / Maximize / Restore
+
wmMaximize
+
void wmMaximize(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, WindowT *win);
+
Maximize a window. Saves current geometry, then expands to screen or maxW/maxH bounds.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ d Display context
+ win Window to maximize
+
wmMinimize
+
void wmMinimize(WindowStackT *stack, DirtyListT *dl, WindowT *win);
+
Minimize a window. Hides the window and shows an icon at the bottom of the screen.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ win Window to minimize
+
wmRestore
+
void wmRestore(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, WindowT *win);
+
Restore a maximized window to its pre-maximize geometry.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ d Display context
+ win Maximized window to restore
+
wmRestoreMinimized
+
void wmRestoreMinimized(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, WindowT *win);
+
Restore a minimized window (show it again and remove the icon).
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ dl Dirty list
+ d Display context
+ win Minimized window to restore
+
Minimized Icon Layout
+
wmMinimizedIconPos
+
void wmMinimizedIconPos(const DisplayT *d, int32_t index, int32_t *x, int32_t *y);
+
Compute the screen position of a minimized icon by ordinal index. Icons wrap into rows from bottom to top when the screen fills up.
+
Parameter Description
+ --------- -----------
+ d Display context
+ index Ordinal index of the minimized icon
+ x, y Output: screen position
+
wmMinimizedIconRect
+
void wmMinimizedIconRect(const WindowStackT *stack, const DisplayT *d, int32_t *y, int32_t *h);
+
Compute the screen rect covering all minimized icon rows. Used to dirty the icon area when windows are minimized or restored.
+
Parameter Description
+ --------- -----------
+ stack Window stack
+ d Display context
+ y, h Output: vertical extent of icon area
+
Miscellaneous
+
wmSetTitle
+
void wmSetTitle(WindowT *win, DirtyListT *dl, const char *title);
+
Set the window title and dirty the title bar for repaint.
+
Parameter Description
+ --------- -----------
+ win Window
+ dl Dirty list
+ title New title text
+
wmSetIcon
+
int32_t wmSetIcon(WindowT *win, const char *path, const DisplayT *d);
+
Load an icon image for a window from a file. Converts to display pixel format.
+
Parameter Description
+ --------- -----------
+ win Window
+ path Image file path
+ d Display context
+
Returns: 0 on success, -1 on failure.
+
+
+
dvxApp.h -- Layer 5: Application API
+
dvxApp.h -- Layer 5: Application API
+
The topmost layer and the public-facing API. Aggregates all lower layers into a single AppContextT. Applications interact exclusively through dvx*() functions and window callbacks. The event loop follows a cooperative model: poll, dispatch, composite, yield.
+
AppContextT
+
Single monolithic context that owns all GUI state. Contains the display, window stack, dirty list, blit ops, font, color scheme, popup state, cursor state, mouse/keyboard state, tooltip state, wallpaper buffer, video mode list, and various configuration fields. Allocated on the caller's stack or statically.
+
Initialization and Shutdown
+
dvxInit
+
int32_t dvxInit(AppContextT *ctx, int32_t requestedW, int32_t requestedH, int32_t preferredBpp);
+
Initialize the entire GUI stack: video mode, input devices, font, color scheme, cursor shapes, and internal state. Single entry point for starting a DVX application.
+
Parameter Description
+ --------- -----------
+ ctx Application context to initialize
+ requestedW/H Desired screen resolution
+ preferredBpp Preferred bits per pixel
+
Returns: 0 on success, negative on failure.
+
dvxShutdown
+
void dvxShutdown(AppContextT *ctx);
+
Tear down the GUI stack in reverse order: destroy all windows, restore text mode, release input devices. Safe to call after a failed dvxInit().
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
dvxChangeVideoMode
+
int32_t dvxChangeVideoMode(AppContextT *ctx, int32_t requestedW, int32_t requestedH, int32_t preferredBpp);
+
Switch to a new video mode live. Reallocates the backbuffer, all window content buffers, repacks colors, rescales wallpaper, and repositions off-screen windows.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ requestedW/H New resolution
+ preferredBpp New bits per pixel
+
Returns: 0 on success, -1 on failure (old mode restored).
+
Event Loop
+
dvxRun
+
void dvxRun(AppContextT *ctx);
+
Enter the main event loop. Polls input, dispatches events, composites dirty regions, and yields on each iteration. Returns when ctx->running becomes false.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
dvxUpdate
+
bool dvxUpdate(AppContextT *ctx);
+
Process exactly one frame of the event loop. For applications that integrate the GUI into their own main loop (e.g. polling serial ports between frames).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
Returns: false when the GUI wants to exit.
+
dvxQuit
+
void dvxQuit(AppContextT *ctx);
+
Request exit from the main event loop (sets ctx->running = false).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
Window Management
+
dvxCreateWindow
+
WindowT *dvxCreateWindow(AppContextT *ctx, const char *title, int32_t x, int32_t y, int32_t w, int32_t h, bool resizable);
+
Create a window at an explicit screen position. The window is raised to the top, focused, and its entire region is dirtied.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ title Window title
+ x, y Screen position
+ w, h Outer frame dimensions
+ resizable true = allow user resize
+
Returns: Pointer to new WindowT.
+
dvxCreateWindowCentered
+
WindowT *dvxCreateWindowCentered(AppContextT *ctx, const char *title, int32_t w, int32_t h, bool resizable);
+
Convenience wrapper that centers the window on screen.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ title Window title
+ w, h Outer frame dimensions
+ resizable true = allow user resize
+
Returns: Pointer to new WindowT.
+
dvxDestroyWindow
+
void dvxDestroyWindow(AppContextT *ctx, WindowT *win);
+
Destroy a window, free all its resources, and dirty its former region.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to destroy
+
dvxRaiseWindow
+
void dvxRaiseWindow(AppContextT *ctx, WindowT *win);
+
Raise a window to the top of the Z-order and give it focus.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to raise
+
dvxFitWindow
+
void dvxFitWindow(AppContextT *ctx, WindowT *win);
+
Resize a window to exactly fit its widget tree's computed minimum size (plus chrome). Used for dialog boxes and fixed-layout windows.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to fit
+
dvxFitWindowW
+
void dvxFitWindowW(AppContextT *ctx, WindowT *win);
+
Resize window width only to fit widget tree's minimum width (plus chrome).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to fit
+
dvxFitWindowH
+
void dvxFitWindowH(AppContextT *ctx, WindowT *win);
+
Resize window height only to fit widget tree's minimum height (plus chrome).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to fit
+
dvxResizeWindow
+
void dvxResizeWindow(AppContextT *ctx, WindowT *win, int32_t newW, int32_t newH);
+
Programmatically resize a window to the specified outer dimensions.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to resize
+ newW, newH New outer frame dimensions
+
dvxMinimizeWindow
+
void dvxMinimizeWindow(AppContextT *ctx, WindowT *win);
+
Minimize a window (show as icon at bottom of screen).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to minimize
+
dvxMaximizeWindow
+
void dvxMaximizeWindow(AppContextT *ctx, WindowT *win);
+
Maximize a window (expand to fill screen or maxW/maxH).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to maximize
+
dvxHideWindow
+
void dvxHideWindow(AppContextT *ctx, WindowT *win);
+
Hide a window without destroying it. Marks the exposed region dirty.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to hide
+
dvxShowWindow
+
void dvxShowWindow(AppContextT *ctx, WindowT *win);
+
Show a previously hidden window. Marks its region dirty for repaint.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to show
+
Invalidation
+
dvxInvalidateRect
+
void dvxInvalidateRect(AppContextT *ctx, WindowT *win, int32_t x, int32_t y, int32_t w, int32_t h);
+
Mark a sub-region of a window's content area as needing repaint. Coordinates are relative to the content area, not the screen. Triggers onPaint during the next composite pass.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window
+ x, y, w, h Dirty rectangle in content-relative coordinates
+
dvxInvalidateWindow
+
void dvxInvalidateWindow(AppContextT *ctx, WindowT *win);
+
Mark the entire window content area as dirty.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to invalidate
+
Window Properties
+
dvxSetTitle
+
void dvxSetTitle(AppContextT *ctx, WindowT *win, const char *title);
+
Set a window's title text and dirty the title bar.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window
+ title New title text
+
dvxSetWindowIcon
+
int32_t dvxSetWindowIcon(AppContextT *ctx, WindowT *win, const char *path);
+
Load an icon for a window from an image file.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window
+ path Image file path
+
Returns: 0 on success, -1 on failure.
+
dvxSetBusy
+
void dvxSetBusy(AppContextT *ctx, bool busy);
+
Set or clear busy state. While busy, the hourglass cursor is shown and input is blocked.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ busy true = show hourglass, false = normal
+
Accessors
+
dvxGetFont
+
const BitmapFontT *dvxGetFont(const AppContextT *ctx);
+
Get a pointer to the default font.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
Returns: Pointer to the active BitmapFontT.
+
dvxGetColors
+
const ColorSchemeT *dvxGetColors(const AppContextT *ctx);
+
Get a pointer to the current color scheme.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
Returns: Pointer to the active ColorSchemeT.
+
dvxGetDisplay
+
DisplayT *dvxGetDisplay(AppContextT *ctx);
+
Get a pointer to the display context.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
Returns: Pointer to the DisplayT.
+
dvxGetBlitOps
+
const BlitOpsT *dvxGetBlitOps(const AppContextT *ctx);
+
Get a pointer to the blit operations vtable.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
Returns: Pointer to the active BlitOpsT.
+
dvxGetVideoModes
+
const VideoModeInfoT *dvxGetVideoModes(const AppContextT *ctx, int32_t *count);
+
Return the list of available video modes enumerated at init time.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ count Output: number of mode entries
+
Returns: Pointer to the VideoModeInfoT array.
+
Color Scheme
+
dvxSetColor
+
void dvxSetColor(AppContextT *ctx, ColorIdE id, uint8_t r, uint8_t g, uint8_t b);
+
Set a single color by ID. Repacks to native pixel format and invalidates the entire screen.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ id Color ID (ColorIdE)
+ r, g, b RGB values (0-255)
+
dvxGetColor
+
void dvxGetColor(const AppContextT *ctx, ColorIdE id, uint8_t *r, uint8_t *g, uint8_t *b);
+
Get a color's RGB values by ID.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ id Color ID (ColorIdE)
+ r, g, b Output: RGB values
+
dvxApplyColorScheme
+
void dvxApplyColorScheme(AppContextT *ctx);
+
Apply all colors from ctx->colorRgb[] at once (repack + full repaint).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
dvxResetColorScheme
+
void dvxResetColorScheme(AppContextT *ctx);
+
Reset all colors to the built-in defaults and repaint.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
dvxLoadTheme
+
bool dvxLoadTheme(AppContextT *ctx, const char *filename);
+
Load a theme file (INI format with [colors] section) and apply it.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ filename Path to theme INI file
+
Returns: true on success.
+
dvxSaveTheme
+
bool dvxSaveTheme(const AppContextT *ctx, const char *filename);
+
Save the current color scheme to a theme file.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ filename Output file path
+
Returns: true on success.
+
dvxColorName
+
const char *dvxColorName(ColorIdE id);
+
Return the INI key name for a color ID (e.g. "desktop", "windowFace").
+
Parameter Description
+ --------- -----------
+ id Color ID
+
Returns: Static string.
+
dvxColorLabel
+
const char *dvxColorLabel(ColorIdE id);
+
Return a human-readable display label (e.g. "Desktop", "Cursor Color").
+
Parameter Description
+ --------- -----------
+ id Color ID
+
Returns: Static string.
+
Wallpaper
+
dvxSetWallpaper
+
bool dvxSetWallpaper(AppContextT *ctx, const char *path);
+
Load and apply a wallpaper image using the current wallpaperMode (stretch/tile/center). Pass NULL to clear the wallpaper.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ path Image file path, or NULL to clear
+
Returns: true on success.
+
dvxSetWallpaperMode
+
void dvxSetWallpaperMode(AppContextT *ctx, WallpaperModeE mode);
+
Change the wallpaper display mode and re-render. No effect if no wallpaper is loaded.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ mode WallpaperStretchE, WallpaperTileE, or WallpaperCenterE
+
Mouse Configuration
+
dvxSetMouseConfig
+
void dvxSetMouseConfig(AppContextT *ctx, int32_t wheelDir, int32_t dblClickMs, int32_t accelThreshold);
+
Configure mouse behavior.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ wheelDir 1 = normal, -1 = reversed
+ dblClickMs Double-click speed in milliseconds (e.g. 500)
+ accelThreshold Double-speed threshold in mickeys/sec (0 = don't change)
+
Accelerators
+
dvxCreateAccelTable
+
AccelTableT *dvxCreateAccelTable(void);
+
Allocate a new accelerator table. Attach to a window via win->accelTable.
+
Returns: Pointer to new AccelTableT.
+
dvxFreeAccelTable
+
void dvxFreeAccelTable(AccelTableT *table);
+
Free an accelerator table and its entries.
+
Parameter Description
+ --------- -----------
+ table Table to free
+
dvxAddAccel
+
void dvxAddAccel(AccelTableT *table, int32_t key, int32_t modifiers, int32_t cmdId);
+
Register a keyboard shortcut. On match, fires the window's onMenu callback with cmdId.
+
Parameter Description
+ --------- -----------
+ table Accelerator table
+ key ASCII character or KEY_Fxx constant
+ modifiers Bitmask of ACCEL_CTRL / ACCEL_SHIFT / ACCEL_ALT
+ cmdId Command ID passed to onMenu
+
Window Arrangement
+
dvxCascadeWindows
+
void dvxCascadeWindows(AppContextT *ctx);
+
Cascade all visible, non-minimized windows. Each is offset diagonally by the title bar height.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
dvxTileWindows
+
void dvxTileWindows(AppContextT *ctx);
+
Arrange visible windows in an NxM grid filling the screen.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
dvxTileWindowsH
+
void dvxTileWindowsH(AppContextT *ctx);
+
Tile windows horizontally (side by side, equal width, full height).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
dvxTileWindowsV
+
void dvxTileWindowsV(AppContextT *ctx);
+
Tile windows vertically (stacked, full width, equal height).
+
Parameter Description
+ --------- -----------
+ ctx Application context
+
Image I/O
+
dvxLoadImage
+
uint8_t *dvxLoadImage(const AppContextT *ctx, const char *path, int32_t *outW, int32_t *outH, int32_t *outPitch);
+
Load an image file (BMP, PNG, JPEG, GIF) and convert to the display's native pixel format. Caller must free with dvxFreeImage().
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ path Image file path
+ outW, outH Output: image dimensions
+ outPitch Output: row pitch in bytes
+
Returns: Pixel buffer, or NULL on failure.
+
dvxLoadImageFromMemory
+
uint8_t *dvxLoadImageFromMemory(const AppContextT *ctx, const uint8_t *data, int32_t dataLen, int32_t *outW, int32_t *outH, int32_t *outPitch);
+
Load an image from a memory buffer. Same output format as dvxLoadImage(). Caller must free with dvxFreeImage().
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ data Image data buffer
+ dataLen Buffer size in bytes
+ outW, outH Output: image dimensions
+ outPitch Output: row pitch in bytes
+
Returns: Pixel buffer, or NULL on failure.
+
dvxFreeImage
+
void dvxFreeImage(uint8_t *data);
+
Free a pixel buffer returned by dvxLoadImage() or dvxLoadImageFromMemory().
+
Parameter Description
+ --------- -----------
+ data Buffer to free
+
dvxImageInfo
+
bool dvxImageInfo(const char *path, int32_t *outW, int32_t *outH);
+
Query image dimensions without decoding the full file.
+
Parameter Description
+ --------- -----------
+ path Image file path
+ outW, outH Output: image dimensions
+
Returns: true on success.
+
dvxSaveImage
+
int32_t dvxSaveImage(const AppContextT *ctx, const uint8_t *data, int32_t w, int32_t h, int32_t pitch, const char *path);
+
Save native-format pixel data to a PNG file.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ data Pixel data in display native format
+ w, h Image dimensions
+ pitch Row pitch in bytes
+ path Output file path
+
Returns: 0 on success, -1 on failure.
+
Screenshots
+
dvxScreenshot
+
int32_t dvxScreenshot(AppContextT *ctx, const char *path);
+
Save the entire screen (backbuffer contents) to a PNG file. Converts from native pixel format to RGB.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ path Output PNG file path
+
Returns: 0 on success, -1 on failure.
+
dvxWindowScreenshot
+
int32_t dvxWindowScreenshot(AppContextT *ctx, WindowT *win, const char *path);
+
Save a window's content to a PNG file.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window
+ path Output PNG file path
+
Returns: 0 on success, -1 on failure.
+
Clipboard
+
dvxClipboardCopy
+
void dvxClipboardCopy(const char *text, int32_t len);
+
Copy text to the process-wide clipboard buffer. Simple static buffer (not inter-process).
+
Parameter Description
+ --------- -----------
+ text Text to copy
+ len Length in bytes
+
dvxClipboardGet
+
const char *dvxClipboardGet(int32_t *outLen);
+
Retrieve the current clipboard contents. Returns a pointer to the internal buffer (valid until the next dvxClipboardCopy), or NULL if empty.
+
Parameter Description
+ --------- -----------
+ outLen Output: length of clipboard text
+
Returns: Clipboard text, or NULL.
+
Resource Loading
+
dvxResLoadIcon
+
uint8_t *dvxResLoadIcon(AppContextT *ctx, const char *dxePath, const char *resName, int32_t *outW, int32_t *outH, int32_t *outPitch);
+
Load an icon/image resource from a DXE file and decode to native pixel format. Caller must free with dvxFreeImage().
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ dxePath Path to DXE file
+ resName Resource name within the DXE
+ outW, outH Output: image dimensions
+ outPitch Output: row pitch
+
Returns: Pixel buffer, or NULL if not found.
+
dvxResLoadText
+
bool dvxResLoadText(const char *dxePath, const char *resName, char *buf, int32_t bufSize);
+
Load a text resource from a DXE file into a caller-provided buffer. Null-terminated and truncated to fit bufSize.
+
Parameter Description
+ --------- -----------
+ dxePath Path to DXE file
+ resName Resource name
+ buf Output buffer
+ bufSize Buffer capacity
+
Returns: true on success.
+
dvxResLoadData
+
void *dvxResLoadData(const char *dxePath, const char *resName, uint32_t *outSize);
+
Load a raw binary resource from a DXE file. Returns a malloc'd buffer that the caller must free.
+
Parameter Description
+ --------- -----------
+ dxePath Path to DXE file
+ resName Resource name
+ outSize Output: data size in bytes
+
Returns: Data buffer, or NULL if not found.
+
Utilities
+
dvxTextHash
+
uint32_t dvxTextHash(const char *text);
+
Compute a djb2-xor hash for cheap dirty detection. Compare at save time with the current hash to detect changes without a shadow copy. Not cryptographic.
+
Parameter Description
+ --------- -----------
+ text Null-terminated string to hash
+
Returns: 32-bit hash value.
+
+
+
dvxWidget.h -- Widget System
+
dvxWidget.h -- Widget System
+
Retained-mode widget toolkit layered on the DVX window manager. Widgets form a tree (parent-child) rooted at a per-window VBox container. Layout is automatic: measure minimum sizes bottom-up, then allocate space top-down with flexbox-like weighted distribution. Widget types are registered dynamically at runtime via DXE plugins.
+
WidgetT Structure
+
Core widget structure. Generic across all widget types; type-specific data lives in the void *data pointer managed by each widget's DXE.
+
Field Description
+ ----- -----------
+ int32_t type Widget type ID (assigned by wgtRegisterClass)
+ const WidgetClassT *wclass Vtable for this widget type
+ char name[MAX_WIDGET_NAME] Widget name for lookup via wgtFind
+ parent, firstChild, lastChild, nextSibling Tree linkage pointers
+ WindowT *window Owning window
+ int32_t x, y, w, h Computed geometry (relative to content area)
+ int32_t calcMinW, calcMinH Computed minimum size (from layout pass)
+ int32_t minW, minH, maxW, maxH, prefW, prefH Size hints (tagged sizes)
+ int32_t weight Extra-space distribution weight (0=fixed, 100=normal)
+ WidgetAlignE align Main-axis alignment for children
+ int32_t spacing, padding Tagged sizes for child spacing and padding
+ uint32_t fgColor, bgColor Custom colors (0 = use scheme defaults)
+ bool visible, enabled, readOnly State flags
+ bool swallowTab Tab key goes to widget, not focus navigation
+ char accelKey Accelerator character (0 = none)
+ void *userData, *data Application data and widget-private data
+ const char *tooltip Tooltip text (NULL = none)
+ MenuT *contextMenu Right-click menu (NULL = none)
+
Universal Callbacks:
+
Callback Description
+ -------- -----------
+ onClick(WidgetT *w) Widget clicked
+ onDblClick(WidgetT *w) Widget double-clicked
+ onChange(WidgetT *w) Value changed
+ onFocus(WidgetT *w) Widget gained focus
+ onBlur(WidgetT *w) Widget lost focus
+ onKeyPress(WidgetT *w, int32_t keyAscii) ASCII key press
+ onKeyDown(WidgetT *w, int32_t keyCode, int32_t shift) Key down
+ onKeyUp(WidgetT *w, int32_t keyCode, int32_t shift) Key up
+ onMouseDown(WidgetT *w, int32_t btn, int32_t x, int32_t y) Mouse button pressed
+ onMouseUp(WidgetT *w, int32_t btn, int32_t x, int32_t y) Mouse button released
+ onMouseMove(WidgetT *w, int32_t btn, int32_t x, int32_t y) Mouse moved
+ onScroll(WidgetT *w, int32_t delta) Mouse wheel
+ onValidate(WidgetT *w) Return false to cancel a write
+
Size Specification Macros
+
Macro Description
+ ----- -----------
+ wgtPixels(v) Size in pixels
+ wgtChars(v) Size in character widths (multiplied by charWidth at layout)
+ wgtPercent(v) Size as percentage of parent dimension
+
Widget Class Flags
+
Flag Description
+ ---- -----------
+ WCLASS_FOCUSABLE Can receive keyboard focus (Tab navigation)
+ WCLASS_HORIZ_CONTAINER Lays out children horizontally (vs. vertical)
+ WCLASS_PAINTS_CHILDREN Widget handles child rendering itself
+ WCLASS_NO_HIT_RECURSE Hit testing stops here, no child recursion
+ WCLASS_FOCUS_FORWARD Accel hit forwards focus to next focusable sibling
+ WCLASS_HAS_POPUP Has dropdown popup overlay
+ WCLASS_SCROLLABLE Accepts mouse wheel events
+ WCLASS_SCROLL_CONTAINER Scroll container (ScrollPane)
+ WCLASS_NEEDS_POLL Needs periodic polling
+ WCLASS_SWALLOWS_TAB Tab key goes to widget, not focus navigation
+ WCLASS_RELAYOUT_ON_SCROLL Full relayout on scrollbar drag
+ WCLASS_PRESS_RELEASE Click = press + release (Button, ImageButton)
+ WCLASS_ACCEL_WHEN_HIDDEN Accelerator matching works even when invisible
+
Window Integration
+
wgtInitWindow
+
WidgetT *wgtInitWindow(AppContextT *ctx, WindowT *win);
+
Initialize the widget system for a window. Creates a root VBox container that fills the content area, and installs callback handlers (onPaint, onMouse, onKey, onResize) for widget-based event dispatch. The window's userData is set to the AppContextT pointer.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ win Window to initialize
+
Returns: Root VBox widget (add children to this).
+
Widget Operations
+
wgtGetContext
+
AppContextT *wgtGetContext(const WidgetT *w);
+
Walk from any widget up the tree to the root, then retrieve the AppContextT stored in the window's userData. Lets any widget access the full application context.
+
Parameter Description
+ --------- -----------
+ w Any widget in the tree
+
Returns: Pointer to the AppContextT.
+
wgtInvalidate
+
void wgtInvalidate(WidgetT *w);
+
Mark a widget as needing both re-layout (measure + position) and repaint. Propagates upward to ancestors. Use after structural changes (adding/removing children, text changes that affect size).
+
Parameter Description
+ --------- -----------
+ w Widget to invalidate
+
wgtInvalidatePaint
+
void wgtInvalidatePaint(WidgetT *w);
+
Mark a widget as needing repaint only, without re-layout. Use for visual-only changes (checkbox toggle, selection highlight, cursor blink).
+
Parameter Description
+ --------- -----------
+ w Widget to repaint
+
wgtSetText
+
void wgtSetText(WidgetT *w, const char *text);
+
Set widget text content (dispatches to the widget class's SET_TEXT handler).
+
Parameter Description
+ --------- -----------
+ w Widget
+ text New text
+
wgtGetText
+
const char *wgtGetText(const WidgetT *w);
+
Get the widget's current text content.
+
Parameter Description
+ --------- -----------
+ w Widget
+
Returns: Text string (empty string if no handler).
+
wgtSetEnabled
+
void wgtSetEnabled(WidgetT *w, bool enabled);
+
Enable or disable a widget. Disabled widgets are grayed out and do not receive input.
+
Parameter Description
+ --------- -----------
+ w Widget
+ enabled true = enabled, false = disabled
+
wgtSetReadOnly
+
void wgtSetReadOnly(WidgetT *w, bool readOnly);
+
Set read-only mode. Allows scrolling and selection but blocks editing.
+
Parameter Description
+ --------- -----------
+ w Widget
+ readOnly true = read-only
+
wgtSetFocused
+
void wgtSetFocused(WidgetT *w);
+
Set keyboard focus to a widget.
+
Parameter Description
+ --------- -----------
+ w Widget to focus
+
wgtGetFocused
+
WidgetT *wgtGetFocused(void);
+
Get the currently focused widget.
+
Returns: Focused widget, or NULL.
+
wgtSetVisible
+
void wgtSetVisible(WidgetT *w, bool visible);
+
Show or hide a widget.
+
Parameter Description
+ --------- -----------
+ w Widget
+ visible true = visible, false = hidden
+
wgtSetName
+
void wgtSetName(WidgetT *w, const char *name);
+
Set a widget's name for lookup via wgtFind().
+
Parameter Description
+ --------- -----------
+ w Widget
+ name Name string (max MAX_WIDGET_NAME chars)
+
wgtFind
+
WidgetT *wgtFind(WidgetT *root, const char *name);
+
Find a widget by name. Searches the subtree rooted at root.
+
Parameter Description
+ --------- -----------
+ root Root of subtree to search
+ name Widget name to find
+
Returns: Matching widget, or NULL.
+
wgtDestroy
+
void wgtDestroy(WidgetT *w);
+
Destroy a widget and all its children. Removes from parent's child list.
+
Parameter Description
+ --------- -----------
+ w Widget to destroy
+
wgtSetTooltip
+
void wgtSetTooltip(WidgetT *w, const char *text);
+
Set tooltip text for a widget. Pass NULL to remove. Caller owns the string and it must outlive the widget.
+
Parameter Description
+ --------- -----------
+ w Widget
+ text Tooltip text, or NULL
+
widgetOnResize
+
void widgetOnResize(WindowT *win, int32_t newW, int32_t newH);
+
Default window resize handler installed by wgtInitWindow(). Re-evaluates scrollbars and relayouts the widget tree. Call from custom onResize handlers to chain to the widget system.
+
Parameter Description
+ --------- -----------
+ win Window being resized
+ newW, newH New content dimensions
+
Layout
+
wgtResolveSize
+
int32_t wgtResolveSize(int32_t taggedSize, int32_t parentSize, int32_t charWidth);
+
Decode a tagged size value (WGT_SIZE_PIXELS/CHARS/PERCENT) into a concrete pixel count. Returns 0 for a raw 0 input (meaning "auto").
+
Parameter Description
+ --------- -----------
+ taggedSize Tagged size value
+ parentSize Parent dimension (for PERCENT mode)
+ charWidth Font character width (for CHARS mode)
+
Returns: Size in pixels.
+
wgtLayout
+
void wgtLayout(WidgetT *root, int32_t availW, int32_t availH, const BitmapFontT *font);
+
Execute the full two-pass layout algorithm. Pass 1 (bottom-up): compute minimum sizes. Pass 2 (top-down): allocate space with weighted distribution. Normally called automatically; exposed for cases where layout must be forced before the next paint.
+
Parameter Description
+ --------- -----------
+ root Root widget
+ availW/H Available space
+ font Bitmap font (for character-based sizing)
+
wgtPaint
+
void wgtPaint(WidgetT *root, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
+
Paint the entire widget tree by depth-first traversal. Each widget's clip rect is set to its bounds. Overlays (popups, tooltips) are painted in a second pass on top.
+
Parameter Description
+ --------- -----------
+ root Root widget
+ d Display context
+ ops Blit operations vtable
+ font Bitmap font
+ colors Color scheme
+
Debug
+
wgtSetDebugLayout
+
void wgtSetDebugLayout(AppContextT *ctx, bool enabled);
+
Draw colored borders around layout containers for debugging.
+
Parameter Description
+ --------- -----------
+ ctx Application context
+ enabled true = draw debug borders
+
Dynamic Widget Registration
+
wgtRegisterClass
+
int32_t wgtRegisterClass(const WidgetClassT *wclass);
+
Register a new widget class at runtime. Appends to widgetClassTable. The WidgetClassT must remain valid for the lifetime of the process (typically static const in a DXE).
+
Parameter Description
+ --------- -----------
+ wclass Widget class vtable to register
+
Returns: Assigned type ID.
+
wgtRegisterApi
+
void wgtRegisterApi(const char *name, const void *api);
+
Register a widget API struct under a name. Each widget DXE registers its API during initialization. Callers retrieve it via wgtGetApi() and cast to the widget-specific type.
+
Parameter Description
+ --------- -----------
+ name Widget type name (e.g. "button", "listbox")
+ api Pointer to the widget's API struct
+
wgtGetApi
+
const void *wgtGetApi(const char *name);
+
Retrieve a registered widget API struct by name.
+
Parameter Description
+ --------- -----------
+ name Widget type name
+
Returns: Pointer to the API struct, or NULL if not found.
+
Widget Interface Descriptors
+
wgtRegisterIface
+
void wgtRegisterIface(const char *name, const WgtIfaceT *iface);
+
Register an interface descriptor for a widget type. Used by the BASIC form runtime and IDE for generic property/method dispatch.
+
Parameter Description
+ --------- -----------
+ name Widget type name
+ iface Interface descriptor
+
wgtGetIface
+
const WgtIfaceT *wgtGetIface(const char *name);
+
Retrieve an interface descriptor by widget type name.
+
Parameter Description
+ --------- -----------
+ name Widget type name
+
Returns: Interface descriptor, or NULL.
+
wgtFindByBasName
+
const char *wgtFindByBasName(const char *basName);
+
Find a widget type name by its VB-style name (e.g. "CommandButton" -> "button"). Case-insensitive search.
+
Parameter Description
+ --------- -----------
+ basName VB-style widget name
+
Returns: Internal type name, or NULL.
+
wgtIfaceCount
+
int32_t wgtIfaceCount(void);
+
Return the number of registered widget interfaces.
+
Returns: Count of registered interfaces.
+
wgtIfaceAt
+
const WgtIfaceT *wgtIfaceAt(int32_t idx, const char **outName);
+
Get a registered widget interface by index.
+
Parameter Description
+ --------- -----------
+ idx Index (0-based)
+ outName Output: type name
+
Returns: Interface descriptor.
+
wgtIfaceGetPath
+
const char *wgtIfaceGetPath(const char *name);
+
Get the .wgt DXE file path for a registered widget.
+
Parameter Description
+ --------- -----------
+ name Widget type name
+
Returns: File path string.
+
wgtIfaceSetPath
+
void wgtIfaceSetPath(const char *name, const char *path);
+
Set the .wgt DXE file path for a registered widget (called by the loader).
+
Parameter Description
+ --------- -----------
+ name Widget type name
+ path DXE file path
+
wgtIfaceGetPathIndex
+
int32_t wgtIfaceGetPathIndex(const char *name);
+
Get the 1-based index of this widget within its .wgt file. Used to construct suffixed resource names (e.g. "name-2", "icon16-2").
+
Parameter Description
+ --------- -----------
+ name Widget type name
+
Returns: 1-based index within the DXE file.
+
Typed Dispatch Helpers
+
The following inline functions provide type-safe dispatch through the WidgetClassT handler table. Each checks for a non-NULL handler before calling.
+
Function Method ID Description
+ -------- --------- -----------
+ wclsHas(w, methodId) -- Check if handler exists
+ wclsPaint(w, d, ops, font, colors) WGT_METHOD_PAINT Paint the widget
+ wclsPaintOverlay(w, d, ops, font, colors) WGT_METHOD_PAINT_OVERLAY Paint overlay (popups)
+ wclsCalcMinSize(w, font) WGT_METHOD_CALC_MIN_SIZE Compute minimum size
+ wclsLayout(w, font) WGT_METHOD_LAYOUT Layout children
+ wclsGetLayoutMetrics(w, font, ...) WGT_METHOD_GET_LAYOUT_METRICS Get pad, gap, extraTop, borderW
+ wclsOnMouse(w, root, vx, vy) WGT_METHOD_ON_MOUSE Handle mouse event
+ wclsOnKey(w, key, mod) WGT_METHOD_ON_KEY Handle key event
+ wclsOnAccelActivate(w, root) WGT_METHOD_ON_ACCEL_ACTIVATE Handle accelerator
+ wclsDestroy(w) WGT_METHOD_DESTROY Destroy widget data
+ wclsOnChildChanged(parent, child) WGT_METHOD_ON_CHILD_CHANGED Notify parent of change
+ wclsGetText(w) WGT_METHOD_GET_TEXT Get widget text
+ wclsSetText(w, text) WGT_METHOD_SET_TEXT Set widget text
+ wclsClearSelection(w) WGT_METHOD_CLEAR_SELECTION Clear text selection
+ wclsClosePopup(w) WGT_METHOD_CLOSE_POPUP Close dropdown popup
+ wclsGetPopupRect(w, font, ...) WGT_METHOD_GET_POPUP_RECT Get popup screen rect
+ wclsOnDragUpdate(w, root, x, y) WGT_METHOD_ON_DRAG_UPDATE Update during drag
+ wclsOnDragEnd(w, root, x, y) WGT_METHOD_ON_DRAG_END End drag operation
+ wclsGetCursorShape(w, vx, vy) WGT_METHOD_GET_CURSOR_SHAPE Get cursor for position
+ wclsPoll(w, win) WGT_METHOD_POLL Periodic polling
+ wclsQuickRepaint(w, outY, outH) WGT_METHOD_QUICK_REPAINT Fast partial repaint
+ wclsScrollChildIntoView(parent, child) WGT_METHOD_SCROLL_CHILD_INTO_VIEW Scroll child visible
+
+
+
Base WidgetT (Common Properties, Events, and Operations)
+
DVX Widget System
+
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/.
+
Individual widgets are documented in their own sections. See the table of contents for the full list.
+
Base WidgetT (Common Properties, Events, and Operations)
+
Every widget inherits from the WidgetT structure defined in core/dvxWidget.h. The fields and callbacks listed here are available on all widget types.
+
Common Properties
+
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.
+
Size Specification Macros
+
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.
+
Common Events (Callbacks)
+
These callback function pointers are available on every WidgetT. Set them directly on the widget struct.
+
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.
+
Common Operations
+
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.
+
+
+
AnsiTerm
+
AnsiTerm
+
A VT100/ANSI-compatible terminal emulator widget designed for connecting to BBS systems over the serial link. Uses a traditional text-mode cell buffer (character + attribute byte pairs) with the CP437 character set and 16-color CGA palette. Supports cursor movement, screen/line erase, scrolling regions, SGR colors, and scrollback history. Communication is abstracted through read/write function pointers, allowing the terminal to work with raw serial ports, the secLink encrypted channel, or any other byte-oriented transport.
+
Header: widgets/widgetAnsiTerm.h
+
Creation
+
WidgetT *term = wgtAnsiTerm(parent, 80, 25);
+
Macros
+
Macro Description
+ ----- -----------
+ wgtAnsiTerm(parent, cols, rows) Create an ANSI terminal widget with the given column and row dimensions.
+ wgtAnsiTermWrite(w, data, len) Write raw bytes into the terminal's ANSI parser. data is a const uint8_t * buffer, len is the byte count.
+ wgtAnsiTermClear(w) Clear the terminal screen and reset the cursor to the home position.
+ wgtAnsiTermSetComm(w, ctx, readFn, writeFn) Attach a communication channel. readFn and writeFn are I/O callbacks; ctx is passed as their first argument.
+ wgtAnsiTermSetScrollback(w, maxLines) Set the maximum number of scrollback lines. Lines scrolled off the top are saved in a circular buffer.
+ wgtAnsiTermPoll(w) Poll the communication channel for incoming data and feed it into the ANSI parser.
+ wgtAnsiTermRepaint(w, outY, outH) Fast repaint path that renders dirty rows directly into the window's content buffer, bypassing the widget pipeline. Returns the dirty region via outY/outH.
+
Properties (BASIC Interface)
+
Property Type Access Description
+ -------- ---- ------ -----------
+ Cols Integer Read-only Number of columns.
+ Rows Integer Read-only Number of rows.
+ Scrollback Integer Write-only Maximum scrollback lines.
+
Methods (BASIC Interface)
+
Method Description
+ ------ -----------
+ Clear Clear the terminal screen.
+ Write Write a string into the terminal.
+
Events
+
AnsiTerm uses the common events only. No widget-specific events are defined.
+
+
+
+
+
Canvas
+
Canvas
+
A freeform drawing surface with a fixed-size pixel buffer. Provides drawing primitives (lines, rectangles, circles, text, individual pixels) and supports save/load to BMP files. Mouse interaction is available via a callback.
+
Header: widgets/widgetCanvas.h
+
Creation
+
WidgetT *cv = wgtCanvas(parent, 320, 200);
+
Macros
+
Macro Description
+ ----- -----------
+ wgtCanvas(parent, w, h) Create a canvas with the given pixel dimensions.
+ wgtCanvasClear(w, color) Fill the entire canvas with a solid color.
+ wgtCanvasSetPenColor(w, color) Set the drawing pen color.
+ wgtCanvasSetPenSize(w, size) Set the drawing pen size in pixels.
+ wgtCanvasDrawLine(w, x0, y0, x1, y1) Draw a line from (x0,y0) to (x1,y1).
+ wgtCanvasDrawRect(w, x, y, width, height) Draw a rectangle outline.
+ wgtCanvasFillRect(w, x, y, width, height) Draw a filled rectangle.
+ wgtCanvasFillCircle(w, cx, cy, radius) Draw a filled circle.
+ wgtCanvasSetPixel(w, x, y, color) Set a single pixel to the given color.
+ wgtCanvasGetPixel(w, x, y) Get the color of a single pixel.
+ wgtCanvasDrawText(w, x, y, text) Draw text at the given position using the current pen color.
+ wgtCanvasSetMouseCallback(w, cb) Set a mouse interaction callback. Signature: void (*cb)(WidgetT *w, int32_t cx, int32_t cy, bool drag). Receives canvas-relative coordinates and whether the mouse is being dragged.
+ wgtCanvasSave(w, path) Save the canvas contents to a BMP file.
+ wgtCanvasLoad(w, path) Load a BMP file into the canvas.
+
Events
+
Callback Description
+ -------- -----------
+ onClick Fires when the canvas is clicked.
+ Mouse callback (via wgtCanvasSetMouseCallback) Fires on mouse down and drag with canvas-local coordinates.
+
Methods (BASIC Interface)
+
Method Description
+ ------ -----------
+ Clear Clear the canvas to a given color.
+
+
+
+
+
+
+
+
+
+
+
+
ListView
+
ListView
+
A multi-column list with sortable headers. Supports single and multi-selection, column alignment, header click sorting, and drag-to-reorder. Data is provided as a flat array of strings (row-major order, one string per cell).
+
Header: widgets/widgetListView.h
+
Creation
+
WidgetT *lv = wgtListView(parent);
+ListViewColT cols[] = {
+ { "Name", wgtChars(20), ListViewAlignLeftE },
+ { "Size", wgtChars(10), ListViewAlignRightE }
+};
+wgtListViewSetColumns(lv, cols, 2);
+const char *cells[] = { "file.txt", "1234", "readme.md", "5678" };
+wgtListViewSetData(lv, cells, 2);
+
Column Definition
+
typedef struct {
+ const char *title;
+ int32_t width; // tagged size (wgtPixels/wgtChars/wgtPercent, 0 = auto)
+ ListViewAlignE align; // ListViewAlignLeftE, ListViewAlignCenterE, ListViewAlignRightE
+} ListViewColT;
+
Sort Direction
+
typedef enum {
+ ListViewSortNoneE,
+ ListViewSortAscE,
+ ListViewSortDescE
+} ListViewSortE;
+
Macros
+
Macro Description
+ ----- -----------
+ wgtListView(parent) Create a list view.
+ wgtListViewSetColumns(w, cols, count) Define columns from an array of ListViewColT.
+ wgtListViewSetData(w, cellData, rowCount) Set row data. cellData is a flat const char ** array of size rowCount * colCount.
+ wgtListViewGetSelected(w) Get the index of the selected row (-1 if none).
+ wgtListViewSetSelected(w, idx) Set the selected row by index.
+ wgtListViewSetSort(w, col, dir) Set the sort column and direction.
+ wgtListViewSetHeaderClickCallback(w, cb) Set a callback for header clicks. Signature: void (*cb)(WidgetT *w, int32_t col, ListViewSortE dir).
+ wgtListViewSetMultiSelect(w, multi) Enable or disable multi-selection.
+ wgtListViewIsItemSelected(w, idx) Check if a specific row is selected.
+ wgtListViewSetItemSelected(w, idx, selected) Select or deselect a specific row.
+ wgtListViewSelectAll(w) Select all rows.
+ wgtListViewClearSelection(w) Deselect all rows.
+ wgtListViewSetReorderable(w, reorderable) Enable drag-to-reorder of rows.
+
Events
+
Callback Description
+ -------- -----------
+ onClick Fires when a row is clicked.
+ onDblClick Fires when a row is double-clicked.
+ onChange Fires when the selection changes.
+
Properties (BASIC Interface)
+
Property Type Access Description
+ -------- ---- ------ -----------
+ ListIndex Integer Read/Write Index of the currently selected row.
+
Methods (BASIC Interface)
+
Method Description
+ ------ -----------
+ SelectAll Select all rows.
+ ClearSelection Deselect all rows.
+ SetMultiSelect Enable or disable multi-selection.
+ SetReorderable Enable or disable drag-to-reorder.
+ IsItemSelected Check if a specific row is selected by index.
+ SetItemSelected Select or deselect a specific row by index.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
TextInput / TextArea
+
TextInput / TextArea
+
Single-line text input, password input, masked input, and multi-line text area with optional syntax colorization, line numbers, find/replace, and gutter decorators.
+
Header: widgets/widgetTextInput.h
+
Creation
+
Macro Description
+ ----- -----------
+ wgtTextInput(parent, maxLen) Create a single-line text input. maxLen is the maximum number of characters.
+ wgtPasswordInput(parent, maxLen) Create a password input (characters displayed as bullets).
+ wgtMaskedInput(parent, mask) Create a masked input field. The mask string defines the input format.
+ wgtTextArea(parent, maxLen) Create a multi-line text area.
+
Methods (TextArea-specific)
+
Macro Description
+ ----- -----------
+ wgtTextAreaSetColorize(w, fn, ctx) Set a syntax colorization callback. The callback receives each line and fills a color index array. Color indices: 0=default, 1=keyword, 2=string, 3=comment, 4=number, 5=operator, 6=type/builtin, 7=reserved.
+ wgtTextAreaGoToLine(w, line) Scroll to and place the cursor on the given line number.
+ wgtTextAreaSetAutoIndent(w, enable) Enable or disable automatic indentation on newline.
+ wgtTextAreaSetShowLineNumbers(w, show) Show or hide line numbers in the gutter.
+ wgtTextAreaSetCaptureTabs(w, capture) When true, Tab key inserts a tab/spaces instead of moving focus.
+ wgtTextAreaSetTabWidth(w, width) Set the tab stop width in characters.
+ wgtTextAreaSetUseTabChar(w, useChar) When true, insert literal tab characters; when false, insert spaces.
+ wgtTextAreaFindNext(w, needle, caseSens, fwd) Search for the next occurrence. Returns true if found.
+ wgtTextAreaReplaceAll(w, needle, repl, caseSens) Replace all occurrences. Returns the number of replacements made.
+ wgtTextAreaSetLineDecorator(w, fn, ctx) Set a gutter line decorator callback. The callback returns a color and receives the line number, a color output pointer, and the user context.
+ wgtTextAreaGetCursorLine(w) Get the current cursor line number.
+ wgtTextAreaSetGutterClick(w, fn) Set a callback for gutter clicks (e.g. for breakpoint toggling). Callback receives the widget and line number.
+
Events
+
Callback Description
+ -------- -----------
+ onChange Fires when the text content changes.
+ onKeyPress Fires on each key press (ASCII value).
+ onValidate Called before committing a change. Return false to cancel.
+
+
+
+
+
+
+
+
+
diff --git a/docs/dvx_widget_reference.html b/docs/dvx_widget_reference.html
index b7ab5f8..272dee5 100644
--- a/docs/dvx_widget_reference.html
+++ b/docs/dvx_widget_reference.html
@@ -303,15 +303,9 @@ img { max-width: 100%; }
Base WidgetT (Common Properties, Events, and Operations)
DVX Widget Reference
-
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/.
+
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/.
Base WidgetT (Common Properties, Events, and Operations)
-
Every widget inherits from the WidgetT structure defined in
-core/dvxWidget.h. The fields and callbacks listed here are available on all
-widget types.
+
Every widget inherits from the WidgetT structure defined in core/dvxWidget.h. The fields and callbacks listed here are available on all widget types.
Common Properties
Field Type Description
----- ---- -----------
@@ -341,8 +335,7 @@ widget types.
wgtChars(v) Size in character widths (multiplied by font charWidth).
wgtPercent(v) Size as a percentage of parent dimension.
Common Events (Callbacks)
-
These callback function pointers are available on every WidgetT. Set them
-directly on the widget struct.
+
These callback function pointers are available on every WidgetT. Set them directly on the widget struct.
Callback Signature Description
-------- --------- -----------
onClick void (*)(WidgetT *w) Fires on mouse click / activation.
@@ -381,13 +374,7 @@ directly on the widget struct.
AnsiTerm
AnsiTerm
-
A VT100/ANSI-compatible terminal emulator widget designed for connecting to
-BBS systems over the serial link. Uses a traditional text-mode cell buffer
-(character + attribute byte pairs) with the CP437 character set and 16-color
-CGA palette. Supports cursor movement, screen/line erase, scrolling regions,
-SGR colors, and scrollback history. Communication is abstracted through
-read/write function pointers, allowing the terminal to work with raw serial
-ports, the secLink encrypted channel, or any other byte-oriented transport.
+
A VT100/ANSI-compatible terminal emulator widget designed for connecting to BBS systems over the serial link. Uses a traditional text-mode cell buffer (character + attribute byte pairs) with the CP437 character set and 16-color CGA palette. Supports cursor movement, screen/line erase, scrolling regions, SGR colors, and scrollback history. Communication is abstracted through read/write function pointers, allowing the terminal to work with raw serial ports, the secLink encrypted channel, or any other byte-oriented transport.
Header: widgets/widgetAnsiTerm.h
Creation
WidgetT *term = wgtAnsiTerm(parent, 80, 25);
@@ -419,10 +406,7 @@ ports, the secLink encrypted channel, or any other byte-oriented transport.
Box (VBox / HBox / Frame)
Box (VBox / HBox / Frame)
-
Container widgets that arrange their children in a vertical column (VBox),
-horizontal row (HBox), or a titled group box (Frame). These are the primary
-layout building blocks. Children are laid out using a flexbox-like algorithm
-with weight-based extra-space distribution.
+
Container widgets that arrange their children in a vertical column (VBox), horizontal row (HBox), or a titled group box (Frame). These are the primary layout building blocks. Children are laid out using a flexbox-like algorithm with weight-based extra-space distribution.
Header: widgets/widgetBox.h
Creation
Macro Description
@@ -445,8 +429,7 @@ with weight-based extra-space distribution.
Button
Button
-
A push button with a text label. Fires onClick when pressed and released.
-Supports keyboard activation via accelerator keys.
+
A push button with a text label. Fires onClick when pressed and released. Supports keyboard activation via accelerator keys.
Header: widgets/widgetButton.h
Creation
WidgetT *btn = wgtButton(parent, "OK");
@@ -455,8 +438,7 @@ Supports keyboard activation via accelerator keys.
----- -----------
wgtButton(parent, text) Create a push button with the given label text.
Properties
-
Uses common WidgetT properties. Set accelKey for keyboard shortcut. Use
-wgtSetText() / wgtGetText() to change the label.
+
Uses common WidgetT properties. Set accelKey for keyboard shortcut. Use wgtSetText() / wgtGetText() to change the label.
Events
Callback Description
-------- -----------
@@ -466,10 +448,7 @@ wgtSetText() / wgtGetText() to change the label.
Label
Label
-
A static text label. Does not accept keyboard focus. Typically used to
-describe other widgets. Supports text alignment and accelerator keys (with
-WCLASS_FOCUS_FORWARD, the accelerator moves focus to the next focusable
-sibling).
+
A static text label. Does not accept keyboard focus. Typically used to describe other widgets. Supports text alignment and accelerator keys (with WCLASS_FOCUS_FORWARD, the accelerator moves focus to the next focusable sibling).
Header: widgets/widgetLabel.h
Creation
WidgetT *lbl = wgtLabel(parent, "Name:");
@@ -479,8 +458,7 @@ sibling).
wgtLabel(parent, text) Create a text label.
wgtLabelSetAlign(w, align) Set the text alignment (AlignStartE, AlignCenterE, AlignEndE).
Properties
-
Use wgtSetText() / wgtGetText() to change the text. Set accelKey for
-accelerator support (focus forwards to next focusable widget).
+
Use wgtSetText() / wgtGetText() to change the text. Set accelKey for accelerator support (focus forwards to next focusable widget).
Events
Labels use the common events only. Typically no callbacks are set on labels.
Properties (BASIC Interface)
@@ -492,9 +470,7 @@ accelerator support (focus forwards to next focusable widget).
TextInput / TextArea
TextInput / TextArea
-
Single-line text input, password input, masked input, and multi-line text
-area with optional syntax colorization, line numbers, find/replace, and
-gutter decorators.
+
Single-line text input, password input, masked input, and multi-line text area with optional syntax colorization, line numbers, find/replace, and gutter decorators.
Header: widgets/widgetTextInput.h
Creation
Macro Description
@@ -529,8 +505,7 @@ gutter decorators.