DVX_GUI/dvx/widgets/widgetInternal.h

159 lines
8.2 KiB
C

// widgetInternal.h — Shared internal header for widget implementation files
#ifndef WIDGET_INTERNAL_H
#define WIDGET_INTERNAL_H
#include "../dvxWidget.h"
#include "../dvxApp.h"
#include "../dvxDraw.h"
#include "../dvxWm.h"
#include "../dvxVideo.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
// ============================================================
// Constants
// ============================================================
#define DEFAULT_SPACING 4
#define DEFAULT_PADDING 4
#define SEPARATOR_THICKNESS 2
#define BUTTON_PAD_H 8
#define BUTTON_PAD_V 4
#define CHECKBOX_BOX_SIZE 12
#define CHECKBOX_GAP 4
#define FRAME_BEVEL_BORDER 2
#define FRAME_FLAT_BORDER 1
#define TEXT_INPUT_PAD 3
#define DROPDOWN_BTN_WIDTH 16
#define DROPDOWN_MAX_VISIBLE 8
#define SLIDER_TRACK_H 4
#define SLIDER_THUMB_W 11
#define TAB_PAD_H 8
#define TAB_PAD_V 4
#define TAB_BORDER 2
#define TREE_INDENT 16
#define TREE_EXPAND_SIZE 9
#define TREE_ICON_GAP 4
#define TREE_BORDER 2
// ============================================================
// Shared state (defined in widgetCore.c)
// ============================================================
extern bool sDebugLayout;
extern WidgetT *sOpenPopup;
extern WidgetT *sDragSlider;
extern WidgetT *sDrawingCanvas;
extern int32_t sDragOffset;
// ============================================================
// Core functions (widgetCore.c)
// ============================================================
void widgetAddChild(WidgetT *parent, WidgetT *child);
WidgetT *widgetAlloc(WidgetT *parent, WidgetTypeE type);
int32_t widgetCountVisibleChildren(const WidgetT *w);
void widgetDestroyChildren(WidgetT *w);
void widgetDropdownPopupRect(WidgetT *w, const BitmapFontT *font, int32_t contentH, int32_t *popX, int32_t *popY, int32_t *popW, int32_t *popH);
int32_t widgetFrameBorderWidth(const WidgetT *w);
WidgetT *widgetHitTest(WidgetT *w, int32_t x, int32_t y);
bool widgetIsBoxContainer(WidgetTypeE type);
bool widgetIsHorizContainer(WidgetTypeE type);
void widgetRemoveChild(WidgetT *parent, WidgetT *child);
// ============================================================
// Layout functions (widgetLayout.c)
// ============================================================
void widgetCalcMinSizeBox(WidgetT *w, const BitmapFontT *font);
void widgetCalcMinSizeTree(WidgetT *w, const BitmapFontT *font);
void widgetLayoutBox(WidgetT *w, const BitmapFontT *font);
void widgetLayoutChildren(WidgetT *w, const BitmapFontT *font);
// ============================================================
// Event functions (widgetEvent.c)
// ============================================================
void widgetManageScrollbars(WindowT *win, AppContextT *ctx);
void widgetOnKey(WindowT *win, int32_t key, int32_t mod);
void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons);
void widgetOnPaint(WindowT *win, RectT *dirtyArea);
void widgetOnResize(WindowT *win, int32_t newW, int32_t newH);
void widgetOnScroll(WindowT *win, ScrollbarOrientE orient, int32_t value);
// ============================================================
// Paint/ops functions (widgetOps.c)
// ============================================================
void widgetPaintOne(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetPaintOverlays(WidgetT *root, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
// ============================================================
// Per-widget paint functions
// ============================================================
void widgetButtonPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetCanvasPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetCheckboxPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetComboBoxPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetComboBoxPaintPopup(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetDropdownPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetDropdownPaintPopup(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetFramePaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetImagePaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetLabelPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetProgressBarPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetRadioPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetSeparatorPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetSliderPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetStatusBarPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetTabControlPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetTextInputPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetToolbarPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
void widgetTreeViewPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors);
// ============================================================
// Per-widget calcMinSize functions
// ============================================================
void widgetButtonCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetCanvasCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetCheckboxCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetComboBoxCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetDropdownCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetImageCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetLabelCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetProgressBarCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetRadioCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetSliderCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetSpacerCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetTabControlCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetTextInputCalcMinSize(WidgetT *w, const BitmapFontT *font);
void widgetTreeViewCalcMinSize(WidgetT *w, const BitmapFontT *font);
// ============================================================
// Per-widget layout functions (for special containers)
// ============================================================
void widgetTabControlLayout(WidgetT *w, const BitmapFontT *font);
void widgetTreeViewLayout(WidgetT *w, const BitmapFontT *font);
// ============================================================
// Per-widget mouse functions
// ============================================================
void widgetButtonOnMouse(WidgetT *hit);
void widgetCanvasOnMouse(WidgetT *hit, int32_t vx, int32_t vy);
void widgetCheckboxOnMouse(WidgetT *hit);
void widgetComboBoxOnMouse(WidgetT *hit, WidgetT *root, int32_t vx);
void widgetDropdownOnMouse(WidgetT *hit);
void widgetImageOnMouse(WidgetT *hit);
void widgetRadioOnMouse(WidgetT *hit);
void widgetSliderOnMouse(WidgetT *hit, int32_t vx, int32_t vy);
void widgetTabControlOnMouse(WidgetT *hit, WidgetT *root, int32_t vx, int32_t vy);
void widgetTextInputOnMouse(WidgetT *hit, WidgetT *root, int32_t vx);
void widgetTreeViewOnMouse(WidgetT *hit, WidgetT *root, int32_t vx, int32_t vy);
#endif // WIDGET_INTERNAL_H