mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Reduce the RegisterColor enums so there is one for each type
Combine the foreground and background colour enums so there are only eight and change the access function to gnc_table_get_color
This commit is contained in:
parent
7a2c1492fd
commit
98d8696b1a
@ -345,70 +345,31 @@ gnc_table_get_label (Table *table, VirtualLocation virt_loc)
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
|
||||||
gnc_table_get_fg_color_internal (Table *table, VirtualLocation virt_loc)
|
|
||||||
{
|
|
||||||
TableGetFGColorHandler fg_color_handler;
|
|
||||||
const char *handler_name;
|
|
||||||
|
|
||||||
if (!table || !table->model)
|
|
||||||
return COLOR_UNKNOWN_FG;
|
|
||||||
|
|
||||||
handler_name = gnc_table_get_cell_name (table, virt_loc);
|
|
||||||
|
|
||||||
fg_color_handler = gnc_table_model_get_fg_color_handler (table->model,
|
|
||||||
handler_name);
|
|
||||||
if (!fg_color_handler)
|
|
||||||
{
|
|
||||||
TableGetBGColorHandler bg_color_handler =
|
|
||||||
gnc_table_model_get_bg_color_handler (table->model, handler_name);
|
|
||||||
|
|
||||||
guint32 bg_color =
|
|
||||||
bg_color_handler (virt_loc, NULL, table->model->handler_user_data);
|
|
||||||
return bg_color + COLOR_UNKNOWN_FG;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fg_color_handler (virt_loc, table->model->handler_user_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
guint32
|
guint32
|
||||||
gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc)
|
gnc_table_get_color (Table *table, VirtualLocation virt_loc,
|
||||||
{
|
|
||||||
return gnc_table_get_fg_color_internal (table, virt_loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static guint32
|
|
||||||
gnc_table_get_bg_color_internal (Table *table, VirtualLocation virt_loc,
|
|
||||||
gboolean *hatching)
|
gboolean *hatching)
|
||||||
{
|
{
|
||||||
TableGetBGColorHandler bg_color_handler;
|
TableGetCellColorHandler color_handler;
|
||||||
const char *handler_name;
|
const char *handler_name;
|
||||||
|
|
||||||
if (hatching)
|
if (hatching)
|
||||||
*hatching = FALSE;
|
*hatching = FALSE;
|
||||||
|
|
||||||
if (!table || !table->model)
|
if (!table || !table->model)
|
||||||
return COLOR_UNKNOWN_BG;
|
return COLOR_UNDEFINED;
|
||||||
|
|
||||||
handler_name = gnc_table_get_cell_name (table, virt_loc);
|
handler_name = gnc_table_get_cell_name (table, virt_loc);
|
||||||
|
|
||||||
bg_color_handler = gnc_table_model_get_bg_color_handler (table->model,
|
color_handler = gnc_table_model_get_cell_color_handler (table->model,
|
||||||
handler_name);
|
handler_name);
|
||||||
|
|
||||||
if (!bg_color_handler)
|
if (!color_handler)
|
||||||
return COLOR_UNKNOWN_BG;
|
return COLOR_UNDEFINED;
|
||||||
|
|
||||||
return bg_color_handler (virt_loc, hatching,
|
return color_handler (virt_loc, hatching,
|
||||||
table->model->handler_user_data);
|
table->model->handler_user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32
|
|
||||||
gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
|
|
||||||
gboolean *hatching)
|
|
||||||
{
|
|
||||||
return gnc_table_get_bg_color_internal (table, virt_loc, hatching);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
|
gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
|
||||||
PhysicalCellBorders *borders)
|
PhysicalCellBorders *borders)
|
||||||
|
@ -179,35 +179,19 @@ struct table
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Color definitions used for table elements */
|
/** Color definitions used for table elements */
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
COLOR_UNDEFINED = 0, // 0
|
||||||
/* Colors used for background drawing */
|
COLOR_HEADER, // 1
|
||||||
COLOR_UNKNOWN_BG, // 0
|
COLOR_PRIMARY, // 2
|
||||||
COLOR_HEADER_BG, // 1
|
COLOR_PRIMARY_ACTIVE, // 3
|
||||||
COLOR_PRIMARY_BG, // 2
|
COLOR_SECONDARY, // 4
|
||||||
COLOR_PRIMARY_BG_ACTIVE, // 3
|
COLOR_SECONDARY_ACTIVE, // 5
|
||||||
COLOR_SECONDARY_BG, // 4
|
COLOR_SPLIT, // 6
|
||||||
COLOR_SECONDARY_BG_ACTIVE, // 5
|
COLOR_SPLIT_ACTIVE, // 7
|
||||||
COLOR_SPLIT_BG, // 6
|
COLOR_NEGATIVE = 16, // 16
|
||||||
COLOR_SPLIT_BG_ACTIVE, // 7
|
|
||||||
|
|
||||||
/* Colors used for foreground drawing (text etc)
|
|
||||||
* ATTENTION: the background and foreground lists should have
|
|
||||||
* the same types (the same amount of entries) !
|
|
||||||
* The code relies on this ! */
|
|
||||||
COLOR_UNKNOWN_FG, // 8
|
|
||||||
COLOR_HEADER_FG, // 9
|
|
||||||
COLOR_PRIMARY_FG, // 10
|
|
||||||
COLOR_PRIMARY_FG_ACTIVE, // 11
|
|
||||||
COLOR_SECONDARY_FG, // 12
|
|
||||||
COLOR_SECONDARY_FG_ACTIVE, // 13
|
|
||||||
COLOR_SPLIT_FG, // 14
|
|
||||||
COLOR_SPLIT_FG_ACTIVE, // 15
|
|
||||||
|
|
||||||
/* Other colors */
|
|
||||||
COLOR_NEGATIVE, // 16 Color to use for negative numbers
|
|
||||||
} RegisterColor;
|
} RegisterColor;
|
||||||
|
|
||||||
|
|
||||||
/** Set the default gui handlers used by new tables. */
|
/** Set the default gui handlers used by new tables. */
|
||||||
void gnc_table_set_default_gui_handlers (TableGUIHandlers *gui_handlers);
|
void gnc_table_set_default_gui_handlers (TableGUIHandlers *gui_handlers);
|
||||||
|
|
||||||
@ -258,9 +242,7 @@ const char * gnc_table_get_label (Table *table, VirtualLocation virt_loc);
|
|||||||
|
|
||||||
CellIOFlags gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc);
|
CellIOFlags gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc);
|
||||||
|
|
||||||
guint32 gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc);
|
guint32 gnc_table_get_color (Table *table, VirtualLocation virt_loc,
|
||||||
|
|
||||||
guint32 gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
|
|
||||||
gboolean *hatching);
|
gboolean *hatching);
|
||||||
|
|
||||||
void gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
|
void gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
|
||||||
|
Loading…
Reference in New Issue
Block a user