1
0
Fork 0
libfort/src/properties.h

210 lines
6.0 KiB
C
Raw Normal View History

2018-11-03 21:50:30 +01:00
#ifndef PROPERTIES_H
#define PROPERTIES_H
2018-01-17 19:22:57 +01:00
2018-05-06 15:36:53 +02:00
#include "fort_utils.h"
2018-02-25 09:39:41 +01:00
#include <stdint.h>
#include <limits.h>
2018-01-17 19:22:57 +01:00
2018-11-03 21:50:30 +01:00
#define PROP_IS_SET(ft_props, property) ((ft_props) & (property))
#define PROP_SET(ft_props, property) ((ft_props) |=(property))
2019-01-01 19:43:21 +01:00
#define PROP_UNSET(ft_props, property) ((ft_props) &= ~((uint32_t)(property)))
2018-01-17 19:22:57 +01:00
2018-11-10 07:58:21 +01:00
#define TEXT_STYLE_TAG_MAX_SIZE 64
2018-11-14 20:50:36 +01:00
FT_INTERNAL
2018-11-10 07:58:21 +01:00
void get_style_tag_for_cell(const fort_table_properties_t *props,
size_t row, size_t col, char *style_tag, size_t sz);
2018-11-14 20:50:36 +01:00
FT_INTERNAL
2018-11-10 07:58:21 +01:00
void get_reset_style_tag_for_cell(const fort_table_properties_t *props,
size_t row, size_t col, char *style_tag, size_t sz);
2018-11-14 20:50:36 +01:00
FT_INTERNAL
2018-11-10 07:58:21 +01:00
void get_style_tag_for_content(const fort_table_properties_t *props,
size_t row, size_t col, char *style_tag, size_t sz);
2018-11-14 20:50:36 +01:00
FT_INTERNAL
2018-11-10 07:58:21 +01:00
void get_reset_style_tag_for_content(const fort_table_properties_t *props,
size_t row, size_t col, char *style_tag, size_t sz);
2018-11-03 21:50:30 +01:00
struct fort_cell_props {
2018-04-17 19:14:50 +02:00
size_t cell_row;
size_t cell_col;
2019-01-02 08:38:26 +01:00
uint32_t properties_flags;
2018-04-16 21:33:05 +02:00
unsigned int col_min_width;
2018-04-01 12:27:02 +02:00
enum ft_text_alignment align;
2018-04-16 21:33:05 +02:00
unsigned int cell_padding_top;
unsigned int cell_padding_bottom;
unsigned int cell_padding_left;
unsigned int cell_padding_right;
unsigned int cell_empty_string_height;
2018-04-01 12:27:02 +02:00
enum ft_row_type row_type;
2018-11-10 07:58:21 +01:00
unsigned int content_fg_color_number;
unsigned int content_bg_color_number;
unsigned int cell_bg_color_number;
2018-11-16 21:20:57 +01:00
enum ft_text_style cell_text_style;
enum ft_text_style content_text_style;
2018-02-25 09:39:41 +01:00
};
2018-11-03 21:50:30 +01:00
typedef struct fort_cell_props fort_cell_props_t;
typedef vector_t fort_cell_prop_container_t;
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
fort_cell_prop_container_t *create_cell_prop_container(void);
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
void destroy_cell_prop_container(fort_cell_prop_container_t *cont);
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
const fort_cell_props_t *cget_cell_prop(const fort_cell_prop_container_t *cont, size_t row, size_t col);
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
fort_cell_props_t *get_cell_prop_and_create_if_not_exists(fort_cell_prop_container_t *cont, size_t row, size_t col);
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
fort_status_t set_cell_property(fort_cell_prop_container_t *cont, size_t row, size_t col, uint32_t property, int value);
2018-01-17 19:22:57 +01:00
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
int get_cell_property_value_hierarcial(const fort_table_properties_t *properties, size_t row, size_t column, uint32_t property);
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
fort_status_t set_default_cell_property(uint32_t property, int value);
2018-01-17 19:22:57 +01:00
2018-11-17 21:55:05 +01:00
/* TABLE BORDER DESRIPTION
*
*
* TL TT TT TT TV TT TT TT TT TT TT TT TR
* LL IV RR
* LL IV RR
* LH IH IH IH II IH IH IH TI IH IH IH RH
* LL IV IV RR
* LL IV IV RR
* LL LI IH IH IH RI RH
* LL IV IV RR
* LL IV IV RR
* LH IH IH IH BI IH IH IH II IH IH IH RH
* LL IV RR
* LL IV RR
* BL BB BB BB BV BB BB BB BV BB BB BB BR
*/
2018-11-17 21:55:05 +01:00
/* HORIZONTAL SEPARATOR DESCRIPTION
*
*
* TL TT TT TT TV TT TT TT TV TT TT TT TR <----- TopSeparator
2018-01-17 19:22:57 +01:00
* 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
*/
2018-05-06 16:04:34 +02:00
enum HorSeparatorPos {
2018-01-17 19:22:57 +01:00
TopSeparator,
InsideSeparator,
BottomSeparator
};
2018-05-06 16:04:34 +02:00
enum BorderItemPos {
2018-01-17 19:22:57 +01:00
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,
LI_bip = 15,
TI_bip = 16,
RI_bip = 17,
BI_bip = 18,
2018-01-17 19:22:57 +01:00
BorderItemPosSize
};
2018-05-06 16:04:34 +02:00
enum SeparatorItemPos {
2018-02-04 14:21:04 +01:00
LH_sip = 0,
IH_sip = 1,
II_sip = 2,
RH_sip = 3,
2018-11-15 21:14:18 +01:00
TI_sip = 4,
BI_sip = 5,
2018-02-04 14:21:04 +01:00
SepratorItemPosSize
};
2018-01-17 19:22:57 +01:00
2018-05-06 16:04:34 +02:00
struct fort_border_style {
2018-05-02 20:16:41 +02:00
const char *border_chars[BorderItemPosSize];
const char *header_border_chars[BorderItemPosSize];
const char *separator_chars[SepratorItemPosSize];
2018-03-12 20:28:55 +01:00
};
2018-03-12 21:02:59 +01:00
extern struct fort_border_style FORT_BASIC_STYLE;
2018-05-07 22:25:45 +02:00
extern struct fort_border_style FORT_BASIC2_STYLE;
2018-03-12 21:02:59 +01:00
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;
2019-01-01 10:59:35 +01:00
extern struct fort_border_style FORT_EMPTY2_STYLE;
2018-05-02 20:16:41 +02:00
extern struct fort_border_style FORT_SOLID_STYLE;
2018-05-04 20:25:29 +02:00
extern struct fort_border_style FORT_SOLID_ROUND_STYLE;
2018-11-16 18:35:56 +01:00
extern struct fort_border_style FORT_NICE_STYLE;
2018-05-02 20:16:41 +02:00
extern struct fort_border_style FORT_DOUBLE_STYLE;
2018-05-04 20:25:29 +02:00
extern struct fort_border_style FORT_DOUBLE2_STYLE;
extern struct fort_border_style FORT_BOLD_STYLE;
extern struct fort_border_style FORT_BOLD2_STYLE;
extern struct fort_border_style FORT_FRAME_STYLE;
2018-03-14 19:30:27 +01:00
2018-03-12 21:02:59 +01:00
2018-11-03 21:50:30 +01:00
struct fort_entire_table_properties {
2018-04-16 21:33:05 +02:00
unsigned int left_margin;
unsigned int top_margin;
unsigned int right_margin;
unsigned int bottom_margin;
2018-03-25 10:11:08 +02:00
};
2018-11-03 21:50:30 +01:00
typedef struct fort_entire_table_properties fort_entire_table_properties_t;
extern fort_entire_table_properties_t g_entire_table_properties;
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
fort_status_t set_entire_table_property(fort_table_properties_t *table_properties, uint32_t property, int value);
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
fort_status_t set_default_entire_table_property(uint32_t property, int value);
2018-03-12 20:28:55 +01:00
2018-11-03 21:50:30 +01:00
struct fort_table_properties {
2018-03-12 21:02:59 +01:00
struct fort_border_style border_style;
2018-11-03 21:50:30 +01:00
fort_cell_prop_container_t *cell_properties;
fort_entire_table_properties_t entire_table_properties;
2018-01-17 19:22:57 +01:00
};
2018-11-03 21:50:30 +01:00
extern fort_table_properties_t g_table_properties;
2018-01-17 19:22:57 +01:00
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
size_t max_border_elem_strlen(struct fort_table_properties *);
2018-01-17 19:22:57 +01:00
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
fort_table_properties_t *create_table_properties(void);
2018-03-05 19:18:26 +01:00
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
void destroy_table_properties(fort_table_properties_t *properties);
2018-01-17 19:22:57 +01:00
2018-09-01 14:45:34 +02:00
FT_INTERNAL
2018-11-03 21:50:30 +01:00
fort_table_properties_t *copy_table_properties(const fort_table_properties_t *property);
2018-11-03 21:50:30 +01:00
#endif /* PROPERTIES_H */