1 #include <stdio.h>
2 #include <Xm/Xm.h>
3 #include <Xm/ScrollBar.h>
4 
dragCallback(Widget w,XtPointer clientData,XtPointer callData)5 void dragCallback(Widget w, XtPointer clientData, XtPointer callData)
6 {
7     XmScrollBarCallbackStruct *cbs = (XmScrollBarCallbackStruct *)callData;
8 
9     printf ("dragCallback: %d\n", cbs->value);
10 }
11 
decrementCallback(Widget w,XtPointer clientData,XtPointer callData)12 void decrementCallback(Widget w, XtPointer clientData, XtPointer callData)
13 {
14     printf ("decrementCallback\n");
15 }
16 
incrementCallback(Widget w,XtPointer clientData,XtPointer callData)17 void incrementCallback(Widget w, XtPointer clientData, XtPointer callData)
18 {
19     printf ("incrementCallback\n");
20 }
pageDecrementCallback(Widget w,XtPointer clientData,XtPointer callData)21 void pageDecrementCallback(Widget w, XtPointer clientData, XtPointer callData)
22 {
23     printf ("pageDecrementCallback\n");
24 }
25 
pageIncrementCallback(Widget w,XtPointer clientData,XtPointer callData)26 void pageIncrementCallback(Widget w, XtPointer clientData, XtPointer callData)
27 {
28     printf ("pageIncrementCallback\n");
29 }
30 
valueChangedCallback(Widget w,XtPointer clientData,XtPointer callData)31 void valueChangedCallback(Widget w, XtPointer clientData, XtPointer callData)
32 {
33     XmScrollBarCallbackStruct *cbs = (XmScrollBarCallbackStruct *)callData;
34 
35     printf ("valueChangedCallback: %d\n", cbs->value);
36 }
37 
38 int
main(int argc,char ** argv)39 main(int argc, char **argv)
40 {
41     Widget toplevel, one;
42     XtAppContext app;
43     unsigned int maximum;
44 
45     XtSetLanguageProc(NULL, NULL, NULL);
46 
47     toplevel = XtVaAppInitialize(&app, "Scroll", NULL, 0, &argc, argv, NULL, NULL);
48 
49     one = XtVaCreateManagedWidget("sb", xmScrollBarWidgetClass, toplevel,
50 				  XmNorientation, XmHORIZONTAL,
51 				  XmNminimum, 0, XmNmaximum, 100,
52 				  XmNwidth, 100,
53 				  XmNsliderSize, 100,
54 				  NULL);
55 
56     XtAddCallback(one, XmNdecrementCallback, decrementCallback, NULL);
57     XtAddCallback(one, XmNdragCallback, dragCallback, NULL);
58     XtAddCallback(one, XmNincrementCallback, incrementCallback, NULL);
59     XtAddCallback(one, XmNpageDecrementCallback, pageDecrementCallback, NULL);
60     XtAddCallback(one, XmNpageIncrementCallback, pageIncrementCallback, NULL);
61     XtAddCallback(one, XmNvalueChangedCallback, valueChangedCallback, NULL);
62 
63     XtRealizeWidget(toplevel);
64 
65     XtVaGetValues(one, XmNmaximum, &maximum, NULL);
66 
67     printf ("one.maximum = %u\n", maximum);
68 
69 
70 {
71     static XtWidgetGeometry Expected[] = {
72    CWWidth | CWHeight            ,   50,   50,  100,   15, 0,0,0, /* sb */
73     };
74     PrintDetails(toplevel,Expected);
75 };
76   LessTifTestMainLoop(toplevel);
77 
78     exit(0);
79 }
80