LessTiff application

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am a Windows programmer new to Linux and I am converting an existing
application to the motif clone, LessTiff. Everything went smoothly 'till
I got to scroll bars. The application so far is reproduced below. It all
works, except for the vertical scroll bar. It only shows a gray
rectangle where the scroll bar should be, no buttons, no slider - and no
sign of activity from the scroll bar call backs. My intent is to create
an application managed scroll window.

The resource file has no entries and is not shown here.

Regards,
Bill Bourke



// trace.cpp - motif trace utility.

#include <Xm/ScrolledW.h>
#include <Xm/ScrollBar.h>
#include <Xm/DrawingA.h>
#include <Xm/Label.h>
#include <stdio.h>


Widget appshell,
  scroller,
  vscroll,
  workwin;
       
static GC the_gc;
static XGCValues gc_values;
static XtGCMask gc_mask;

static Pixel WhiteColor, 
             BlackColor;


static void DrawEvt (Widget w, XtPointer, XEvent* event, Boolean*) {

    XDrawLine (XtDisplay (w), XtWindow (w), the_gc, 0, 0, 100, 100);
}


static void ExposeCB (Widget w, void* client_data, void* call_data) {

    XDrawLine (XtDisplay (w), XtWindow (w), the_gc, 100, 0, 0, 100);
}


static void ScrollCB (Widget w, void* client_data, void* call_data) {

    printf ("ScrollCB %d\n", ((XmScrollBarCallbackStruct*)
call_data)->reason);
}


int main (int argc, char* argv []) {

    // Create the application window and get some color contants.

    Arg arglist [2];
    appshell = XtInitialize (argv [0], "trace", NULL, 0, &argc, argv);
    BlackColor = BlackPixel (XtDisplay (appshell), DefaultScreen
(XtDisplay (appshell)));
    WhiteColor = WhitePixel (XtDisplay (appshell), DefaultScreen
(XtDisplay (appshell)));

    // Create the scrolled client window. Scrolling will be managed by
the application.
    
    scroller = XmCreateScrolledWindow (appshell, "Scroller", NULL, 0);
    XtSetArg (arglist [0], XmNheight, 400);
    XtSetArg (arglist [1], XmNwidth, 600);
    XtSetValues (scroller, arglist, 2);
    XtManageChild (scroller);

    // Create the draw window and give it a white background.

    workwin = XmCreateDrawingArea (scroller, "WorkWin", NULL, 0);
    XtManageChild (workwin);

    XtSetArg (arglist [0], XmNforeground, BlackColor);
    XtSetArg (arglist [1], XmNbackground, WhiteColor);
    XtSetValues (workwin, arglist, 2);
    
    // Create the graphics context for drawing lines.

    gc_values.foreground = BlackColor;
    gc_values.background = WhiteColor;
    gc_values.line_width = 1;
    gc_values.line_style = LineSolid;
    gc_mask = GCForeground | GCBackground | GCLineWidth, GCLineStyle;
    the_gc = XtGetGC (workwin, gc_mask, &gc_values);

    // Add callbacks and event handlers to the draw window.

    XtAddEventHandler (workwin, (ButtonPressMask | ButtonMotionMask),
FALSE, DrawEvt, NULL);
    XtAddCallback (workwin, XmNexposeCallback, ExposeCB, NULL);

    // Create the vertical scroll bar.

    vscroll = XmCreateScrollBar (appshell, "VScroll", NULL, 0);
    //XmScrollBarSetValues (vscroll, 20, 20, 10, 50, false);
    XtManageChild (vscroll);

    // Associate the vertical scroll bar and draw window with the scroll
window.

    XmScrolledWindowSetAreas (scroller, NULL, vscroll, workwin);

    // Add call backs for scroll events.

    XtAddCallback (vscroll, XmNdecrementCallback,     ScrollCB, NULL);
    XtAddCallback (vscroll, XmNdragCallback,          ScrollCB, NULL);
    XtAddCallback (vscroll, XmNincrementCallback,     ScrollCB, NULL);
    XtAddCallback (vscroll, XmNpageDecrementCallback, ScrollCB, NULL);
    XtAddCallback (vscroll, XmNpageIncrementCallback, ScrollCB, NULL);
    XtAddCallback (vscroll, XmNtoBottomCallback,      ScrollCB, NULL);
    XtAddCallback (vscroll, XmNtoTopCallback,         ScrollCB, NULL);
    XtAddCallback (vscroll, XmNvalueChangedCallback,  ScrollCB, NULL);

    // Go.

    XtRealizeWidget (appshell);
    XtMainLoop ();
}

_______________________________________________

Newbie@XFree86.Org
*** To unsubscribe , or change message options, see:
http://XFree86.Org/mailman/listinfo/newbie

[Index of Archives]     [XFree86]     [Xfree86 Xpert]     [X.org]     [IETF Annouce]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Picture Sharing]     [Linux Security]     [Linux RAID]

  Powered by Linux