Commit f9b03929 authored by Claes Sjofors's avatar Claes Sjofors

Ge, fonts displayed in font menu, and reset button added

parent bddb110e
......@@ -773,7 +773,7 @@ void GeGtk::image_file_selected_cb( void *ctx, char *filename, wow_eFileSelType
char *s;
dcli_translate_filename( str, "$pwrp_pop/");
sprintf( cmd, "cp %s %s", filename, str);
sprintf( cmd, "cp \'%s\' %s", filename, str);
system( cmd);
sprintf( str, "Image imported, %s", filename);
......@@ -1055,6 +1055,11 @@ void GeGtk::activate_gradient_radlowerright(GtkWidget *w, gpointer gectx)
((Ge *)gectx)->activate_gradient( glow_eGradient_RadialLowerRight);
}
void GeGtk::activate_reset_mode(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_reset_mode();
}
void GeGtk::activate_scale(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_scale();
......@@ -1538,6 +1543,14 @@ static void destroy_event( GtkWidget *w, gpointer data)
{
}
static void set_widget_font( GtkWidget *w, const char *font_name)
{
PangoFontDescription *desc;
desc = pango_font_description_from_string( font_name);
gtk_widget_modify_font( w, desc);
}
gboolean GeGtk::ge_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
GeGtk *gectx = (GeGtk *)data;
......@@ -2431,6 +2444,11 @@ GeGtk::GeGtk( void *x_parent_ctx,
g_signal_connect(tools_open_object, "clicked", G_CALLBACK(activate_objectattributes), this);
gtk_toolbar_append_widget( tools, tools_open_object, "Open selected object", "");
// Ordinary edit mode button
GtkWidget *tools_reset_mode = image_button( "$pwr_exe/ge_reset.png");
g_signal_connect(tools_reset_mode, "clicked", G_CALLBACK(activate_reset_mode), this);
gtk_toolbar_append_widget( tools2, tools_reset_mode, "Mode reset", "");
// Scale button
GtkWidget *tools_scale = image_button( "$pwr_exe/ge_scale.png");
g_signal_connect(tools_scale, "clicked", G_CALLBACK(activate_scale), this);
......@@ -2648,18 +2666,23 @@ GeGtk::GeGtk( void *x_parent_ctx,
// Text font options menu
GtkWidget *tools_textfont_1 = gtk_image_menu_item_new_with_label( "Helvetica");
set_widget_font( gtk_bin_get_child( GTK_BIN(tools_textfont_1)), "Helvetica");
g_signal_connect(tools_textfont_1, "activate", G_CALLBACK(activate_textfont_1), this);
GtkWidget *tools_textfont_2 = gtk_image_menu_item_new_with_label( "Times");
set_widget_font( gtk_bin_get_child( GTK_BIN(tools_textfont_2)), "Times");
g_signal_connect(tools_textfont_2, "activate", G_CALLBACK(activate_textfont_2), this);
GtkWidget *tools_textfont_3 = gtk_image_menu_item_new_with_label( "New Century Schoolbook");
set_widget_font( gtk_bin_get_child( GTK_BIN(tools_textfont_3)), "New Century Schoolbook");
g_signal_connect(tools_textfont_3, "activate", G_CALLBACK(activate_textfont_3), this);
GtkWidget *tools_textfont_4 = gtk_image_menu_item_new_with_label( "Courier");
set_widget_font( gtk_bin_get_child( GTK_BIN(tools_textfont_4)), "Courier");
g_signal_connect(tools_textfont_4, "activate", G_CALLBACK(activate_textfont_4), this);
GtkWidget *tools_textfont_5 = gtk_image_menu_item_new_with_label( "Lucida Sans");
set_widget_font( gtk_bin_get_child( GTK_BIN(tools_textfont_5)), "Lucida Sans");
g_signal_connect(tools_textfont_5, "activate", G_CALLBACK(activate_textfont_5), this);
GtkMenu *textfont_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
......
......@@ -236,6 +236,7 @@ class GeGtk : public Ge {
static void activate_gradient_radlowerleft( GtkWidget *w, gpointer gectx);
static void activate_gradient_radupperright( GtkWidget *w, gpointer gectx);
static void activate_gradient_radlowerright( GtkWidget *w, gpointer gectx);
static void activate_reset_mode( GtkWidget *w, gpointer gectx);
static void activate_scale( GtkWidget *w, gpointer gectx);
static void activate_scale_double( GtkWidget *w, gpointer gectx);
static void activate_scale_half( GtkWidget *w, gpointer gectx);
......
......@@ -1539,6 +1539,12 @@ void Ge::activate_subgraphs()
subgraphs_new();
}
void Ge::activate_reset_mode()
{
graph->reset_mode( false, false);
status_msg( this, 0, 0);
}
void Ge::activate_rect( bool keep)
{
graph->set_mode( grow_eMode_Rect, keep);
......
......@@ -218,6 +218,7 @@ class Ge {
void activate_graph_attr();
void activate_open();
void activate_subgraphs();
void activate_reset_mode();
void activate_rect( bool keep);
void activate_rectrounded( bool keep);
void activate_line( bool keep);
......
......@@ -2238,6 +2238,33 @@ int Graph::edit_graph_attributes()
was_subgraph = is_subgraph();
return 1;
}
void Graph::reset_mode( bool select_clear, bool keep)
{
if ( grow_Mode( grow->ctx) == grow_eMode_PolyLine && current_polyline) {
if ( fill)
grow_SetObjectFill( current_polyline, 1);
if ( shadow)
grow_SetObjectShadow( current_polyline, 1);
journal_store( journal_eAction_CreateObject, current_polyline);
}
else if ( grow_Mode( grow->ctx) == grow_eMode_EditPolyLine ||
grow_Mode( grow->ctx) == grow_eMode_Scale) {
journal_store( journal_eAction_PostPropertiesSelect, 0);
}
grow_PolylineEnd( grow->ctx);
current_polyline = 0;
grow_SetMode( grow->ctx, grow_eMode_Edit);
grow_EnableHighlight( grow->ctx);
// grow_SelectClear( grow->ctx);
grow_SetMoveRestrictions( grow->ctx, glow_eMoveRestriction_No, 0, 0, NULL);
grow_SetScaleEqual( grow->ctx, 0);
keep_mode = keep;
if ( select_clear)
grow_SelectClear( grow->ctx);
}
//
// Callbacks from grow
//
......@@ -2464,27 +2491,8 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
break;
}
case glow_eEvent_MB3Click:
if ( grow_Mode( graph->grow->ctx) == grow_eMode_PolyLine && graph->current_polyline) {
if ( graph->fill)
grow_SetObjectFill( graph->current_polyline, 1);
if ( graph->shadow)
grow_SetObjectShadow( graph->current_polyline, 1);
graph->journal_store( journal_eAction_CreateObject, graph->current_polyline);
}
else if ( grow_Mode( graph->grow->ctx) == grow_eMode_EditPolyLine ||
grow_Mode( graph->grow->ctx) == grow_eMode_Scale) {
graph->journal_store( journal_eAction_PostPropertiesSelect, 0);
}
graph->reset_mode( true, false);
grow_PolylineEnd( graph->grow->ctx);
graph->current_polyline = 0;
grow_SetMode( graph->grow->ctx, grow_eMode_Edit);
grow_EnableHighlight( graph->grow->ctx);
grow_SelectClear( graph->grow->ctx);
grow_SetMoveRestrictions( graph->grow->ctx, glow_eMoveRestriction_No, 0, 0, NULL);
grow_SetScaleEqual( graph->grow->ctx, 0);
graph->keep_mode = false;
if ( graph->cursor_motion_cb)
(graph->cursor_motion_cb) (graph->parent_ctx, event->any.x,
event->any.y);
......
......@@ -833,6 +833,11 @@ class Graph {
/*! /return Always 1 */
int edit_graph_attributes();
//! Reset mode.
/*! \param reset_clear Clear selection. */
/*! \param keep Do not reset the edit mode when an object is created */
void reset_mode( bool reset_clear, bool keep);
//! Clear the graph.
/*! Remove all objects and reset the graph. */
void clear_all();
......
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