1 #include <WINGs/WINGs.h>
2 #include <WINGs/WINGsP.h>
15 XSegment segments
[40];
21 void closeAction(WMWidget
*self
,void *data
)
23 WMDestroyWidget(self
);
27 void drawProcedure(XEvent
*event
, void *data
)
29 struct _pict
*p
= (struct _pict
*) data
;
31 WMDrawPixmap(pixmap
, p
->dwin
, HOFF
, 30);
32 XDrawRectangle(display
, p
->dwin
, g3
, HOFF
, VOFF
, 100, 100);
33 XFillRectangle(screen
->display
, p
->dwin
, WMColorGC(screen
->white
), HOFF
, VOFF
, 100, 100);
34 XDrawSegments(display
, p
->dwin
, WMColorGC(screen
->black
), p
->segments
, p
->seglen
);
38 int main(int argc
, char **argv
)
47 RColor one
= { 247, 251, 107, 0xFF },
48 two
= { 0xAF, 0x0F, 0xFF, 0x33 };
50 WMInitializeApplication("DrawWin", &argc
, argv
);
51 display
= XOpenDisplay("");
52 screen
= WMCreateScreen(display
, DefaultScreen(display
));
53 win
= WMCreateWindow(screen
, "");
54 WMResizeWidget(win
, WINWIDTH
, WINHEIGHT
);
55 WMSetWindowCloseAction(win
, closeAction
, NULL
);
56 WMSetWindowTitle(win
, "Graphics");
57 color
= WMCreateRGBColor(screen
, 124<<9, 206<<8, 162<<8, False
);
58 WMSetWidgetBackgroundColor((WMWidget
*)win
, color
);
59 /* end setup main window */
61 image
= RCreateImage(100, 100, 0.5);
62 RFillImage(image
, &two
);
63 RDrawLine(image
, 50, 10, 90, 90, &one
);
64 RDrawLine(image
, 10, 90, 50, 10, &one
);
65 RDrawLine(image
, 10, 90, 90, 90, &one
);
67 g3
= WMColorGC(screen
->gray
);
68 XSetLineAttributes(display
, g3
, 3, LineSolid
, CapButt
, JoinMiter
);
70 pict
.segments
[1].x1
= pict
.segments
[0].x1
= HOFF
;
71 pict
.segments
[0].x2
= HOFF
;
72 pict
.segments
[0].y1
= VOFF
;
73 pict
.segments
[1].y2
= pict
.segments
[0].y2
= VOFF
;
74 pict
.segments
[1].x2
= HOFF
+ 10;
75 pict
.segments
[1].y1
= VOFF
+ 10;
77 for (i
= 9; i
> 0; i
--) {
79 pict
.segments
[j
+1].x1
= pict
.segments
[j
].x1
= HOFF
;
80 pict
.segments
[j
+1].y2
= pict
.segments
[j
].y2
= VOFF
;
81 pict
.segments
[j
].x2
= i
+ pict
.segments
[j
-1].x2
;
82 pict
.segments
[j
].y1
= i
+ pict
.segments
[j
-1].y1
;
83 pict
.segments
[j
+1].x2
= i
+ pict
.segments
[j
].x2
;
84 pict
.segments
[j
+1].y1
= i
+ pict
.segments
[j
].y1
;
90 pict
.dwin
= W_VIEW_DRAWABLE(WMWidgetView(win
));
91 pixmap
= WMCreatePixmapFromRImage(screen
, image
, 1);
93 WMCreateEventHandler(WMWidgetView(win
), ExposureMask
, drawProcedure
, &pict
);
96 WMScreenMainLoop(screen
);