Ejemplo n.º 1
0
WMScreen *WMCreateSimpleApplicationScreen(Display * display)
{
	WMScreen *scr;

	scr = WMCreateScreen(display, DefaultScreen(display));

	scr->aflags.hasAppIcon = 0;
	scr->aflags.simpleApplication = 1;

	return scr;
}
int main (int argc, char **argv){
int i,j;
WMColor *color;
WMWindow * win;
RImage *image;
struct _pict pict;
Drawable de;

RColor one, two={0xaf, 0x0f,0xff,0x33};
one.red=247;
one.green=251;
one.blue=107;
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,0.5);
RFillImage(image, &two);
RDrawLine(image, 50,10,90,90,&one);
RDrawLine(image, 10,90,50,10,&one);
RDrawLine(image, 10,90,90,90,&one);

g3=WMColorGC(screen->gray);
XSetLineAttributes(display,g3,3,LineSolid,CapButt,JoinMiter);

pict.segments[1].x1= pict.segments[0].x1=HOFF;
pict.segments[0].x2=HOFF;
pict.segments[0].y1=VOFF;
pict.segments[1].y2=  pict.segments[0].y2=VOFF;
pict.segments[1].x2= HOFF+10;
pict.segments[1].y1=VOFF+10;
pict.seglen=2;
for (i=9;i>0;i--){
 j=2*(10-i);
 pict.segments[j+1].x1= pict.segments[j].x1=HOFF;
 pict.segments[j+1].y2= pict.segments[j].y2=VOFF;
 pict.segments[j].x2= i+pict.segments[j-1].x2;
 pict.segments[j].y1=i+pict.segments[j-1].y1;
 pict.segments[j+1].x2= i+pict.segments[j].x2;
 pict.segments[j+1].y1=i+pict.segments[j].y1;
 pict.seglen+=2;
};


WMRealizeWidget(win);

pict.dwin=W_VIEW_DRAWABLE(WMWidgetView(win));
pixmap=WMCreatePixmapFromRImage(screen, image,1);

WMCreateEventHandler(WMWidgetView(win), ExposureMask,drawProcedure,&pict);

WMMapWidget(win);
WMScreenMainLoop(screen);
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
	WMScreen *scr;
	WMPixmap *pixmap;

	/* Initialize the application */
	WMInitializeApplication("Test@eqweq_ewq$eqw", &argc, argv);

	testUD();

	/*
	 * Open connection to the X display.
	 */
	dpy = XOpenDisplay("");

	if (!dpy) {
		puts("could not open display");
		exit(1);
	}

	/* This is used to disable buffering of X protocol requests.
	 * Do NOT use it unless when debugging. It will cause a major
	 * slowdown in your application
	 */
#if 0
	XSynchronize(dpy, True);
#endif
	/*
	 * Create screen descriptor.
	 */
	scr = WMCreateScreen(dpy, DefaultScreen(dpy));

	/*
	 * Loads the logo of the application.
	 */
	pixmap = WMCreatePixmapFromFile(scr, "logo.xpm");

	/*
	 * Makes the logo be used in standard dialog panels.
	 */
	if (pixmap) {
		WMSetApplicationIconPixmap(scr, pixmap);
		WMReleasePixmap(pixmap);
	}

	/*
	 * Do some test stuff.
	 *
	 * Put the testSomething() function you want to test here.
	 */

	testText(scr);
	testFontPanel(scr);

	testColorPanel(scr);

	testTextField(scr);

#if 0

	testBox(scr);
	testButton(scr);
	testColorPanel(scr);
	testColorWell(scr);
	testDragAndDrop(scr);
	testFrame(scr);
	testGradientButtons(scr);
	testList(scr);
	testOpenFilePanel(scr);
	testProgressIndicator(scr);
	testPullDown(scr);
	testScrollView(scr);
	testSlider(scr);
	testSplitView(scr);
	testTabView(scr);
	testTextField(scr);
