[Bug 1708] New: XawScrollbarSetThumb does not change size of thumb.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Oct 25 13:57:52 PDT 2004

Please do not reply to this email: if you want to comment on the bug, go to          
the URL shown below and enter yourcomments there.   
           Summary: XawScrollbarSetThumb does not change size of thumb.
           Product: xorg
           Version: 6.8.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: Lib/Xaw
        AssignedTo: xorg-bugzilla-noise at freedesktop.org
        ReportedBy: arnold at skeeve.com

The XawScrollbarSetThumb function doesn't change the size of the thumb. It
remains the same size no matter what values are used.  This occurs on both
Fedora Core 1 and 2 and with the libraries built from the 6.8.1 tar balls.
Here is a test program, extracted from my larger program.


Arnold Robbins
 * scroll.c --- try to figure out scrollbar.
 * Arnold Robbins
 * arnold at skeeve.com

#include <stdio.h>
#include <getopt.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/cursorfont.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Scrollbar.h>

typedef struct _instance_variables
    Pixel highColor;
    Pixel lowColor;
    Pixel criticalColor;
    Pixel chargingColor;
    Pixel foreground;
    int highValue;
    int lowValue;
    String geometry;
    int delay;
    Boolean displayPercent;
} instance_variable_rec;

static XtAppContext app_context;
static Widget scrollbar;
static Widget topLevel;
static Widget command;
static XtIntervalId timerId;
static instance_variable_rec iv;
static int debug;

#define CHAR_COUNT 5

static void update(XtPointer client_data, XtIntervalId * id)
    char buf[128];
    static int i = 1;

    sprintf(buf, "% 2d%%", i);

    XtVaSetValues(command, XtNlabel, buf, NULL);

fprintf(stderr, "i = %d\n", i); fflush(stderr);
    XawScrollbarSetThumb(scrollbar, 0.0001, (i / 100.0));
    i += 5;

if (i >= 100) exit(1);
    timerId = XtAppAddTimeOut(app_context, 1000 * iv.delay + 500,
			      update, app_context);

static void press(Widget w, XtPointer client_data, XtPointer call_data)
    iv.displayPercent = !iv.displayPercent;
    timerId = XtAppAddTimeOut(app_context, 0, update, app_context);
    if (debug)
	printf("displayPercent = %d\n", iv.displayPercent);

static XrmOptionDescRec options[] =
    {"-highcolor", "*highColor", XrmoptionSepArg, NULL},
    {"-lowcolor", "*lowColor", XrmoptionSepArg, NULL},
    {"-criticalcolor", "*criticalColor", XrmoptionSepArg, NULL},
    {"-chargingcolor", "*chargingColor", XrmoptionSepArg, NULL},
    {"-highvalue", "*highValue", XrmoptionSepArg, NULL},
    {"-lowvalue", "*lowValue", XrmoptionSepArg, NULL},
    {"-delay", "*delay", XrmoptionSepArg, NULL},
    {"-percent", "*percent", XrmoptionNoArg, (XtPointer) "true"},

#define offset(field) XtOffsetOf( instance_variable_rec, field )
static XtResource resources[] =
    {"highColor", XtCForeground, XtRPixel, sizeof(Pixel),
     offset(highColor), XtRString, "green"},
    {"lowColor", XtCForeground, XtRPixel, sizeof(Pixel),
     offset(lowColor), XtRString, "yellow"},
    {"criticalColor", XtCForeground, XtRPixel, sizeof(Pixel),
     offset(criticalColor), XtRString, "red"},
    {"chargingColor", XtCForeground, XtRPixel, sizeof(Pixel),
     offset(chargingColor), XtRString, "blue"},
    {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
     offset(foreground), XtRString, XtDefaultForeground},
    {"highValue", XtCValue, XtRInt, sizeof(int),
     offset(highValue), XtRImmediate, (XtPointer) 50},
    {"lowValue", XtCValue, XtRInt, sizeof(int),
     offset(lowValue), XtRImmediate, (XtPointer) 10},
    {"geometry", XtCString, XtRString, sizeof(String),
     offset(geometry), XtRString, (XtPointer) "10x100"},
    {"delay", XtCValue, XtRInt, sizeof(int),
     offset(delay), XtRImmediate, (XtPointer) 1},
    {"percent", XtCValue, XtRBoolean, sizeof(Boolean),
     offset(displayPercent), XtRImmediate, (XtPointer) FALSE},

