1
0
Fork 0
libfort/src/options.h

173 lines
4.3 KiB
C
Raw Normal View History

2018-01-17 19:22:57 +01:00
#ifndef OPTIONS_H
#define OPTIONS_H
#include "fort_impl.h"
2018-02-25 09:39:41 +01:00
#include <stdint.h>
#include <limits.h>
2018-01-17 19:22:57 +01:00
2018-03-18 10:17:33 +01:00
//enum TextAlignment
//{
// LeftAligned,
// CenterAligned,
// RightAligned
//};
2018-01-17 19:22:57 +01:00
2018-03-18 10:17:33 +01:00
//enum RowType
//{
// Common,
// Header
//};
2018-03-05 19:08:14 +01:00
2018-01-17 19:22:57 +01:00
struct fort_column_options
{
int col_min_width;
enum TextAlignment align;
};
typedef struct fort_column_options fort_column_options_t;
extern fort_column_options_t g_column_options;
fort_column_options_t create_column_options(void);
2018-01-17 19:22:57 +01:00
struct vector;
typedef struct vector vector_t;
2018-02-25 09:39:41 +01:00
#define FT_ANY_COLUMN (UINT_MAX)
#define FT_ANY_ROW (UINT_MAX)
2018-01-17 19:22:57 +01:00
2018-02-25 09:39:41 +01:00
#define FT_ROW_UNSPEC (UINT_MAX-1)
#define FT_COLUMN_UNSPEC (UINT_MAX-1)
2018-01-17 19:22:57 +01:00
2018-02-25 09:39:41 +01:00
#define FT_OPT_MIN_WIDTH ((uint32_t)(0x01U << (0)))
#define FT_OPT_TEXT_ALIGN ((uint32_t)(0x01U << (1)))
#define FT_OPT_TOP_PADDING ((uint32_t)(0x01U << (2)))
#define FT_OPT_BOTTOM_PADDING ((uint32_t)(0x01U << (3)))
#define FT_OPT_LEFT_PADDING ((uint32_t)(0x01U << (4)))
#define FT_OPT_RIGHT_PADDING ((uint32_t)(0x01U << (5)))
#define FT_OPT_EMPTY_STR_HEIGHT ((uint32_t)(0x01U << (6)))
2018-03-05 19:08:14 +01:00
#define FT_OPT_ROW_TYPE ((uint32_t)(0x01U << (7)))
2018-01-17 19:22:57 +01:00
2018-02-25 17:25:00 +01:00
#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option))
#define OPTION_SET(ft_opts, option) ((ft_opts) |=(option))
#define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option))
2018-01-17 19:22:57 +01:00
2018-02-25 09:39:41 +01:00
struct fort_cell_options
{
unsigned cell_row;
unsigned cell_col;
uint32_t options;
int col_min_width;
enum TextAlignment align;
2018-02-27 18:41:57 +01:00
int cell_padding_top;
int cell_padding_bottom;
int cell_padding_left;
int cell_padding_right;
int cell_empty_string_height;
2018-03-05 19:08:14 +01:00
enum RowType row_type;
2018-02-25 09:39:41 +01:00
};
typedef struct fort_cell_options fort_cell_options_t;
typedef vector_t fort_cell_opt_container_t;
fort_cell_opt_container_t *create_cell_opt_container(void);
2018-02-25 09:39:41 +01:00
void destroy_cell_opt_container(fort_cell_opt_container_t *cont);
const fort_cell_options_t* cget_cell_opt(const fort_cell_opt_container_t *cont, unsigned row, unsigned col);
fort_cell_options_t* get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, unsigned row, unsigned col);
fort_status_t set_cell_option(fort_cell_opt_container_t *cont, unsigned row, unsigned col, uint32_t option, int value);
fort_status_t unset_cell_option(fort_cell_opt_container_t *cont, unsigned row, unsigned col, uint32_t option);
2018-01-17 19:22:57 +01:00
int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option);
2018-02-27 18:41:57 +01:00
fort_status_t set_default_cell_option(uint32_t option, int value);
2018-01-17 19:22:57 +01:00
/*****************************************************************************
* TABLE BORDER
*****************************************************************************/
/*
* TL TT TT TT TV TT TT TT TV TB TB TB TR <----- TopSeparator
* LL IV IV RR
* LH IH IH IH II IH IH IH II IH IH IH RH <----- InsideSeparator
* LL IV IV RR
* BL BB BB BB BV BB BB BB BV BB BB BB BR <----- BottomSeparator
*/
enum HorSeparatorPos
{
TopSeparator,
InsideSeparator,
BottomSeparator
};
enum BorderItemPos
{
TL_bip = 0,
TT_bip = 1,
TV_bip = 2,
TR_bip = 3,
LL_bip = 4,
IV_bip = 5,
RR_bip = 6,
LH_bip = 7,
IH_bip = 8,
II_bip = 9,
RH_bip = 10,
BL_bip = 11,
BB_bip = 12,
BV_bip = 13,
BR_bip = 14,
BorderItemPosSize
};
2018-02-04 14:21:04 +01:00
enum SeparatorItemPos
{
LH_sip = 0,
IH_sip = 1,
II_sip = 2,
RH_sip = 3,
SepratorItemPosSize
};
2018-01-17 19:22:57 +01:00
2018-03-12 20:28:55 +01:00
struct fort_border_style
{
char border_chars[BorderItemPosSize];
char header_border_chars[BorderItemPosSize];
char separator_chars[SepratorItemPosSize];
};
2018-03-12 21:02:59 +01:00
extern struct fort_border_style FORT_BASIC_STYLE;
extern struct fort_border_style FORT_SIMPLE_STYLE;
2018-03-14 19:30:27 +01:00
extern struct fort_border_style FORT_PLAIN_STYLE;
2018-03-12 21:02:59 +01:00
extern struct fort_border_style FORT_DOT_STYLE;
2018-03-14 19:30:27 +01:00
extern struct fort_border_style FORT_EMPTY_STYLE;
2018-03-12 21:02:59 +01:00
2018-03-12 20:28:55 +01:00
2018-01-17 19:22:57 +01:00
struct fort_table_options
{
2018-03-12 21:02:59 +01:00
struct fort_border_style border_style;
2018-02-25 09:39:41 +01:00
fort_cell_opt_container_t * cell_options;
2018-01-17 19:22:57 +01:00
};
typedef struct fort_table_options fort_table_options_t;
extern fort_table_options_t g_table_options;
fort_table_options_t* create_table_options();
2018-01-21 11:22:46 +01:00
fort_table_options_t* copy_table_options(const fort_table_options_t *option);
2018-01-17 19:22:57 +01:00
void destroy_table_options(fort_table_options_t* options);
2018-03-05 19:18:26 +01:00
2018-01-17 19:22:57 +01:00
2018-03-09 10:44:16 +01:00
#endif /* OPTIONS_H */