From 0d303600c61311172df0b8daec732d982d2a656a Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 20 Dec 2002 11:12:21 +0000 Subject: Fixed problem with vertical scrollbar being moved out of real range leading to inability to scroll at times. Added moveThumb argument to ScrollTo to allow smoother manipulation of thumb on GTK+ --- gtk/ScintillaGTK.cxx | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 3c87be91c..bd84e1190 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1118,6 +1118,17 @@ void ScintillaGTK::Resize(int width, int height) { ChangeSize(); } +static void SetAdjustmentValue(GtkObject *object, int value) { + GtkAdjustment *adjustment = GTK_ADJUSTMENT(object); + int maxValue = static_cast( + adjustment->upper - adjustment->page_size); + if (value > maxValue) + value = maxValue; + if (value < 0) + value = 0; + gtk_adjustment_set_value(adjustment, value); +} + gint ScintillaGTK::PressThis(GdkEventButton *event) { //Platform::DebugPrintf("Press %x time=%d state = %x button = %x\n",this,event->time, event->state, event->button); // Do not use GTK+ double click events as Scintilla has its own double click detection @@ -1169,19 +1180,15 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) { } else if (event->button == 4) { // Wheel scrolling up (only xwin gtk does it this way) if (ctrl) - gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustmenth), ( - (xOffset) / 2 ) - 6); + SetAdjustmentValue(adjustmenth, (xOffset / 2) - 6); else - gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustmentv), - topLine - 3); - } else if ( event->button == 5 ) { + SetAdjustmentValue(adjustmentv, topLine - 3); + } else if (event->button == 5) { // Wheel scrolling down (only xwin gtk does it this way) if (ctrl) - gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustmenth), ( - (xOffset) / 2 ) + 6); + SetAdjustmentValue(adjustmenth, (xOffset / 2) + 6); else - gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustmentv), - topLine + 3); + SetAdjustmentValue(adjustmentv, topLine + 3); } return FALSE; } @@ -1477,13 +1484,11 @@ gint ScintillaGTK::Expose(GtkWidget *, GdkEventExpose *ose, ScintillaGTK *sciThi } void ScintillaGTK::ScrollSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) { - //Platform::DebugPrintf("Scrolly %g %x\n",adj->value,p); - sciThis->ScrollTo((int)adj->value); + sciThis->ScrollTo(static_cast(adj->value), false); } void ScintillaGTK::ScrollHSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) { - //Platform::DebugPrintf("Scrollyh %g %x\n",adj->value,p); - sciThis->HorizontalScrollTo((int)adj->value * 2); + sciThis->HorizontalScrollTo(static_cast(adj->value * 2)); } void ScintillaGTK::SelectionReceived(GtkWidget *widget, @@ -1739,4 +1744,3 @@ void scintilla_set_id(ScintillaObject *sci, int id) { void scintilla_release_resources(void) { Platform_Finalise(); } - -- cgit v1.2.3