Commit 1729c14d authored by claes's avatar claes

Timer added to scrollbar update

parent a856b929
/* /*
* Proview $Id: flow_browwidget_gtk.cpp,v 1.4 2007-02-06 15:13:34 claes Exp $ * Proview $Id: flow_browwidget_gtk.cpp,v 1.5 2007-10-17 07:19:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -57,6 +57,12 @@ struct _BrowWidgetGtk { ...@@ -57,6 +57,12 @@ struct _BrowWidgetGtk {
int scroll_v_ignore; int scroll_v_ignore;
gdouble scroll_h_value; gdouble scroll_h_value;
gdouble scroll_v_value; gdouble scroll_v_value;
int scroll_h_pagesize;
int scroll_v_pagesize;
int scroll_h_upper;
int scroll_v_upper;
gint scroll_timerid;
flow_sScroll scroll_data;
}; };
struct _BrowWidgetGtkClass { struct _BrowWidgetGtkClass {
...@@ -64,12 +70,26 @@ struct _BrowWidgetGtkClass { ...@@ -64,12 +70,26 @@ struct _BrowWidgetGtkClass {
}; };
G_DEFINE_TYPE( BrowWidgetGtk, browwidgetgtk, GTK_TYPE_DRAWING_AREA); G_DEFINE_TYPE( BrowWidgetGtk, browwidgetgtk, GTK_TYPE_DRAWING_AREA);
static gboolean scroll_callback_cb( void *d);
static void scroll_callback( flow_sScroll *data) static void scroll_callback( flow_sScroll *data)
{ {
browwidget_sScroll *scroll_data; browwidget_sScroll *scroll_data = (browwidget_sScroll *) data->scroll_data;
if ( ((BrowWidgetGtk *)scroll_data->brow)->scroll_timerid)
g_source_remove( ((BrowWidgetGtk *)scroll_data->brow)->scroll_timerid);
((BrowWidgetGtk *)scroll_data->brow)->scroll_timerid =
g_timeout_add( 200, scroll_callback_cb, scroll_data->brow);
((BrowWidgetGtk *)scroll_data->brow)->scroll_data = *data;
}
scroll_data = (browwidget_sScroll *) data->scroll_data; static gboolean scroll_callback_cb( void *d)
{
flow_sScroll *data = &((BrowWidgetGtk *)d)->scroll_data;
browwidget_sScroll *scroll_data = (browwidget_sScroll *) data->scroll_data;
((BrowWidgetGtk *)scroll_data->brow)->scroll_timerid = 0;
if ( data->total_width <= data->window_width) { if ( data->total_width <= data->window_width) {
if ( data->offset_x == 0) if ( data->offset_x == 0)
...@@ -115,29 +135,47 @@ static void scroll_callback( flow_sScroll *data) ...@@ -115,29 +135,47 @@ static void scroll_callback( flow_sScroll *data)
if ( scroll_data->scroll_h_managed) { if ( scroll_data->scroll_h_managed) {
((BrowWidgetGtk *)scroll_data->brow)->scroll_h_ignore = 1; ((BrowWidgetGtk *)scroll_data->brow)->scroll_h_ignore = 1;
g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment, if ( data->window_width != ((BrowWidgetGtk *)scroll_data->brow)->scroll_h_pagesize ||
"upper", (gdouble)data->total_width, data->total_width != ((BrowWidgetGtk *)scroll_data->brow)->scroll_h_upper) {
"page-size", (gdouble)data->window_width, g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment,
"value", (gdouble)data->offset_x, "upper", (gdouble)data->total_width,
NULL); "page-size", (gdouble)data->window_width,
gtk_adjustment_changed( "value", (gdouble)data->offset_x,
((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment); NULL);
gtk_adjustment_changed( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment);
}
else {
g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment,
"value", (gdouble)data->offset_x,
NULL);
gtk_adjustment_value_changed( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment);
}
((BrowWidgetGtk *)scroll_data->brow)->scroll_h_value = (gdouble)data->offset_x; ((BrowWidgetGtk *)scroll_data->brow)->scroll_h_value = (gdouble)data->offset_x;
((BrowWidgetGtk *)scroll_data->brow)->scroll_h_pagesize = data->window_width;
((BrowWidgetGtk *)scroll_data->brow)->scroll_h_upper = data->total_width;
} }
if ( scroll_data->scroll_v_managed) { if ( scroll_data->scroll_v_managed) {
((BrowWidgetGtk *)scroll_data->brow)->scroll_v_ignore = 1; ((BrowWidgetGtk *)scroll_data->brow)->scroll_v_ignore = 1;
g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment, if ( data->window_height != ((BrowWidgetGtk *)scroll_data->brow)->scroll_v_pagesize ||
"upper", (gdouble)data->total_height, data->total_height != ((BrowWidgetGtk *)scroll_data->brow)->scroll_v_upper) {
"page-size", (gdouble)data->window_height, g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment,
// "value", (gdouble)data->offset_y, "upper", (gdouble)data->total_height,
NULL); "page-size", (gdouble)data->window_height,
gtk_adjustment_changed( // "value", (gdouble)data->offset_y,
((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment); NULL);
((BrowWidgetGtk *)scroll_data->brow)->scroll_v_ignore = 1; gtk_adjustment_changed( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment);
gtk_range_set_value( GTK_RANGE(scroll_data->scroll_v), (gdouble)data->offset_y); ((BrowWidgetGtk *)scroll_data->brow)->scroll_v_ignore = 1;
gtk_range_set_value( GTK_RANGE(scroll_data->scroll_v), (gdouble)data->offset_y);
}
else {
gtk_range_set_value( GTK_RANGE(scroll_data->scroll_v), (gdouble)data->offset_y);
}
((BrowWidgetGtk *)scroll_data->brow)->scroll_v_value = (gdouble)data->offset_y; ((BrowWidgetGtk *)scroll_data->brow)->scroll_v_value = (gdouble)data->offset_y;
((BrowWidgetGtk *)scroll_data->brow)->scroll_v_pagesize = data->window_height;
((BrowWidgetGtk *)scroll_data->brow)->scroll_v_upper = data->total_height;
} }
return FALSE;
} }
static void scroll_h_action( GtkWidget *w, static void scroll_h_action( GtkWidget *w,
...@@ -299,14 +337,26 @@ static void browwidgetgtk_realize( GtkWidget *widget) ...@@ -299,14 +337,26 @@ static void browwidgetgtk_realize( GtkWidget *widget)
} }
static void browwidgetgtk_destroy( GtkObject *object)
{
BrowWidgetGtk *brow = (BrowWidgetGtk *)object;
if ( brow->scroll_timerid)
g_source_remove( brow->scroll_timerid);
GTK_OBJECT_CLASS( browwidgetgtk_parent_class)->destroy( object);
}
static void browwidgetgtk_class_init( BrowWidgetGtkClass *klass) static void browwidgetgtk_class_init( BrowWidgetGtkClass *klass)
{ {
GtkWidgetClass *widget_class; GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);
widget_class = GTK_WIDGET_CLASS( klass); widget_class = GTK_WIDGET_CLASS( klass);
widget_class->realize = browwidgetgtk_realize; widget_class->realize = browwidgetgtk_realize;
widget_class->expose_event = browwidgetgtk_expose; widget_class->expose_event = browwidgetgtk_expose;
widget_class->event = browwidgetgtk_event; widget_class->event = browwidgetgtk_event;
widget_class->grab_focus = browwidgetgtk_grab_focus; widget_class->grab_focus = browwidgetgtk_grab_focus;
object_class->destroy = browwidgetgtk_destroy;
} }
static void browwidgetgtk_init( BrowWidgetGtk *flow) static void browwidgetgtk_init( BrowWidgetGtk *flow)
......
/* /*
* Proview $Id: flow_widget_gtk.cpp,v 1.4 2007-02-06 15:13:34 claes Exp $ * Proview $Id: flow_widget_gtk.cpp,v 1.5 2007-10-17 07:19:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -57,6 +57,12 @@ struct _FlowWidgetGtk { ...@@ -57,6 +57,12 @@ struct _FlowWidgetGtk {
int scroll_v_ignore; int scroll_v_ignore;
gdouble scroll_h_value; gdouble scroll_h_value;
gdouble scroll_v_value; gdouble scroll_v_value;
int scroll_h_pagesize;
int scroll_v_pagesize;
int scroll_h_upper;
int scroll_v_upper;
gint scroll_timerid;
flow_sScroll scroll_data;
}; };
struct _FlowWidgetGtkClass { struct _FlowWidgetGtkClass {
...@@ -64,12 +70,26 @@ struct _FlowWidgetGtkClass { ...@@ -64,12 +70,26 @@ struct _FlowWidgetGtkClass {
}; };
G_DEFINE_TYPE( FlowWidgetGtk, flowwidgetgtk, GTK_TYPE_DRAWING_AREA); G_DEFINE_TYPE( FlowWidgetGtk, flowwidgetgtk, GTK_TYPE_DRAWING_AREA);
static gboolean scroll_callback_cb( void *d);
static void scroll_callback( flow_sScroll *data) static void scroll_callback( flow_sScroll *data)
{ {
flowwidget_sScroll *scroll_data; flowwidget_sScroll *scroll_data = (flowwidget_sScroll *) data->scroll_data;
if ( ((FlowWidgetGtk *)scroll_data->flow)->scroll_timerid)
g_source_remove( ((FlowWidgetGtk *)scroll_data->flow)->scroll_timerid);
((FlowWidgetGtk *)scroll_data->flow)->scroll_timerid =
g_timeout_add( 200, scroll_callback_cb, scroll_data->flow);
((FlowWidgetGtk *)scroll_data->flow)->scroll_data = *data;
}
scroll_data = (flowwidget_sScroll *) data->scroll_data; static gboolean scroll_callback_cb( void *d)
{
flow_sScroll *data = &((FlowWidgetGtk *)d)->scroll_data;
flowwidget_sScroll *scroll_data = (flowwidget_sScroll *) data->scroll_data;
((FlowWidgetGtk *)scroll_data->flow)->scroll_timerid = 0;
if ( data->total_width <= data->window_width) { if ( data->total_width <= data->window_width) {
if ( data->offset_x == 0) if ( data->offset_x == 0)
...@@ -115,33 +135,52 @@ static void scroll_callback( flow_sScroll *data) ...@@ -115,33 +135,52 @@ static void scroll_callback( flow_sScroll *data)
if ( scroll_data->scroll_h_managed) { if ( scroll_data->scroll_h_managed) {
((FlowWidgetGtk *)scroll_data->flow)->scroll_h_ignore = 1; ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_ignore = 1;
g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment, if ( data->window_width != ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_pagesize ||
"upper", (gdouble)data->total_width, data->total_width != ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_upper) {
"page-size", (gdouble)data->window_width, g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment,
"value", (gdouble)data->offset_x, "upper", (gdouble)data->total_width,
NULL); "page-size", (gdouble)data->window_width,
gtk_adjustment_changed( "value", (gdouble)data->offset_x,
((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment); NULL);
gtk_adjustment_changed( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment);
}
else {
gtk_range_set_value( GTK_RANGE(scroll_data->scroll_v), (gdouble)data->offset_y);
}
((FlowWidgetGtk *)scroll_data->flow)->scroll_h_value = (gdouble)data->offset_x; ((FlowWidgetGtk *)scroll_data->flow)->scroll_h_value = (gdouble)data->offset_x;
((FlowWidgetGtk *)scroll_data->flow)->scroll_h_pagesize = data->window_width;
((FlowWidgetGtk *)scroll_data->flow)->scroll_h_upper = data->total_width;
} }
if ( scroll_data->scroll_v_managed) { if ( scroll_data->scroll_v_managed) {
((FlowWidgetGtk *)scroll_data->flow)->scroll_v_ignore = 1; ((FlowWidgetGtk *)scroll_data->flow)->scroll_v_ignore = 1;
g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment, if ( data->window_height != ((FlowWidgetGtk *)scroll_data->flow)->scroll_v_pagesize ||
"upper", (gdouble)data->total_height, data->total_height != ((FlowWidgetGtk *)scroll_data->flow)->scroll_v_upper) {
"page-size", (gdouble)data->window_height, g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment,
"value", (gdouble)data->offset_y, "upper", (gdouble)data->total_height,
NULL); "page-size", (gdouble)data->window_height,
gtk_adjustment_changed( "value", (gdouble)data->offset_y,
((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment); NULL);
gtk_adjustment_changed( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment);
}
else {
g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment,
"value", (gdouble)data->offset_y,
NULL);
gtk_adjustment_value_changed( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment);
}
((FlowWidgetGtk *)scroll_data->flow)->scroll_v_value = (gdouble)data->offset_y; ((FlowWidgetGtk *)scroll_data->flow)->scroll_v_value = (gdouble)data->offset_y;
((FlowWidgetGtk *)scroll_data->flow)->scroll_h_pagesize = data->window_width;
((FlowWidgetGtk *)scroll_data->flow)->scroll_h_upper = data->total_width;
} }
return FALSE;
} }
static void scroll_h_action( GtkWidget *w, static void scroll_h_action( GtkWidget *w,
gpointer data) gpointer data)
{ {
FlowWidgetGtk *floww = (FlowWidgetGtk *)data; FlowWidgetGtk *floww = (FlowWidgetGtk *)data;
if ( floww->scroll_h_ignore) { if ( floww->scroll_h_ignore) {
floww->scroll_h_ignore = 0; floww->scroll_h_ignore = 0;
return; return;
...@@ -289,13 +328,24 @@ static void flowwidgetgtk_realize( GtkWidget *widget) ...@@ -289,13 +328,24 @@ static void flowwidgetgtk_realize( GtkWidget *widget)
} }
static void flowwidgetgtk_destroy( GtkObject *object)
{
FlowWidgetGtk *flow = (FlowWidgetGtk *)object;
if ( flow->scroll_timerid)
g_source_remove( flow->scroll_timerid);
GTK_OBJECT_CLASS( flowwidgetgtk_parent_class)->destroy( object);
}
static void flowwidgetgtk_class_init( FlowWidgetGtkClass *klass) static void flowwidgetgtk_class_init( FlowWidgetGtkClass *klass)
{ {
GtkWidgetClass *widget_class; GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
widget_class = GTK_WIDGET_CLASS( klass); GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);
widget_class->realize = flowwidgetgtk_realize; widget_class->realize = flowwidgetgtk_realize;
widget_class->expose_event = flowwidgetgtk_expose; widget_class->expose_event = flowwidgetgtk_expose;
widget_class->event = flowwidgetgtk_event; widget_class->event = flowwidgetgtk_event;
object_class->destroy = flowwidgetgtk_destroy;
} }
static void flowwidgetgtk_init( FlowWidgetGtk *flow) static void flowwidgetgtk_init( FlowWidgetGtk *flow)
......
/* /*
* Proview $Id: glow_growwidget_gtk.cpp,v 1.4 2007-02-06 15:13:34 claes Exp $ * Proview $Id: glow_growwidget_gtk.cpp,v 1.5 2007-10-17 07:19:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -59,6 +59,12 @@ struct _GrowWidgetGtk { ...@@ -59,6 +59,12 @@ struct _GrowWidgetGtk {
int scroll_v_ignore; int scroll_v_ignore;
gdouble scroll_h_value; gdouble scroll_h_value;
gdouble scroll_v_value; gdouble scroll_v_value;
int scroll_h_pagesize;
int scroll_v_pagesize;
int scroll_h_upper;
int scroll_v_upper;
gint scroll_timerid;
glow_sScroll scroll_data;
}; };
struct _GrowWidgetGtkClass { struct _GrowWidgetGtkClass {
...@@ -66,12 +72,27 @@ struct _GrowWidgetGtkClass { ...@@ -66,12 +72,27 @@ struct _GrowWidgetGtkClass {
}; };
G_DEFINE_TYPE( GrowWidgetGtk, growwidgetgtk, GTK_TYPE_DRAWING_AREA); G_DEFINE_TYPE( GrowWidgetGtk, growwidgetgtk, GTK_TYPE_DRAWING_AREA);
static gboolean scroll_callback_cb( void *d);
static void scroll_callback( glow_sScroll *data) static void scroll_callback( glow_sScroll *data)
{ {
growwidget_sScroll *scroll_data; growwidget_sScroll *scroll_data = (growwidget_sScroll *) data->scroll_data;
if ( ((GrowWidgetGtk *)scroll_data->grow)->scroll_timerid)
g_source_remove( ((GrowWidgetGtk *)scroll_data->grow)->scroll_timerid);
((GrowWidgetGtk *)scroll_data->grow)->scroll_timerid =
g_timeout_add( 200, scroll_callback_cb, scroll_data->grow);
((GrowWidgetGtk *)scroll_data->grow)->scroll_data = *data;
}
scroll_data = (growwidget_sScroll *) data->scroll_data; static gboolean scroll_callback_cb( void *d)
{
glow_sScroll *data = &((GrowWidgetGtk *)d)->scroll_data;
growwidget_sScroll *scroll_data = (growwidget_sScroll *) data->scroll_data;
((GrowWidgetGtk *)scroll_data->grow)->scroll_timerid = 0;
if ( data->total_width <= data->window_width) { if ( data->total_width <= data->window_width) {
if ( data->offset_x == 0) if ( data->offset_x == 0)
...@@ -115,6 +136,48 @@ static void scroll_callback( glow_sScroll *data) ...@@ -115,6 +136,48 @@ static void scroll_callback( glow_sScroll *data)
if ( data->window_height < 1) if ( data->window_height < 1)
data->window_height = 1; data->window_height = 1;
if ( scroll_data->scroll_h_managed) {
((GrowWidgetGtk *)scroll_data->grow)->scroll_h_ignore = 1;
if ( data->window_width != ((GrowWidgetGtk *)scroll_data->grow)->scroll_h_pagesize ||
data->total_width != ((GrowWidgetGtk *)scroll_data->grow)->scroll_h_upper) {
g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment,
"upper", (gdouble)data->total_width,
"page-size", (gdouble)data->window_width,
"value", (gdouble)data->offset_x,
NULL);
gtk_adjustment_changed( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment);
}
else {
gtk_range_set_value( GTK_RANGE(scroll_data->scroll_v), (gdouble)data->offset_y);
}
((GrowWidgetGtk *)scroll_data->grow)->scroll_h_value = (gdouble)data->offset_x;
((GrowWidgetGtk *)scroll_data->grow)->scroll_h_pagesize = data->window_width;
((GrowWidgetGtk *)scroll_data->grow)->scroll_h_upper = data->total_width;
}
if ( scroll_data->scroll_v_managed) {
((GrowWidgetGtk *)scroll_data->grow)->scroll_v_ignore = 1;
if ( data->window_height != ((GrowWidgetGtk *)scroll_data->grow)->scroll_v_pagesize ||
data->total_height != ((GrowWidgetGtk *)scroll_data->grow)->scroll_v_upper) {
g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment,
"upper", (gdouble)data->total_height,
"page-size", (gdouble)data->window_height,
"value", (gdouble)data->offset_y,
NULL);
gtk_adjustment_changed( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment);
}
else {
g_object_set( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment,
"value", (gdouble)data->offset_y,
NULL);
gtk_adjustment_value_changed( ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment);
}
((GrowWidgetGtk *)scroll_data->grow)->scroll_v_value = (gdouble)data->offset_y;
((GrowWidgetGtk *)scroll_data->grow)->scroll_h_pagesize = data->window_width;
((GrowWidgetGtk *)scroll_data->grow)->scroll_h_upper = data->total_width;
}
return FALSE;
#if 0
if ( scroll_data->scroll_h_managed) { if ( scroll_data->scroll_h_managed) {
((GrowWidgetGtk *)scroll_data->grow)->scroll_h_ignore = 1; ((GrowWidgetGtk *)scroll_data->grow)->scroll_h_ignore = 1;
g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment, g_object_set( ((GtkScrollbar *)scroll_data->scroll_h)->range.adjustment,
...@@ -138,6 +201,7 @@ static void scroll_callback( glow_sScroll *data) ...@@ -138,6 +201,7 @@ static void scroll_callback( glow_sScroll *data)
((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment); ((GtkScrollbar *)scroll_data->scroll_v)->range.adjustment);
((GrowWidgetGtk *)scroll_data->grow)->scroll_v_value = (gdouble)data->offset_y; ((GrowWidgetGtk *)scroll_data->grow)->scroll_v_value = (gdouble)data->offset_y;
} }
#endif
} }
static void scroll_h_action( GtkWidget *w, static void scroll_h_action( GtkWidget *w,
...@@ -226,6 +290,8 @@ static void growwidgetgtk_destroy( GtkObject *object) ...@@ -226,6 +290,8 @@ static void growwidgetgtk_destroy( GtkObject *object)
{ {
GrowWidgetGtk *grow = (GrowWidgetGtk *)object; GrowWidgetGtk *grow = (GrowWidgetGtk *)object;
if ( grow->scroll_timerid)
g_source_remove( grow->scroll_timerid);
if ( grow->is_navigator) { if ( grow->is_navigator) {
((GrowCtx *)grow->grow_ctx)->no_nav = 1; ((GrowCtx *)grow->grow_ctx)->no_nav = 1;
} }
......
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