Scrollbar.java (next_scrollbar_number): New field.
2004-02-05 Thomas Fitzsimmons <fitzsim@redhat.com> * java/awt/Scrollbar.java (next_scrollbar_number): New field. (Scrollbar (int, int, int, int, int)): Make default page increment 10. (setValues): Only call peer.setValues if one of the values has changed. (generateName): New method. (getUniqueLong): New method. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c (range_scrollbar): Remove structure. (post_adjustment_event): Remove function. (post_change_event): Accept jobject argument. (create): Cast jints to gdoubles. Round scrollbar values to the nearest integer. Clamp min, max and value settings. (connectJObject): Connect hook to widget->window. (connectSignals): Remove range_scrollbar structure variables. Remove "move-slider" connection. Pass global peer reference to "value-changed" callback. (setLineIncrement): Cast jint value to gdouble. (setPageIncrement): Likewise. (setValues): Likewise. Clamp min, max and value settings. From-SVN: r77332
This commit is contained in:
parent
6039a93dd7
commit
bc1ec7f70e
3 changed files with 100 additions and 107 deletions
|
@ -120,6 +120,11 @@ private AdjustmentListener adjustment_listeners;
|
|||
|
||||
private transient boolean valueIsAdjusting = false;
|
||||
|
||||
/*
|
||||
* The number used to generate the name returned by getName.
|
||||
*/
|
||||
private static transient long next_scrollbar_number = 0;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
|
@ -194,9 +199,8 @@ Scrollbar(int orientation, int value, int visibleAmount, int minimum,
|
|||
// Default is 1 according to online docs.
|
||||
lineIncrement = 1;
|
||||
|
||||
pageIncrement = (maximum - minimum) / 5;
|
||||
if (pageIncrement == 0)
|
||||
pageIncrement = 1;
|
||||
// Default is 10 according to javadocs.
|
||||
pageIncrement = 10;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -394,15 +398,17 @@ setValues(int value, int visibleAmount, int minimum, int maximum)
|
|||
if (visibleAmount > maximum - minimum)
|
||||
visibleAmount = maximum - minimum;
|
||||
|
||||
ScrollbarPeer peer = (ScrollbarPeer) getPeer ();
|
||||
if (peer != null
|
||||
&& (this.value != value || this.visibleAmount != visibleAmount
|
||||
|| this.minimum != minimum || this.maximum != maximum))
|
||||
peer.setValues(value, visibleAmount, minimum, maximum);
|
||||
|
||||
this.value = value;
|
||||
this.visibleAmount = visibleAmount;
|
||||
this.minimum = minimum;
|
||||
this.maximum = maximum;
|
||||
|
||||
ScrollbarPeer sp = (ScrollbarPeer)getPeer();
|
||||
if (sp != null)
|
||||
sp.setValues(value, visibleAmount, minimum, maximum);
|
||||
|
||||
int range = maximum - minimum;
|
||||
if (lineIncrement > range)
|
||||
{
|
||||
|
@ -411,8 +417,8 @@ setValues(int value, int visibleAmount, int minimum, int maximum)
|
|||
else
|
||||
lineIncrement = range;
|
||||
|
||||
if (sp != null)
|
||||
sp.setLineIncrement(lineIncrement);
|
||||
if (peer != null)
|
||||
peer.setLineIncrement(lineIncrement);
|
||||
}
|
||||
|
||||
if (pageIncrement > range)
|
||||
|
@ -422,8 +428,8 @@ setValues(int value, int visibleAmount, int minimum, int maximum)
|
|||
else
|
||||
pageIncrement = range;
|
||||
|
||||
if (sp != null)
|
||||
sp.setPageIncrement(pageIncrement);
|
||||
if (peer != null)
|
||||
peer.setPageIncrement(pageIncrement);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -503,9 +509,9 @@ setLineIncrement(int lineIncrement)
|
|||
|
||||
this.lineIncrement = lineIncrement;
|
||||
|
||||
ScrollbarPeer sp = (ScrollbarPeer) getPeer ();
|
||||
if (sp != null)
|
||||
sp.setLineIncrement (this.lineIncrement);
|
||||
ScrollbarPeer peer = (ScrollbarPeer) getPeer ();
|
||||
if (peer != null)
|
||||
peer.setLineIncrement (this.lineIncrement);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -584,9 +590,9 @@ setPageIncrement(int pageIncrement)
|
|||
|
||||
this.pageIncrement = pageIncrement;
|
||||
|
||||
ScrollbarPeer sp = (ScrollbarPeer) getPeer ();
|
||||
if (sp != null)
|
||||
sp.setPageIncrement (this.pageIncrement);
|
||||
ScrollbarPeer peer = (ScrollbarPeer) getPeer ();
|
||||
if (peer != null)
|
||||
peer.setPageIncrement (this.pageIncrement);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -746,5 +752,20 @@ paramString()
|
|||
{
|
||||
this.valueIsAdjusting = valueIsAdjusting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a unique name for this scroll bar.
|
||||
*
|
||||
* @return A unique name for this scroll bar.
|
||||
*/
|
||||
String generateName ()
|
||||
{
|
||||
return "scrollbar" + getUniqueLong ();
|
||||
}
|
||||
|
||||
private static synchronized long getUniqueLong ()
|
||||
{
|
||||
return next_scrollbar_number++;
|
||||
}
|
||||
} // class Scrollbar
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue