// dvx_wm.h — Layer 4: Window manager for DV/X GUI #ifndef DVX_WM_H #define DVX_WM_H #include "dvxTypes.h" // Initialize window stack void wmInit(WindowStackT *stack); // Create a new window and add it to the stack (raised to top) WindowT *wmCreateWindow(WindowStackT *stack, DisplayT *d, const char *title, int32_t x, int32_t y, int32_t w, int32_t h, bool resizable); // Destroy a window and remove from stack void wmDestroyWindow(WindowStackT *stack, WindowT *win); // Raise a window to the top of the stack void wmRaiseWindow(WindowStackT *stack, DirtyListT *dl, int32_t idx); // Set focus to a window (by stack index) void wmSetFocus(WindowStackT *stack, DirtyListT *dl, int32_t idx); // Recalculate content area geometry from frame dimensions void wmUpdateContentRect(WindowT *win); // Reallocate content buffer after resize int32_t wmReallocContentBuf(WindowT *win, const DisplayT *d); // Add a menu bar to a window MenuBarT *wmAddMenuBar(WindowT *win); // Add a menu to a menu bar MenuT *wmAddMenu(MenuBarT *bar, const char *label); // Add an item to a menu void wmAddMenuItem(MenuT *menu, const char *label, int32_t id); // Add a separator to a menu void wmAddMenuSeparator(MenuT *menu); // Add a vertical scrollbar to a window ScrollbarT *wmAddVScrollbar(WindowT *win, int32_t min, int32_t max, int32_t pageSize); // Add a horizontal scrollbar to a window ScrollbarT *wmAddHScrollbar(WindowT *win, int32_t min, int32_t max, int32_t pageSize); // Draw window chrome (frame, title bar, menu bar) clipped to a dirty rect void wmDrawChrome(DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors, WindowT *win, const RectT *clipTo); // Draw window content clipped to a dirty rect void wmDrawContent(DisplayT *d, const BlitOpsT *ops, WindowT *win, const RectT *clipTo); // Draw scrollbars for a window void wmDrawScrollbars(DisplayT *d, const BlitOpsT *ops, const ColorSchemeT *colors, WindowT *win, const RectT *clipTo); // Draw minimized window icons at bottom of screen void wmDrawMinimizedIcons(DisplayT *d, const BlitOpsT *ops, const ColorSchemeT *colors, const WindowStackT *stack, const RectT *clipTo); // Hit test: which part of which window is at screen position (mx, my)? // Returns stack index or -1 if no window hit // Sets *hitPart: 0=content, 1=title, 2=close button, 3=resize edge, // 4=menu bar, 5=vscroll, 6=hscroll, 7=minimize, 8=maximize int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hitPart); // Detect which resize edge(s) are hit (returns RESIZE_xxx flags) int32_t wmResizeEdgeHit(const WindowT *win, int32_t mx, int32_t my); // Handle window drag (call each mouse move during drag) void wmDragMove(WindowStackT *stack, DirtyListT *dl, int32_t mouseX, int32_t mouseY); // Handle window resize (call each mouse move during resize) void wmResizeMove(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, int32_t mouseX, int32_t mouseY); // Begin dragging a window void wmDragBegin(WindowStackT *stack, int32_t idx, int32_t mouseX, int32_t mouseY); // End dragging void wmDragEnd(WindowStackT *stack); // Begin resizing a window void wmResizeBegin(WindowStackT *stack, int32_t idx, int32_t edge, int32_t mouseX, int32_t mouseY); // End resizing void wmResizeEnd(WindowStackT *stack); // Set window title void wmSetTitle(WindowT *win, DirtyListT *dl, const char *title); // Handle scrollbar click (arrow buttons, trough, or begin thumb drag) void wmScrollbarClick(WindowStackT *stack, DirtyListT *dl, int32_t idx, int32_t orient, int32_t mx, int32_t my); // Handle ongoing scrollbar thumb drag void wmScrollbarDrag(WindowStackT *stack, DirtyListT *dl, int32_t mx, int32_t my); // End scrollbar thumb drag void wmScrollbarEnd(WindowStackT *stack); // Maximize a window (saves current geometry, expands to screen/max bounds) void wmMaximize(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, WindowT *win); // Minimize a window (hides window, shows icon at bottom of screen) void wmMinimize(WindowStackT *stack, DirtyListT *dl, WindowT *win); // Hit-test minimized icons at bottom of screen // Returns stack index of the minimized window, or -1 int32_t wmMinimizedIconHit(const WindowStackT *stack, const DisplayT *d, int32_t mx, int32_t my); // Restore a maximized window to its pre-maximize geometry void wmRestore(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, WindowT *win); // Restore a minimized window void wmRestoreMinimized(WindowStackT *stack, DirtyListT *dl, WindowT *win); // Load an icon image for a window (converts to display pixel format) int32_t wmSetIcon(WindowT *win, const char *path, const DisplayT *d); #endif // DVX_WM_H