5 Struct N_GUI_DATAGRID_DATA
gullradriel edited this page 2026-10-09 00:55:18 +02:00

N_GUI_DATAGRID_DATA

Module: GUI: allegro5 widget system with pseudo-windows

data grid specific data: a sortable column table

#include "n_gui.h"

Public Attributes

Name
void * user_data
user data for callback
int sort_dir
sort direction: 1 ascending, -1 descending
int sort_col
column index used for sorting, or -1
int selected_row
selected data row (the primary / last-clicked row), or -1
int scroll_offset
first visible data row
size_t rows_cap
allocated row capacity (in rows)
unsigned char * row_sel
per-row selection flags (1 = selected), sized rows_cap; NULL until needed
unsigned char * row_has_color
per-row tint flags (1 = row_color[row] is painted), sized rows_cap; NULL until a row color is set
ALLEGRO_COLOR * row_color
per-row background tint, sized rows_cap; NULL until a row color is set
void(*)(int widget_id, int row, void *user_data) on_select
callback on row selection (widget_id, row, user_data)
void(*)(int widget_id, int row, int x, int y, void *user_data) on_context
callback on right-click over a data row, for a context menu (widget_id, row, x, y, user_data); x/y are the cursor position in GUI coordinates so the caller can place a popup there.
void(*)(int widget_id, void *user_data) on_columns_changed
callback fired after the user resizes a column by dragging its header border (widget_id, user_data), so the host can persist the new layout.
size_t nb_rows
number of rows
size_t nb_cols
number of columns
int multiselect
1 = multi-row selection enabled (Ctrl/Shift-click), 0 = single-select
int h_scroll_dragging
1 while the user is dragging the horizontal scrollbar thumb (so the shared scrollbar-drag handler routes the drag to h_scroll, not the vertical scroll).
float h_scroll
horizontal scroll offset in pixels: how far the columns are scrolled to the left when their total width exceeds the widget's pane.
size_t cols_cap
allocated column capacity
N_GUI_DATAGRID_COL * cols
column definitions (physical/storage order; cells are indexed by these)
float col_resize_x0
cursor x at the start of a column-resize drag
float col_resize_w0
original width of the column at the start of a resize drag
int col_resize_col
physical column being resized by a header-border drag, or -1
size_t * col_order
display order: display_pos -> physical column index (sized cols_cap), or NULL when the display order is still the identity
char ** cells
row-major cell strings (nb_rows * nb_cols owned char*)
int anchor_row
anchor row for Shift-click range selection, or -1

Public Attributes Documentation

variable user_data

void * user_data;

user data for callback

variable sort_dir

int sort_dir;

sort direction: 1 ascending, -1 descending

variable sort_col

int sort_col;

column index used for sorting, or -1

variable selected_row

int selected_row;

selected data row (the primary / last-clicked row), or -1

variable scroll_offset

int scroll_offset;

first visible data row

variable rows_cap

size_t rows_cap;

allocated row capacity (in rows)

variable row_sel

unsigned char * row_sel;

per-row selection flags (1 = selected), sized rows_cap; NULL until needed

variable row_has_color

unsigned char * row_has_color;

per-row tint flags (1 = row_color[row] is painted), sized rows_cap; NULL until a row color is set

variable row_color

ALLEGRO_COLOR * row_color;

per-row background tint, sized rows_cap; NULL until a row color is set

variable on_select

void(*)(int widget_id, int row, void *user_data) on_select;

callback on row selection (widget_id, row, user_data)

variable on_context

void(*)(int widget_id, int row, int x, int y, void *user_data) on_context;

callback on right-click over a data row, for a context menu (widget_id, row, x, y, user_data); x/y are the cursor position in GUI coordinates so the caller can place a popup there.

NULL disables it.

variable on_columns_changed

void(*)(int widget_id, void *user_data) on_columns_changed;

callback fired after the user resizes a column by dragging its header border (widget_id, user_data), so the host can persist the new layout.

NULL disables it.

variable nb_rows

size_t nb_rows;

number of rows

variable nb_cols

size_t nb_cols;

number of columns

variable multiselect

int multiselect;

1 = multi-row selection enabled (Ctrl/Shift-click), 0 = single-select

variable h_scroll_dragging

int h_scroll_dragging;

1 while the user is dragging the horizontal scrollbar thumb (so the shared scrollbar-drag handler routes the drag to h_scroll, not the vertical scroll).

variable h_scroll

float h_scroll;

horizontal scroll offset in pixels: how far the columns are scrolled to the left when their total width exceeds the widget's pane.

0 = leftmost.

variable cols_cap

size_t cols_cap;

allocated column capacity

variable cols

N_GUI_DATAGRID_COL * cols;

column definitions (physical/storage order; cells are indexed by these)

variable col_resize_x0

float col_resize_x0;

cursor x at the start of a column-resize drag

variable col_resize_w0

float col_resize_w0;

original width of the column at the start of a resize drag

variable col_resize_col

int col_resize_col;

physical column being resized by a header-border drag, or -1

variable col_order

size_t * col_order;

display order: display_pos -> physical column index (sized cols_cap), or NULL when the display order is still the identity

variable cells

char ** cells;

row-major cell strings (nb_rows * nb_cols owned char*)

variable anchor_row

int anchor_row;

anchor row for Shift-click range selection, or -1