#endif
	/*
	 * The main event loop.
	 *
	 */
	WMScreenMainLoop(scr);

	return 0;
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
	Display *dpy;
	WMScreen *scr;
	char *path;
	int i;
	char *display_name = "";

	wsetabort(wAbort);

	memset(DeadHandlers, 0, sizeof(DeadHandlers));

	WMInitializeApplication("WPrefs", &argc, argv);

	WMSetResourcePath(RESOURCE_PATH);
	path = WMPathForResourceOfType("WPrefs.tiff", NULL);
	if (!path) {
		/* maybe it is run directly from the source directory */
		WMSetResourcePath(".");
		path = WMPathForResourceOfType("WPrefs.tiff", NULL);
		if (!path) {
			WMSetResourcePath("..");
		}
	}
	if (path) {
		wfree(path);
	}

	if (argc > 1) {
		for (i = 1; i < argc; i++) {
			if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "--version") == 0) {
				printf("WPrefs (Window Maker) %s\n", VERSION);
				exit(0);
			} else if (strcmp(argv[i], "-display") == 0) {
				i++;
				if (i >= argc) {
					wwarning(_("too few arguments for %s"), argv[i - 1]);
					exit(0);
				}
				display_name = argv[i];
			} else {
				print_help(argv[0]);
				exit(0);
			}
		}
	}

	setlocale(LC_ALL, "");

#ifdef I18N
	if (getenv("NLSPATH"))
		bindtextdomain("WPrefs", getenv("NLSPATH"));
	else
		bindtextdomain("WPrefs", LOCALEDIR);
	bind_textdomain_codeset("WPrefs", "UTF-8");
	textdomain("WPrefs");

	if (!XSupportsLocale()) {
		wwarning(_("X server does not support locale"));
	}
	if (XSetLocaleModifiers("") == NULL) {
		wwarning(_("cannot set locale modifiers"));
	}
#endif

	dpy = XOpenDisplay(display_name);
	if (!dpy) {
		wfatal(_("could not open display %s"), XDisplayName(display_name));
		exit(0);
	}
#if 0
	XSynchronize(dpy, 1);
