1 #include <WINGs/WINGs.h>
2 #include <WINGs/WINGsP.h>
15 XSegment segments
[40];
21 void closeAction(WMWidget
*self
,void *data
){
22 WMDestroyWidget(self
);
26 void drawProcedure(XEvent
*event
, void *data
){
28 WMDrawPixmap(pixmap
, ((struct _pict
*)data
)->dwin
,HOFF
,30);
29 XDrawRectangle(display
,((struct _pict
*)data
)->dwin
,g3
, HOFF
,VOFF
,100,100);
30 XFillRectangle(screen
->display
, ((struct _pict
*)data
)->dwin
, WMColorGC(screen
->white
), HOFF
, VOFF
, 100, 100);
31 XDrawSegments(display
, ((struct _pict
*)data
)->dwin
, WMColorGC(screen
->black
), ((struct _pict
*)data
)->segments
, ((struct _pict
*)data
)->seglen
);
37 int main (int argc
, char **argv
){
45 RColor one
, two
={0xaf, 0x0f,0xff,0x33};
52 WMInitializeApplication("DrawWin", &argc
, argv
);
53 display
= XOpenDisplay("");
54 screen
= WMCreateScreen(display
, DefaultScreen(display
));
55 win
= WMCreateWindow(screen
, "");
56 WMResizeWidget(win
, WINWIDTH
, WINHEIGHT
);
57 WMSetWindowCloseAction(win
, closeAction
, NULL
);
58 WMSetWindowTitle(win
,"Graphics");
59 color
= WMCreateRGBColor(screen
,124<<9,206<<8,162<<8, False
);
60 WMSetWidgetBackgroundColor((WMWidget
*)win
, color
);
61 /* end setup main window */
63 image
=RCreateImage( 100,100,0.5);
64 RFillImage(image
, &two
);
65 RDrawLine(image
, 50,10,90,90,&one
);
66 RDrawLine(image
, 10,90,50,10,&one
);
67 RDrawLine(image
, 10,90,90,90,&one
);
69 g3
=WMColorGC(screen
->gray
);
70 XSetLineAttributes(display
,g3
,3,LineSolid
,CapButt
,JoinMiter
);
72 pict
.segments
[1].x1
= pict
.segments
[0].x1
=HOFF
;
73 pict
.segments
[0].x2
=HOFF
;
74 pict
.segments
[0].y1
=VOFF
;
75 pict
.segments
[1].y2
= pict
.segments
[0].y2
=VOFF
;
76 pict
.segments
[1].x2
= HOFF
+10;
77 pict
.segments
[1].y1
=VOFF
+10;
81 pict
.segments
[j
+1].x1
= pict
.segments
[j
].x1
=HOFF
;
82 pict
.segments
[j
+1].y2
= pict
.segments
[j
].y2
=VOFF
;
83 pict
.segments
[j
].x2
= i
+pict
.segments
[j
-1].x2
;
84 pict
.segments
[j
].y1
=i
+pict
.segments
[j
-1].y1
;
85 pict
.segments
[j
+1].x2
= i
+pict
.segments
[j
].x2
;
86 pict
.segments
[j
+1].y1
=i
+pict
.segments
[j
].y1
;
93 pict
.dwin
=W_VIEW_DRAWABLE(WMWidgetView(win
));
94 pixmap
=WMCreatePixmapFromRImage(screen
, image
,1);
96 WMCreateEventHandler(WMWidgetView(win
), ExposureMask
,drawProcedure
,&pict
);
99 WMScreenMainLoop(screen
);