Files
window-maker.github.io/WINGs_tutorial/SixthWindow.c
Carlos R. Mafra 6c515667a7 Add WINGs tutorial
The original website is
http://www.quantitativefinanceservices.com/OpenDir/WINGslib/WINGToc.html

and it had the following notice at the bottom:

Copyright (c) 2010 Permission is granted to copy, distribute and/or modify
this document under the terms of the GNU Free Documentation License, Version
1.1 or any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A
copy of the license is included in the section entitled "GNU Free
Documentation License".

So we are fine.
2019-01-13 20:35:08 -05:00

59 lines
1.3 KiB
C

#include <WINGs/WINGs.h>
#include <WINGs/WINGsP.h>
#define WINWIDTH 200
#define WINHEIGHT 300
Display *display;
WMScreen *screen;
WMPixmap* pixmap;
void closeAction(WMWidget *self,void *data){
WMDestroyWidget(self);
exit(0);
}
void drawProcedure(XEvent *event, void *data){
WMDrawPixmap(pixmap, W_VIEW_DRAWABLE(WMWidgetView(data)),30,30);XFlush(display);
}
int main (int argc, char **argv){
WMColor *color;
WMWindow * win;
RImage *image;
RColor one, two={0xaf, 0x0f,0xff,0x33};
one.red=0x20;
one.green=0x20;
one.blue=0x20;
one.alpha=0xff;
WMInitializeApplication("DrawWin", &argc, argv);
display = XOpenDisplay("");
screen = WMCreateScreen(display, DefaultScreen(display));
win = WMCreateWindow(screen, "");
WMResizeWidget(win, WINWIDTH, WINHEIGHT);
WMSetWindowCloseAction(win, closeAction, NULL);
WMSetWindowTitle(win,"Graphics");
color = WMCreateRGBColor(screen,124<<9,206<<8,162<<8, False);
WMSetWidgetBackgroundColor((WMWidget *)win, color);
/* end setup main window */
image=RCreateImage( 100,100,.8);
RFillImage(image, &two);
RDrawLine(image, 50,10,90,90,&one);
RDrawLine(image, 10,90,50,10,&one);
RDrawLine(image, 10,90,90,90,&one);
WMRealizeWidget(win);
pixmap=WMCreatePixmapFromRImage(screen, image,1);
WMCreateEventHandler(WMWidgetView(win), ExposureMask,drawProcedure,win);
WMMapWidget(win);
WMScreenMainLoop(screen);
}