/lesstif-0.95.2/test/Xm/scrolledwindow/test11.c

# · C · 185 lines · 147 code · 33 blank · 5 comment · 0 complexity · f02f4ec8909bd01ad6d6228794bc5a8b MD5 · raw file

  1. /* $Header: /cvsroot/lesstif/lesstif/test/Xm/scrolledwindow/test11.c,v 1.8 2001/05/23 14:30:30 amai Exp $
  2. * create a scrolled window with a drawing area inside... resize the
  3. * drawing area when the pushbutton is clicked (also draw a line
  4. * to show the clipping area)
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <Xm/Form.h>
  9. #include <Xm/Label.h>
  10. #include <Xm/PushB.h>
  11. #include <Xm/ScrolledW.h>
  12. #include <Xm/DrawingA.h>
  13. #include "../../common/Test.h"
  14. Widget toplevel;
  15. Widget form;
  16. Widget scrollw;
  17. Widget execute_button;
  18. Widget da;
  19. unsigned long valuemask;
  20. XGCValues values;
  21. GC gc;
  22. static char *FallBack[] = {
  23. "*.geometrySlop: 2",
  24. NULL
  25. };
  26. void
  27. cb (
  28. Widget w,
  29. XtPointer d,
  30. XtPointer c)
  31. {
  32. static Dimension width = 100;
  33. static Dimension height = 100;
  34. Dimension twidth, theight;
  35. width += 100;
  36. height += 100;
  37. XtVaGetValues(da,
  38. XtNwidth, &twidth,
  39. XtNheight, &theight,
  40. NULL);
  41. fprintf(stderr, "***********width, height is %dx%d\n", twidth, theight);
  42. XtVaSetValues(da,
  43. XtNwidth, width,
  44. XtNheight, height,
  45. NULL);
  46. XDrawLine(XtDisplay(da), XtWindow(da), gc, 0, 0, 500, 500);
  47. }
  48. int main (
  49. int argc,
  50. char **argv)
  51. {
  52. Arg al[64];
  53. int ac;
  54. XtAppContext app;
  55. toplevel = XtVaAppInitialize(&app, "test11", NULL, 0,
  56. &argc, argv, FallBack, NULL);
  57. form = XmCreateForm( toplevel, "myform", NULL, 0);
  58. XtManageChild(form);
  59. ac = 0;
  60. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  61. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  62. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  63. execute_button = XmCreatePushButton ( form, "execute_button", al, ac );
  64. XtAddCallback(execute_button, XmNactivateCallback, cb, NULL);
  65. XtManageChild(execute_button);
  66. ac = 0;
  67. XtSetArg(al[ac], XmNwidth, 500); ac++;
  68. XtSetArg(al[ac], XmNheight, 600); ac++;
  69. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  70. XtSetArg(al[ac], XmNtopWidget, execute_button); ac++;
  71. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  72. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  73. XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  74. XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
  75. scrollw = XmCreateScrolledWindow ( form, "myscroll", al, ac );
  76. XtManageChild(scrollw);
  77. da = XtVaCreateManagedWidget("mycanvas", xmDrawingAreaWidgetClass,
  78. scrollw,
  79. XmNwidth, 100,
  80. XmNheight, 100,
  81. NULL);
  82. XtRealizeWidget(toplevel);
  83. values.foreground = BlackPixelOfScreen(XtScreen(da));
  84. values.background = WhitePixelOfScreen(XtScreen(da));
  85. valuemask = GCForeground | GCBackground;
  86. gc = XCreateGC(XtDisplay(da), XtWindow(da), valuemask, &values);
  87. {
  88. static XtWidgetGeometry Expected[] = {
  89. CWWidth | CWHeight , 508, 391, 500, 625, 0,0,0, /* myform */
  90. CWWidth | CWHeight | CWX | CWY, 0, 0, 500, 25, 0,0,0, /* execute_button */
  91. CWWidth | CWHeight | CWX | CWY, 0, 25, 500, 600, 0,0,0, /* myscroll */
  92. CWWidth | CWHeight | CWX | CWY, 2, 2, 496, 596, 0,0,0, /* ScrolledWindowClipWindow */
  93. CWWidth | CWHeight | CWX | CWY, 0, 0, 100, 100, 0,0,0, /* mycanvas */
  94. CWWidth | CWHeight | CWX | CWY, 500, 0, 19, 600, 0,0,0, /* VertScrollBar */
  95. CWWidth | CWHeight | CWX | CWY, 0, 600, 500, 19, 0,0,0, /* HorScrollBar */
  96. CWWidth | CWHeight , 508, 391, 500, 625, 0,0,0, /* myform */
  97. CWWidth | CWHeight | CWX | CWY, 0, 0, 500, 25, 0,0,0, /* execute_button */
  98. CWWidth | CWHeight | CWX | CWY, 0, 25, 500, 600, 0,0,0, /* myscroll */
  99. CWWidth | CWHeight | CWX | CWY, 2, 2, 496, 596, 0,0,0, /* ScrolledWindowClipWindow */
  100. CWWidth | CWHeight | CWX | CWY, 0, 0, 300, 300, 0,0,0, /* mycanvas */
  101. CWWidth | CWHeight | CWX | CWY, 500, 0, 19, 600, 0,0,0, /* VertScrollBar */
  102. CWWidth | CWHeight | CWX | CWY, 0, 600, 500, 19, 0,0,0, /* HorScrollBar */
  103. CWWidth | CWHeight , 508, 391, 500, 625, 0,0,0, /* myform */
  104. CWWidth | CWHeight | CWX | CWY, 0, 0, 500, 25, 0,0,0, /* execute_button */
  105. CWWidth | CWHeight | CWX | CWY, 0, 25, 500, 600, 0,0,0, /* myscroll */
  106. CWWidth | CWHeight | CWX | CWY, 2, 2, 496, 596, 0,0,0, /* ScrolledWindowClipWindow */
  107. CWWidth | CWHeight | CWX | CWY, 0, 0, 400, 400, 0,0,0, /* mycanvas */
  108. CWWidth | CWHeight | CWX | CWY, 500, 0, 19, 600, 0,0,0, /* VertScrollBar */
  109. CWWidth | CWHeight | CWX | CWY, 0, 600, 500, 19, 0,0,0, /* HorScrollBar */
  110. CWWidth | CWHeight , 508, 391, 500, 625, 0,0,0, /* myform */
  111. CWWidth | CWHeight | CWX | CWY, 0, 0, 500, 25, 0,0,0, /* execute_button */
  112. CWWidth | CWHeight | CWX | CWY, 0, 25, 500, 600, 0,0,0, /* myscroll */
  113. CWWidth | CWHeight | CWX | CWY, 4, 2, 492, 571, 0,0,0, /* ScrolledWindowClipWindow */
  114. CWWidth | CWHeight | CWX | CWY, 0, 0, 500, 500, 0,0,0, /* mycanvas */
  115. CWWidth | CWHeight | CWX | CWY, 500, 0, 19, 600, 0,0,0, /* VertScrollBar */
  116. CWWidth | CWHeight | CWX | CWY, 0, 581, 500, 19, 0,0,0, /* HorScrollBar */
  117. CWWidth | CWHeight , 508, 391, 500, 625, 0,0,0, /* myform */
  118. CWWidth | CWHeight | CWX | CWY, 0, 0, 500, 25, 0,0,0, /* execute_button */
  119. CWWidth | CWHeight | CWX | CWY, 0, 25, 500, 600, 0,0,0, /* myscroll */
  120. CWWidth | CWHeight | CWX | CWY, 4, 4, 469, 569, 0,0,0, /* ScrolledWindowClipWindow */
  121. CWWidth | CWHeight | CWX | CWY, 0, 0, 600, 600, 0,0,0, /* mycanvas */
  122. CWWidth | CWHeight | CWX | CWY, 481, 0, 19, 577, 0,0,0, /* VertScrollBar */
  123. CWWidth | CWHeight | CWX | CWY, 0, 581, 477, 19, 0,0,0, /* HorScrollBar */
  124. CWWidth | CWHeight , 508, 391, 500, 625, 0,0,0, /* myform */
  125. CWWidth | CWHeight | CWX | CWY, 0, 0, 500, 25, 0,0,0, /* execute_button */
  126. CWWidth | CWHeight | CWX | CWY, 0, 25, 500, 600, 0,0,0, /* myscroll */
  127. CWWidth | CWHeight | CWX | CWY, 4, 4, 469, 569, 0,0,0, /* ScrolledWindowClipWindow */
  128. CWWidth | CWHeight | CWX | CWY, 0, 0, 600, 600, 0,0,0, /* mycanvas */
  129. CWWidth | CWHeight | CWX | CWY, 481, 0, 19, 577, 0,0,0, /* VertScrollBar */
  130. CWWidth | CWHeight | CWX | CWY, 0, 581, 477, 19, 0,0,0, /* HorScrollBar */
  131. };
  132. PrintDetails(toplevel,Expected);
  133. LessTifTestWaitForIt(toplevel);
  134. LessTifTestPushButton(execute_button);
  135. LessTifTestWaitForIt(toplevel);
  136. PrintDetails(toplevel,Expected);
  137. LessTifTestPushButton(execute_button);
  138. LessTifTestWaitForIt(toplevel);
  139. PrintDetails(toplevel,Expected);
  140. LessTifTestPushButton(execute_button);
  141. LessTifTestWaitForIt(toplevel);
  142. PrintDetails(toplevel,Expected);
  143. LessTifTestPushButton(execute_button);
  144. LessTifTestWaitForIt(toplevel);
  145. PrintDetails(toplevel,Expected);
  146. LessTifTestPushButton(execute_button);
  147. LessTifTestWaitForIt(toplevel);
  148. PrintDetails(toplevel,Expected);
  149. };
  150. LessTifTestMainLoop(toplevel);
  151. exit(0);
  152. }