Commit e4c14514 authored by Claes Sjofors's avatar Claes Sjofors

Ge menu, ColorTheme next added

parent fb8d0072
......@@ -803,9 +803,14 @@ void GeGtk::image_file_selected_cb( void *ctx, char *filename, wow_eFileSelType
ge->subpalette->select_by_name( cmd);
}
void GeGtk::activate_select_colortheme(GtkWidget *w, gpointer gectx)
void GeGtk::activate_colortheme_select(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_select_colortheme();
((Ge *)gectx)->activate_colortheme_select();
}
void GeGtk::activate_colortheme_next(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_colortheme_next();
}
void GeGtk::activate_customcolors_read(GtkWidget *w, gpointer gectx)
......@@ -1690,15 +1695,31 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_widget_add_accelerator( file_graph_attr, "activate", accel_g,
'g', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *file_select_colortheme = gtk_menu_item_new_with_mnemonic( "_Select ColorTheme");
g_signal_connect( file_select_colortheme, "activate",
G_CALLBACK(activate_select_colortheme), this);
gtk_widget_add_accelerator( file_select_colortheme, "activate", accel_g,
// Submenu colortheme
GtkWidget *file_colortheme_select = gtk_menu_item_new_with_mnemonic( "_Select");
g_signal_connect( file_colortheme_select, "activate",
G_CALLBACK(activate_colortheme_select), this);
gtk_widget_add_accelerator( file_colortheme_select, "activate", accel_g,
't', GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *file_colortheme_next = gtk_menu_item_new_with_mnemonic( "_Next");
g_signal_connect( file_colortheme_next, "activate",
G_CALLBACK(activate_colortheme_next), this);
gtk_widget_add_accelerator( file_colortheme_next, "activate", accel_g,
't', GdkModifierType(GDK_CONTROL_MASK | GDK_MOD1_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *file_colortheme = gtk_menu_item_new_with_mnemonic( "ColorTheme");
GtkMenu *file_colortheme_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_colortheme_menu), file_colortheme_select);
gtk_menu_shell_append(GTK_MENU_SHELL(file_colortheme_menu), file_colortheme_next);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_colortheme),
GTK_WIDGET(file_colortheme_menu));
// Submenu customcolors
GtkWidget *file_customcolors_read = gtk_menu_item_new_with_mnemonic( "_Read");
GtkWidget *file_customcolors_read = gtk_menu_item_new_with_mnemonic( "_Load");
g_signal_connect( file_customcolors_read, "activate",
G_CALLBACK(activate_customcolors_read), this);
......@@ -1791,7 +1812,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_save_as);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_build);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_graph_attr);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_select_colortheme);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_colortheme);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_customcolors);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_subgraphs);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_export);
......
......@@ -192,7 +192,8 @@ class GeGtk : public Ge {
static void activate_export_java_as( GtkWidget *w, gpointer gectx);
static void activate_export_plcfo( GtkWidget *w, gpointer gectx);
static void activate_export_plcfo_as( GtkWidget *w, gpointer gectx);
static void activate_select_colortheme(GtkWidget *w, gpointer gectx);
static void activate_colortheme_select(GtkWidget *w, gpointer gectx);
static void activate_colortheme_next(GtkWidget *w, gpointer gectx);
static void activate_customcolors_read(GtkWidget *w, gpointer gectx);
static void activate_customcolors_write(GtkWidget *w, gpointer gectx);
static void activate_import_graph( GtkWidget *w, gpointer gectx);
......
......@@ -1604,66 +1604,76 @@ void Ge::activate_open()
// Ge::open_graph);
}
typedef struct {
pwr_tString32 name;
int idx;
} tThemes;
static tThemes themes[] = {
{"Standard", 0},
{"Sand", 1},
{"Maroon", 2},
{"Sienna", 3},
{"DarkBlue", 4},
{"Classic", 5},
{"Midnight", 6},
{"PlayRoom", 7},
{"NordicLight", 8},
{"Contrast", 9},
{"AzureContrast", 10},
{"OchreContrast", 11},
{"Chesterfield", 12},
{"TerraVerte", 13},
{"Custom", 100}};
static void ge_colortheme_selector_ok_cb( void *ctx, char *text)
{
Ge *gectx = (Ge *)ctx;
int idx;
int idx = -1;
if ( strcmp( text, "Standard") == 0)
idx = 0;
else if ( strcmp( text, "Sand") == 0)
idx = 1;
else if ( strcmp( text, "Maroon") == 0)
idx = 2;
else if ( strcmp( text, "Sienna") == 0)
idx = 3;
else if ( strcmp( text, "DarkBlue") == 0)
idx = 4;
else if ( strcmp( text, "Classic") == 0)
idx = 5;
else if ( strcmp( text, "Midnight") == 0)
idx = 6;
else if ( strcmp( text, "PlayRoom") == 0)
idx = 7;
else if ( strcmp( text, "NordicLight") == 0)
idx = 8;
else if ( strcmp( text, "Contrast") == 0)
idx = 9;
else if ( strcmp( text, "AzureContrast") == 0)
idx = 10;
else if ( strcmp( text, "OchreContrast") == 0)
idx = 11;
else
return;
for ( unsigned int i = 0; i < sizeof(themes)/sizeof(themes[0]); i++) {
if ( strcmp( text, themes[i].name) == 0) {
idx = themes[i].idx;
break;
}
}
gectx->graph->update_color_theme( idx);
if( idx > 0)
gectx->graph->update_color_theme( idx);
}
void Ge::activate_select_colortheme()
void Ge::activate_colortheme_select()
{
pwr_tString80 names[30];
strcpy( names[0], "Standard");
strcpy( names[1], "Sand");
strcpy( names[2], "Maroon");
strcpy( names[3], "Sienna");
strcpy( names[4], "DarkBlue");
strcpy( names[5], "Classic");
strcpy( names[6], "Midnight");
strcpy( names[7], "PlayRoom");
strcpy( names[8], "NordicLight");
strcpy( names[9], "Contrast");
strcpy( names[10], "AzureContrast");
strcpy( names[11], "OchreContrast");
strcpy( names[11], "Chesterfield");
strcpy( names[11], "TerraVerte");
strcpy( names[11], "Custom");
strcpy( names[12], "");
memset( names, 0, sizeof(names));
for ( unsigned int i = 0; i < sizeof(themes)/sizeof(themes[0]); i++) {
strcpy( names[i], themes[i].name);
}
wow->CreateList( "ColorTheme Selector", (char *)names, sizeof(names[0]),
ge_colortheme_selector_ok_cb, 0, this);
}
void Ge::activate_colortheme_next()
{
int next_idx = -1;
for ( unsigned int i = 0; i < sizeof(themes)/sizeof(themes[0]); i++) {
if ( themes[i].idx == graph->color_theme) {
if ( i == sizeof(themes)/sizeof(themes[0]) - 1)
next_idx = themes[0].idx;
else
next_idx = themes[i+1].idx;
break;
}
}
if ( next_idx < 0)
next_idx = 0;
graph->update_color_theme( next_idx);
}
void Ge::activate_customcolors_read()
{
wow->CreateFileSelDia( "CustomColors Selection", (void *)this,
......
......@@ -222,7 +222,8 @@ class Ge {
void activate_prevpage();
void activate_graph_attr();
void activate_open();
void activate_select_colortheme();
void activate_colortheme_select();
void activate_colortheme_next();
void activate_customcolors_read();
void activate_customcolors_write();
void activate_subgraphs();
......
......@@ -679,13 +679,16 @@ void Graph::set_mode( grow_eMode mode, bool keep)
}
void Graph::update_color_theme( int color_theme)
void Graph::update_color_theme( int ct)
{
char color_theme_file[80];
int sts;
sprintf( color_theme_file, "pwr_colortheme%d", color_theme);
sprintf( color_theme_file, "pwr_colortheme%d", ct);
sts = grow_ReadCustomColorFile( grow->ctx, color_theme_file);
if ( EVEN(sts)) return;
color_theme = ct;
if ( update_colorpalette_cb)
(update_colorpalette_cb)( parent_ctx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment