WINGs: Better presentation for example code in the tutorial
[whome.git] / WINGs_tutorial / SixthWindow.c
blob8be338b4dae2a61d0aeafc4da64d16a0c72c1a53
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)
13 WMDestroyWidget(self);
14 exit(0);
17 void drawProcedure(XEvent *event, void *data)
19 WMDrawPixmap(pixmap, W_VIEW_DRAWABLE(WMWidgetView(data)), 30, 30);
23 int main(int argc, char **argv)
25 WMColor *color;
26 WMWindow * win;
27 RImage *image;
29 RColor one, two = { 0xAF, 0x0F, 0xFF, 0x33 };
30 one.red = 0x20;
31 one.green = 0x20;
32 one.blue = 0x20;
33 one.alpha = 0xFF;
35 WMInitializeApplication("DrawWin", &argc, argv);
36 display = XOpenDisplay("");
37 screen = WMCreateScreen(display, DefaultScreen(display));
38 win = WMCreateWindow(screen, "");
39 WMResizeWidget(win, WINWIDTH, WINHEIGHT);
40 WMSetWindowCloseAction(win, closeAction, NULL);
41 WMSetWindowTitle(win, "Graphics");
42 color = WMCreateRGBColor(screen, 124<<9, 206<<8, 162<<8, False);
43 WMSetWidgetBackgroundColor((WMWidget *)win, color);
45 /* end setup main window */
47 image = RCreateImage(100, 100, 0.8);
48 RFillImage(image, &two);
49 RDrawLine(image, 50, 10, 90, 90, &one);
50 RDrawLine(image, 10, 90, 50, 10, &one);
51 RDrawLine(image, 10, 90, 90, 90, &one);
53 WMRealizeWidget(win);
55 pixmap = WMCreatePixmapFromRImage(screen, image, 1);
56 WMCreateEventHandler(WMWidgetView(win), ExposureMask, drawProcedure, win);
58 WMMapWidget(win);
59 WMScreenMainLoop(screen);