int main(int argc, char **argv)
    Cursor cursor;
    int c;
    Widget form;
    XFontStruct *fs;
    int fontWidth, fontHeight;
    int x = 0, y = 0, height = 10, width = 100;

    topLevel = XtVaAppInitialize(&app_context, "XAcpi",
				 options, XtNumber(options),
				 &argc, argv, NULL, NULL);

			      NULL, 0);

    if (iv.delay < 1)
	iv.delay = 1;

    XParseGeometry(iv.geometry, &x, &y, &width, &height);

    if (debug)
	printf("highColor = %ld\n", iv.highColor);
	printf("lowColor = %ld\n", iv.lowColor);
	printf("criticalColor = %ld\n", iv.criticalColor);
	printf("chargingColor = %ld\n", iv.chargingColor);
	printf("foreground = %ld\n", iv.foreground);
	printf("highValue = %d\n", iv.highValue);
	printf("lowValue = %d\n", iv.lowValue);
	printf("geometry = %s\n", iv.geometry);

    cursor = XCreateFontCursor(XtDisplay(topLevel), XC_top_left_arrow);

    form = XtVaCreateManagedWidget("form",
				   formWidgetClass, topLevel,
				   XtNorientation, XtorientHorizontal,
				   XtNborderWidth, 0,
				   XtNdefaultDistance, 2,

    command = XtVaCreateManagedWidget("command",
				      commandWidgetClass, form,
				      XtNleft, XtChainLeft,
				      XtNhighlightThickness, 0,
				      XtNinternalHeight, 0,
				      XtNinternalWidth, 0,
				      XtNborderWidth, 0,
				      XtNlabel, "",
				      XtNresize, FALSE,

    XtVaGetValues(command, XtNfont, &fs, NULL);
    fontWidth = fs->max_bounds.width;
    fontHeight = fs->max_bounds.ascent + fs->max_bounds.descent;
    XtVaSetValues(command, XtNwidth, fontWidth * CHAR_COUNT, NULL);

    if (debug)
	int tmp = (width > fontWidth * CHAR_COUNT - 6)
	? width - fontWidth * CHAR_COUNT - 6
	: fontWidth * CHAR_COUNT;

	printf("width = %d, using %d + %d = %d\n",
	width, fontWidth * CHAR_COUNT, tmp, fontWidth * CHAR_COUNT + tmp);

fprintf(stderr, "fontWidth * CHAR_COUNT = %d\n", fontWidth *
    scrollbar = XtVaCreateManagedWidget("scrollbar",
					scrollbarWidgetClass, form,
					XtNhorizDistance, 3,
					XtNfromHoriz, command,
				      XtNorientation, XtorientHorizontal,
					XtNscrollHCursor, cursor,
					XtNthickness, fontHeight,
			  XtNlength, (width > fontWidth * CHAR_COUNT - 6)
				     ? width - fontWidth * CHAR_COUNT - 6
					: fontWidth * CHAR_COUNT,
			  XtNlength,  fontWidth * CHAR_COUNT,

    XawScrollbarSetThumb(scrollbar, 0.0, 0.0);
		  XtNtranslations, XtParseTranslationTable(""), NULL);

    XtAddCallback(command, XtNcallback, press, NULL);

    timerId = XtAppAddTimeOut(app_context, 0, update, app_context);

    return 0;
Configure bugmail: https://freedesktop.org/bugzilla/userprefs.cgi?tab=email       
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

More information about the xorg-bugzilla-noise mailing list