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