Add WINGs tutorial
[whome.git] / WINGs_tutorial / SixthWindow.c
blob7e24581977221ecc1f61f1993e009fa38f86e2ca
1 #include <WINGs/WINGs.h>
2 #include <WINGs/WINGsP.h>
4 #define WINWIDTH 200
5 #define WINHEIGHT 300
7 Display *display;
8 WMScreen *screen;
9 WMPixmap* pixmap;
11 void closeAction(WMWidget *self,void *data){
12 WMDestroyWidget(self);
13 exit(0);
16 void drawProcedure(XEvent *event, void *data){
17 WMDrawPixmap(pixmap, W_VIEW_DRAWABLE(WMWidgetView(data)),30,30);XFlush(display);
21 int main (int argc, char **argv){
22 WMColor *color;
23 WMWindow * win;
24 RImage *image;
26 RColor one, two={0xaf, 0x0f,0xff,0x33};
27 one.red=0x20;
28 one.green=0x20;
29 one.blue=0x20;
30 one.alpha=0xff;
33 WMInitializeApplication("DrawWin", &argc, argv);
34 display = XOpenDisplay("");
35 screen = WMCreateScreen(display, DefaultScreen(display));
36 win = WMCreateWindow(screen, "");
37 WMResizeWidget(win, WINWIDTH, WINHEIGHT);
38 WMSetWindowCloseAction(win, closeAction, NULL);
39 WMSetWindowTitle(win,"Graphics");
40 color = WMCreateRGBColor(screen,124<<9,206<<8,162<<8, False);
41 WMSetWidgetBackgroundColor((WMWidget *)win, color);
42 /* end setup main window */
45 image=RCreateImage( 100,100,.8);
46 RFillImage(image, &two);
47 RDrawLine(image, 50,10,90,90,&one);
48 RDrawLine(image, 10,90,50,10,&one);
49 RDrawLine(image, 10,90,90,90,&one);
51 WMRealizeWidget(win);
53 pixmap=WMCreatePixmapFromRImage(screen, image,1);
54 WMCreateEventHandler(WMWidgetView(win), ExposureMask,drawProcedure,win);
56 WMMapWidget(win);
57 WMScreenMainLoop(screen);