#endif
	scr = WMCreateScreen(dpy, DefaultScreen(dpy));
	if (!scr) {
		wfatal(_("could not initialize application"));
		exit(0);
	}

	xext_xkb_supported = XkbQueryExtension(dpy, NULL, NULL, NULL, NULL, NULL);

	WMPLSetCaseSensitive(False);

	Initialize(scr);

	while (1) {
		XEvent event;

		WMNextEvent(dpy, &event);

		while (DeadChildrenCount-- > 0) {
			int i;

			for (i = 0; i < MAX_DEATHS; i++) {
				if (DeadChildren[i] == DeadHandlers[i].pid) {
					(*DeadHandlers[i].handler) (DeadHandlers[i].data);
					DeadHandlers[i].pid = 0;
				}
			}
		}

		WMHandleEvent(&event);
	}
}
Ejemplo n.º 5
0
int main(int argc, char **argv)
{
    Display *dpy;
    WMScreen *scr;
    int x, y, i;
    
    WMInitializeApplication("Puzzle", &argc, argv);

    
    dpy = XOpenDisplay("");
    if (!dpy) {
	printf("could not open display\n");
	exit(1);
    }
    
    scr = WMCreateScreen(dpy, DefaultScreen(dpy));
    
    win = WMCreateWindow(scr, "puzzle");
    WMResizeWidget(win, WinSize, WinSize);
    WMSetWindowTitle(win, "zuPzel");
    WMSetWindowMinSize(win, 80, 80);
    WMSetWindowAspectRatio(win, 2, 2, 2, 2);
    WMSetWindowResizeIncrements(win, Size, Size);
    WMSetViewNotifySizeChanges(WMWidgetView(win), True);
    WMAddNotificationObserver(resizeObserver, NULL,
			      WMViewSizeDidChangeNotification,
			      WMWidgetView(win));
			      
			      
    
    for (i = y = 0; y < Size && i < Size*Size-1; y++) {
	for (x = 0; x < Size && i < Size*Size-1; x++) {
	    char buf[32];
	    WMColor *color;
	    RColor col;
	    RHSVColor hsv;
	    
	    hsv.hue = i*360/(Size*Size-1);
	    hsv.saturation = 120;
	    hsv.value = 200;
	    
	    RHSVtoRGB(&hsv, &col);

	    color = WMCreateRGBColor(scr, col.red<<8, col.green<<8,
				     col.blue<<8, False);

	    MAP(x,y) = i;
	    Button[i] = WMCreateButton(win, WBTMomentaryLight);
	    WMSetWidgetBackgroundColor(Button[i], color);
	    WMReleaseColor(color);
	    WMSetButtonAction(Button[i], buttonClick, (void*)i);
	    WMResizeWidget(Button[i], WinSize/Size, WinSize/Size);
	    WMMoveWidget(Button[i], x*(WinSize/Size), y*(WinSize/Size));
	    sprintf(buf, "%i", i+1);
	    WMSetButtonText(Button[i], buf);
	    WMSetButtonTextAlignment(Button[i], WACenter);
	    i++;
	}
    }
        
    WMMapSubwidgets(win);
    WMMapWidget(win);
    WMRealizeWidget(win);
    
    ResetGame();

    WMScreenMainLoop(scr);
    
    return 0;
}
Ejemplo n.º 6
0
int main (int argc, char **argv){

WMFrame *glframe;
WMScreen *screen;
WMWindow *window;
WMButton *Button;


/*    Xlib and glX variables    */
Window 	win;
XVisualInfo	*xvVisualInfo;
Colormap	cmColorMap;
XSetWindowAttributes 	winAttr;
GLXContext       glXContext;

getargs(argc,argv);
WMInitializeApplication("GLWindow", &argc, argv);
display = XOpenDisplay("");
screen = WMCreateScreen(display, DefaultScreen(display));

 if(!glXQueryExtension(display, NULL, NULL)){wwarning("X server does not have GLX\n"); return 0; }

window = WMCreateWindow(screen, "Main");
WMResizeWidget(window, CONTENTW+2*CONTENTMARGIN, CONTENTH+2*CONTENTMARGIN*CONTENTH/CONTENTW);
WMSetWindowAspectRatio(window, CONTENTW,CONTENTH,CONTENTW,CONTENTH);
WMSetWindowCloseAction(window, closeAll, NULL);
WMSetWindowTitle(window,"GL Frame");
WMRealizeWidget(window); 
datacouple.window=window;
WMSetViewNotifySizeChanges(WMWidgetView(window), True);
WMAddNotificationObserver(resizeHandler, &datacouple, WMViewSizeDidChangeNotification, WMWidgetView(window));


glframe = WMCreateFrame(window);
datacouple.frame=glframe;
WMResizeWidget(glframe, CONTENTW, CONTENTH);
WMMoveWidget(glframe, CONTENTMARGIN,CONTENTMARGIN);
WMRealizeWidget(glframe); 

Button=WMCreateButton(window, WBTMomentaryPush);
WMSetButtonAction(Button, DoRotate,&win);
WMSetButtonText(Button,"Turn");
WMMoveWidget(Button, CONTENTMARGIN,2);
WMRealizeWidget(Button);
WMMapWidget(Button);

/*  get the frame's X window value  */
win =W_VIEW_DRAWABLE(WMWidgetView(glframe));
WMCreateEventHandler(WMWidgetView(glframe), ExposureMask|StructureNotifyMask,redo,&win);

xvVisualInfo = glXChooseVisual(display, DefaultScreen(display), Attr);
 if(xvVisualInfo == NULL) {wwarning("No visualinfo\n");return 0;}

cmColorMap = XCreateColormap(display,RootWindow(display, DefaultScreen(display)), xvVisualInfo->visual, AllocNone);

winAttr.colormap = cmColorMap;
winAttr.border_pixel = 0;
winAttr.background_pixel = 0;
winAttr.event_mask = ExposureMask | ButtonPressMask  |StructureNotifyMask| KeyPressMask;

XChangeWindowAttributes(display,win,CWBorderPixel | CWColormap | CWEventMask,&winAttr);
glXContext = glXCreateContext(display, xvVisualInfo, None, True);
  if(!glXContext) {wwarning("glX cannot create rendering context\n");return 0;} 

glXMakeCurrent(display, win, glXContext);

WMMapWidget(glframe);
init();
setsize(CONTENTW,CONTENTH);
WMMapWidget(window);

WMScreenMainLoop(screen);

return 0;
}