224 lines
6.6 KiB
C
224 lines
6.6 KiB
C
|
#include <cairo/cairo.h>
|
||
|
|
||
|
#include "btk-text.h"
|
||
|
|
||
|
#define NEW_PP(type, pp) (pp = (type*)malloc(sizeof(type)))
|
||
|
|
||
|
#define PP_BUTTON(c) ((btk_pp_button_t*)c->pp)
|
||
|
#define PP_EDITOR(c) ((btk_pp_editor_t*)c->pp)
|
||
|
#define PP_INPUT(c) ((btk_pp_input_t*)c->pp)
|
||
|
#define PP_LIST(c) ((btk_pp_list_t*)c->pp)
|
||
|
#define PP_MARK(c) ((btk_pp_mark_t*)c->pp)
|
||
|
#define PP_SWITCH(c) ((btk_pp_switch_t*)c->pp)
|
||
|
#define PP_TABLE(c) ((btk_pp_table_t*)c->pp)
|
||
|
|
||
|
enum btk_cell_states {
|
||
|
BTK_CELL_STATE_INITIAL = 0,
|
||
|
BTK_CELL_STATE_HIDDEN = 1U << 0,
|
||
|
BTK_CELL_STATE_DISABLED = 1U << 1,
|
||
|
BTK_CELL_STATE_FOCUSED = 1U << 2,
|
||
|
BTK_CELL_STATE_PRESSED = 1U << 3,
|
||
|
BTK_CELL_STATE_ON = 1U << 4,
|
||
|
BTK_CELL_STATE_BELL = 1U << 5,
|
||
|
BTK_CELL_STATE_IN = 1U << 6
|
||
|
};
|
||
|
|
||
|
enum btk_cell_group {
|
||
|
BTK_CELL_GROUP_PASSIVE,
|
||
|
BTK_CELL_GROUP_DYNAMIC,
|
||
|
BTK_CELL_GROUP_FIELD
|
||
|
};
|
||
|
|
||
|
enum btk_cell_type {
|
||
|
BTK_CELL_TYPE_EMPTY,
|
||
|
BTK_CELL_TYPE_MARK,
|
||
|
BTK_CELL_TYPE_GAUGE,
|
||
|
BTK_CELL_TYPE_BUTTON,
|
||
|
BTK_CELL_TYPE_SWITCH,
|
||
|
BTK_CELL_TYPE_WHEEL,
|
||
|
BTK_CELL_TYPE_LIST,
|
||
|
BTK_CELL_TYPE_TABLE,
|
||
|
BTK_CELL_TYPE_INPUT,
|
||
|
BTK_CELL_TYPE_PROMPT,
|
||
|
BTK_CELL_TYPE_EDITOR
|
||
|
};
|
||
|
|
||
|
enum btk_cell_table_col_state {
|
||
|
BTK_CELL_TABLE_COL_HIDDEN,
|
||
|
BTK_CELL_TABLE_COL_VISIBLE
|
||
|
};
|
||
|
|
||
|
typedef struct {
|
||
|
/* global properties */
|
||
|
unsigned int group;
|
||
|
unsigned int type;
|
||
|
unsigned int state;
|
||
|
btk_area_t ca; /* geometry in cell coordinates */
|
||
|
btk_area_t pa; /* geometry in pixel coordinates */
|
||
|
void *pp; /* type specific properties to cast */
|
||
|
btk_field_t *fd; /* for field group types only */
|
||
|
int lh; /* lock pixel height from stretching */
|
||
|
char *label;
|
||
|
} btk_cell_t;
|
||
|
|
||
|
typedef struct {
|
||
|
void (*func)(void);
|
||
|
} btk_pp_button_t;
|
||
|
|
||
|
typedef struct {
|
||
|
char *text;
|
||
|
unsigned int text_w;
|
||
|
btk_pos_t caret_2d;
|
||
|
int caret;
|
||
|
int scroll;
|
||
|
btk_par_t *par;
|
||
|
} btk_pp_editor_t;
|
||
|
|
||
|
typedef struct {
|
||
|
char *text;
|
||
|
unsigned int text_w; /* max text size */
|
||
|
int caret;
|
||
|
int scroll;
|
||
|
} btk_pp_input_t;
|
||
|
|
||
|
typedef struct {
|
||
|
char **items;
|
||
|
unsigned int *items_n;
|
||
|
unsigned int items_w;
|
||
|
int item_sel;
|
||
|
int **filter; // TODO
|
||
|
int **order; // TODO
|
||
|
int **spot;
|
||
|
int scroll;
|
||
|
void (*func_trigger)(int);
|
||
|
void (*func_sel)(int);
|
||
|
} btk_pp_list_t;
|
||
|
|
||
|
typedef struct {
|
||
|
int justify;
|
||
|
} btk_pp_mark_t;
|
||
|
|
||
|
typedef struct {
|
||
|
void (*func)(int, btk_arg_t);
|
||
|
btk_arg_t func_args;
|
||
|
} btk_pp_switch_t;
|
||
|
|
||
|
typedef struct {
|
||
|
char *header;
|
||
|
char **items;
|
||
|
unsigned int items_w;
|
||
|
unsigned int cols_n;
|
||
|
unsigned int *rows_n;
|
||
|
int row_sel;
|
||
|
int *cols_ena; /* hidden cols */
|
||
|
unsigned int *cols_cw; /* width in cell units of each col */
|
||
|
unsigned int *cols_pw; /* width in picels of each col */
|
||
|
unsigned int *cols_px; /* position of each col in pixels */
|
||
|
unsigned int sc; /* stretch col */
|
||
|
unsigned int tw; /* columns total pixel width */
|
||
|
int **filter; // TODO
|
||
|
int **order; // TODO
|
||
|
int **spot;
|
||
|
btk_pos_t scroll;
|
||
|
void (*func_trigger)(int);
|
||
|
void (*func_sel)(int);
|
||
|
} btk_pp_table_t;
|
||
|
|
||
|
void btk_cell_set_button (btk_cell_t *,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
char *,
|
||
|
void (*)(void));
|
||
|
|
||
|
void btk_cell_set_editor (btk_cell_t *,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
char *,
|
||
|
unsigned int);
|
||
|
|
||
|
void btk_cell_set_empty (btk_cell_t *,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int);
|
||
|
|
||
|
void btk_cell_set_input (btk_cell_t *,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
char *,
|
||
|
unsigned int);
|
||
|
|
||
|
void btk_cell_set_list (btk_cell_t *,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
char **,
|
||
|
unsigned int *,
|
||
|
unsigned int,
|
||
|
int **,
|
||
|
int **,
|
||
|
int **,
|
||
|
void (*)(int),
|
||
|
void (*)(int));
|
||
|
|
||
|
void btk_cell_set_mark (btk_cell_t *,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
int,
|
||
|
char *);
|
||
|
|
||
|
void btk_cell_set_switch (btk_cell_t *,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
char *,
|
||
|
void (*)(int, btk_arg_t),
|
||
|
btk_arg_t);
|
||
|
|
||
|
void btk_cell_set_table (btk_cell_t *,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
char *,
|
||
|
char **,
|
||
|
unsigned int,
|
||
|
unsigned int,
|
||
|
unsigned int *,
|
||
|
int *,
|
||
|
unsigned int *,
|
||
|
unsigned int,
|
||
|
int **,
|
||
|
int **,
|
||
|
int **,
|
||
|
void (*)(int),
|
||
|
void (*)(int));
|
||
|
|
||
|
void btk_cell_button_trigger (btk_cell_t *, int);
|
||
|
void btk_cell_destroy (btk_cell_t *);
|
||
|
void btk_cell_draw (btk_cell_t *, cairo_t *);
|
||
|
void btk_cell_editor_input_button (btk_cell_t *, int, int, btk_pos_t);
|
||
|
void btk_cell_editor_input_key (btk_cell_t *, uint32_t);
|
||
|
void btk_cell_editor_reset_caret (btk_cell_t*);
|
||
|
void btk_cell_editor_update_text (btk_cell_t *);
|
||
|
btk_field_t* btk_cell_field_create (cairo_surface_t *, btk_area_t);
|
||
|
void btk_cell_input_button (btk_cell_t *, int, int, btk_pos_t);
|
||
|
void btk_cell_input_input_key (btk_cell_t *, uint32_t);
|
||
|
void btk_cell_input_reset_caret (btk_cell_t *);
|
||
|
void btk_cell_field_destroy (btk_field_t *);
|
||
|
void btk_cell_list_deselect (btk_cell_t*);
|
||
|
void btk_cell_list_input_button (btk_cell_t *, int, int, btk_pos_t);
|
||
|
int btk_cell_list_get_sel (btk_cell_t *);
|
||
|
void btk_cell_setup_font (cairo_t *c_ctx);
|
||
|
void btk_cell_switch_toggle (btk_cell_t *, int);
|
||
|
void btk_cell_table_deselect (btk_cell_t*);
|
||
|
char* btk_cell_table_get_item (btk_cell_t *, int, int);
|
||
|
void btk_cell_table_input_button (btk_cell_t *, int, int, btk_pos_t);
|
||
|
void btk_cell_table_update_geometry (btk_cell_t *);
|