1 #include <stdio.h>
2 #include <Xm/Xm.h>
3 #include <Xm/ScaleP.h>
4 #include <Xm/Form.h>
5
dragCallback(Widget w,XtPointer clientData,XtPointer callData)6 void dragCallback(Widget w, XtPointer clientData, XtPointer callData)
7 {
8 XmScaleCallbackStruct *cbs = (XmScaleCallbackStruct *)callData;
9
10 printf ("dragCallback: %d\n", cbs->value);
11 }
12
valueChangedCallback(Widget w,XtPointer clientData,XtPointer callData)13 void valueChangedCallback(Widget w, XtPointer clientData, XtPointer callData)
14 {
15 XmScaleCallbackStruct *cbs = (XmScaleCallbackStruct *)callData;
16
17 printf ("valueChangedCallback: %d\n", cbs->value);
18 }
19
20 int
main(int argc,char ** argv)21 main(int argc, char **argv)
22 {
23 Widget toplevel, one, two;
24 XtAppContext app;
25 unsigned int maximum;
26 XmString str;
27
28 XtSetLanguageProc(NULL, NULL, NULL);
29
30 toplevel = XtVaAppInitialize(&app, "Scale", NULL, 0, &argc, argv, NULL, NULL);
31
32 one = XtVaCreateManagedWidget("form", xmFormWidgetClass, toplevel,
33 NULL);
34
35 str = XmStringCreateLtoR("Test Scale", XmFONTLIST_DEFAULT_TAG);
36
37 two = XtVaCreateManagedWidget("sb", xmScaleWidgetClass, one,
38 XmNtopAttachment, XmATTACH_FORM,
39 XmNleftAttachment, XmATTACH_FORM,
40 XmNrightAttachment, XmATTACH_FORM,
41 XmNbottomAttachment, XmATTACH_FORM,
42 XmNorientation, XmHORIZONTAL,
43 XmNshowValue, True,
44 #if 0
45 XmNscaleWidth, 100,
46 XmNminimum, 100,
47 XmNmaximum, 300,
48 #endif
49 XmNtitleString, str,
50 NULL);
51
52 XtAddCallback(two, XmNdragCallback, dragCallback, NULL);
53 XtAddCallback(two, XmNvalueChangedCallback, valueChangedCallback, NULL);
54
55 XtRealizeWidget(toplevel);
56
57 XtVaGetValues(two, XmNmaximum, &maximum, NULL);
58
59 printf ("one.maximum = %u\n", maximum);
60
61
62 {
63 static XtWidgetGeometry Expected[] = {
64 CWWidth | CWHeight , 50, 50, 104, 56, 0,0,0, /* form */
65 CWWidth | CWHeight | CWX | CWY, 0, 0, 104, 56, 0,0,0, /* sb */
66 CWWidth | CWHeight | CWX | CWY, 0, 35, 64, 17, 0,0,0, /* Title */
67 CWWidth | CWHeight | CWX | CWY, 0, 16, 104, 19, 0,0,0, /* Scrollbar */
68 };
69 PrintDetails(toplevel,Expected);
70 };
71 LessTifTestMainLoop(toplevel);
72
73 exit(0);
74 }
75