XdrawTest.src 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
  2. XCOMM $XConsortium: XdrawTest.src /main/3 1996/04/23 20:19:28 drk $
  3. XCOMM #########################################################################
  4. XCOMM (c) Copyright 1993, 1994 Hewlett-Packard Company
  5. XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
  6. XCOMM (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  7. XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  8. XCOMM Novell, Inc.
  9. XCOMM #########################################################################
  10. XCOMM
  11. XCOMM This sample shell script demonstrates the calling sequence for most of
  12. XCOMM the X drawing commands.
  13. XCOMM
  14. ExposeCallback()
  15. {
  16. XDrawRectangle $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  17. 10 20 100 200 \
  18. 120 20 200 100
  19. XFillRectangle $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  20. -foreground red -background green 20 30 80 180
  21. XClearArea $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  22. 30 40 60 40 false
  23. XDrawLine $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  24. -foreground red -background white 130 22 130 117
  25. XDrawLines $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  26. 140 30 140 101 \
  27. 150 101 150 30
  28. XDrawLines $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  29. -CoordModePrevious -line_width 3 160 30 0 71 \
  30. 10 0 0 -71
  31. XDrawPoint $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  32. 180 30 180 101
  33. XDrawPoints $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  34. 190 30 190 40 190 50 190 60 190 70 190 80 190 90 190 101
  35. XDrawPoints $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  36. -CoordModePrevious \
  37. 200 30 0 10 0 10 0 10 0 10 0 10 0 10 0 10
  38. XDrawSegments $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  39. -function clear -foreground green -background red \
  40. -line_width 3 \
  41. 210 30 210 40 210 50 210 60 210 70 210 80 210 90 210 100
  42. XDrawArc $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  43. -line_width 3 20 300 100 150 300 5760
  44. XFillArc $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  45. -line_width 3 20 270 100 150 11520 5760
  46. XDrawString $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  47. -font fixed -foreground blue -background red 200 200 \
  48. "XDrawString"
  49. XDrawImageString $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  50. -foreground green -background red 200 250 \
  51. "XDrawImageString"
  52. XFillPolygon $(XtDisplay "-" $CB_WIDGET) $(XtWindow "-" $CB_WIDGET) \
  53. -Convex -CoordModePrevious \
  54. 300 300 30 70 30 -140
  55. XTextWidth "-" fixed "Hi Mom"
  56. }
  57. ClearWindow()
  58. {
  59. XClearWindow $(XtDisplay "-" $DRAWINGAREA) $(XtWindow "-" $DRAWINGAREA)
  60. }
  61. XCOMM ###################### Create the Main UI ###############################
  62. XtInitialize TOPLEVEL drawingArea DrawingArea "$0" "$@"
  63. XtCreateManagedWidget FORM form XmForm $TOPLEVEL
  64. XtCreateManagedWidget DRAWINGAREA drawingArea XmDrawingArea $FORM \
  65. topAttachment:ATTACH_FORM \
  66. leftAttachment:ATTACH_FORM \
  67. rightAttachment:ATTACH_FORM
  68. XtAddCallback $DRAWINGAREA exposeCallback ExposeCallback
  69. XtCreateManagedWidget SEP sep XmSeparator $FORM \
  70. topAttachment:ATTACH_WIDGET \
  71. topWidget:$DRAWINGAREA \
  72. leftAttachment:ATTACH_FORM \
  73. rightAttachment:ATTACH_FORM
  74. XtCreateManagedWidget PB pb XmPushButton $FORM \
  75. labelString:"Clear The Window" \
  76. topAttachment:ATTACH_WIDGET \
  77. topWidget:$SEP \
  78. leftAttachment:ATTACH_FORM \
  79. rightAttachment:ATTACH_FORM \
  80. bottomAttachment:ATTACH_FORM
  81. XtAddCallback $PB activateCallback ClearWindow
  82. XtSetValues $DRAWINGAREA \
  83. height:450 \
  84. width:450
  85. XtRealizeWidget $TOPLEVEL
  86. XtMainLoop