Пример #1
0
void testButton(WMScreen * scr)
{
	WMWindow *win;
	int i;
	char *types[] = {
		"MomentaryPush",
		"PushOnPushOff",
		"Toggle",
		"Switch",
		"Radio",
		"MomentaryChange",
		"OnOff",
		"MomentaryLigh"
	};

	windowCount++;

	win = WMCreateWindow(scr, "testButton");
	WMResizeWidget(win, 300, 300);
	WMSetWindowTitle(win, "Buttons");

	WMSetWindowCloseAction(win, closeAction, NULL);

	for (i = 1; i < 9; i++) {
		WMButton *b;
		b = WMCreateButton(win, i);
		WMResizeWidget(b, 150, 24);
		WMMoveWidget(b, 20, i * 30);
		WMSetButtonText(b, types[i - 1]);
	}

	WMRealizeWidget(win);
	WMMapSubwidgets(win);
	WMMapWidget(win);
}
Пример #2
0
void testSlider(WMScreen * scr)
{
	WMWindow *win;
	WMSlider *s;

	windowCount++;

	win = WMCreateWindow(scr, "testSlider");
	WMResizeWidget(win, 300, 300);
	WMSetWindowTitle(win, "Sliders");

	WMSetWindowCloseAction(win, closeAction, NULL);

	s = WMCreateSlider(win);
	WMResizeWidget(s, 16, 100);
	WMMoveWidget(s, 100, 100);
	WMSetSliderKnobThickness(s, 8);
	WMSetSliderContinuous(s, False);
	WMSetSliderAction(s, sliderCallback, s);

	s = WMCreateSlider(win);
	WMResizeWidget(s, 100, 16);
	WMMoveWidget(s, 100, 10);
	WMSetSliderKnobThickness(s, 8);

	WMRealizeWidget(win);
	WMMapSubwidgets(win);
	WMMapWidget(win);
}
Пример #3
0
void testScrollView(WMScreen * scr)
{
	WMWindow *win;
	WMScrollView *sview;
	WMFrame *f;
	WMLabel *l;
	char buffer[128];
	int i;

	windowCount++;

	/* creates the top-level window */
	win = WMCreateWindow(scr, "testScroll");
	WMSetWindowTitle(win, "Scrollable View");

	WMSetWindowCloseAction(win, closeAction, NULL);

	/* set the window size */
	WMResizeWidget(win, 300, 300);

	/* creates a scrollable view inside the top-level window */
	sview = WMCreateScrollView(win);
	WMResizeWidget(sview, 200, 200);
	WMMoveWidget(sview, 30, 30);
	WMSetScrollViewRelief(sview, WRSunken);
	WMSetScrollViewHasVerticalScroller(sview, True);
	WMSetScrollViewHasHorizontalScroller(sview, True);

	/* create a frame with a bunch of labels */
	f = WMCreateFrame(win);
	WMResizeWidget(f, 400, 400);
	WMSetFrameRelief(f, WRFlat);

	for (i = 0; i < 20; i++) {
		l = WMCreateLabel(f);
		WMResizeWidget(l, 50, 18);
		WMMoveWidget(l, 10, 20 * i);
		sprintf(buffer, "Label %i", i);
		WMSetLabelText(l, buffer);
		WMSetLabelRelief(l, WRSimple);
	}
	WMMapSubwidgets(f);
	WMMapWidget(f);

	WMSetScrollViewContentView(sview, WMWidgetView(f));

	/* make the windows of the widgets be actually created */
	WMRealizeWidget(win);

	/* Map all child widgets of the top-level be mapped.
	 * You must call this for each container widget (like frames),
	 * even if they are childs of the top-level window.
	 */
	WMMapSubwidgets(win);

	/* map the top-level window */
	WMMapWidget(win);
}
Пример #4
0
int main(int argc, char **argv)
{
	Display *dpy;
	WMWindow *win;
	WMScreen *scr;
	WMButton *lab, *l0 = NULL;
	WMLabel *pos;
	int x, y, c;
	char buf[20];

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

	dpy = XOpenDisplay("");
	if (!dpy) {
		wfatal("cant open display");
		exit(0);
	}

	scr = WMCreateSimpleApplicationScreen(dpy);

	win = WMCreateWindow(scr, "main");
	WMResizeWidget(win, 20 * 33, 20 + 20 * 9);
	WMSetWindowTitle(win, "Font Chars");
	WMSetWindowCloseAction(win, quit, NULL);
	pos = WMCreateLabel(win);
	WMResizeWidget(pos, 20 * 33, 20);
	WMMoveWidget(pos, 10, 5);

	c = 0;
	for (y = 0; y < 8; y++) {
		for (x = 0; x < 32; x++, c++) {
			lab = WMCreateCustomButton(win, WBBStateLightMask);
			WMResizeWidget(lab, 20, 20);
			WMMoveWidget(lab, 10 + x * 20, 30 + y * 20);
			sprintf(buf, "%c", c);
			WMSetButtonText(lab, buf);
			WMSetButtonAction(lab, show, pos);
			WMHangData(lab, (void *)(uintptr_t) c);
			if (c > 0) {
				WMGroupButtons(l0, lab);
			} else {
				l0 = lab;
			}
		}
	}
	WMRealizeWidget(win);
	WMMapSubwidgets(win);
	WMMapWidget(win);
	WMScreenMainLoop(scr);
	return 0;
}
Пример #5
0
void testBox(WMScreen * scr)
{
	WMWindow *win;
	WMBox *box, *hbox;
	WMButton *btn;
	WMPopUpButton *pop;
	int i;

	windowCount++;

	win = WMCreateWindow(scr, "testBox");
	WMSetWindowTitle(win, "Box");
	WMSetWindowCloseAction(win, closeAction, NULL);
	WMResizeWidget(win, 400, 300);

	box = WMCreateBox(win);
	WMSetBoxBorderWidth(box, 5);
	WMSetViewExpandsToParent(WMWidgetView(box), 0, 0, 0, 0);

	/*WMSetBoxHorizontal(box, True); */
	for (i = 0; i < 4; i++) {
		btn = WMCreateCommandButton(box);
		WMSetButtonText(btn, "bla");
		WMMapWidget(btn);
		WMAddBoxSubview(box, WMWidgetView(btn), i & 1, True, 20, 0, 5);
	}

	pop = WMCreatePopUpButton(box);
	WMAddPopUpButtonItem(pop, "ewqeq");
	WMAddPopUpButtonItem(pop, "ewqeqrewrw");
	WMAddBoxSubview(box, WMWidgetView(pop), False, True, 20, 0, 5);
	WMMapWidget(pop);

	hbox = WMCreateBox(box);
	WMSetBoxHorizontal(hbox, True);
	WMAddBoxSubview(box, WMWidgetView(hbox), False, True, 24, 0, 0);
	WMMapWidget(hbox);

	for (i = 0; i < 4; i++) {
		btn = WMCreateCommandButton(hbox);
		WMSetButtonText(btn, "bla");
		WMMapWidget(btn);
		WMAddBoxSubview(hbox, WMWidgetView(btn), 1, True, 60, 0, i < 3 ? 5 : 0);
	}

	WMRealizeWidget(win);
	WMMapSubwidgets(win);
	WMMapWidget(win);

}
Пример #6
0
void testFrame(WMScreen * scr)
{
	WMWindow *win;
	WMFrame *frame;
	int i;
	static char *titles[] = {
		"AboveTop",
		"AtTop",
		"BelowTop",
		"AboveBottom",
		"AtBottom",
		"BelowBottom"
	};
	static WMTitlePosition pos[] = {
		WTPAboveTop,
		WTPAtTop,
		WTPBelowTop,
		WTPAboveBottom,
		WTPAtBottom,
		WTPBelowBottom
	};

	windowCount++;

	win = WMCreateWindow(scr, "testFrame");
	WMSetWindowTitle(win, "Frame");
	WMSetWindowCloseAction(win, closeAction, NULL);
	WMResizeWidget(win, 400, 300);

	for (i = 0; i < 6; i++) {
		frame = WMCreateFrame(win);
		WMMoveWidget(frame, 8 + (i % 3) * 130, 8 + (i / 3) * 130);
		WMResizeWidget(frame, 120, 120);
		WMSetFrameTitle(frame, titles[i]);
		WMSetFrameTitlePosition(frame, pos[i]);
	}

	WMRealizeWidget(win);
	WMMapSubwidgets(win);
	WMMapWidget(win);

}
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);
}
Пример #8
0
void testGradientButtons(WMScreen * scr)
{
	WMWindow *win;
	WMButton *btn;
	WMPixmap *pix1, *pix2;
	RImage *back;
	RColor light, dark;
	WMColor *color, *altColor;

	windowCount++;

	/* creates the top-level window */
	win = WMCreateWindow(scr, "testGradientButtons");
	WMSetWindowTitle(win, "Gradiented Button Demo");
	WMResizeWidget(win, 300, 200);

	WMSetWindowCloseAction(win, closeAction, NULL);

	light.red = 0x90;
	light.green = 0x85;
	light.blue = 0x90;
	dark.red = 0x35;
	dark.green = 0x30;
	dark.blue = 0x35;

	color = WMCreateRGBColor(scr, 0x5900, 0x5100, 0x5900, True);
	WMSetWidgetBackgroundColor(win, color);
	WMReleaseColor(color);

	back = RRenderGradient(60, 24, &dark, &light, RGRD_DIAGONAL);
	RBevelImage(back, RBEV_RAISED2);
	pix1 = WMCreatePixmapFromRImage(scr, back, 0);
	RReleaseImage(back);

	back = RRenderGradient(60, 24, &dark, &light, RGRD_DIAGONAL);
	RBevelImage(back, RBEV_SUNKEN);
	pix2 = WMCreatePixmapFromRImage(scr, back, 0);
	RReleaseImage(back);

	color = WMWhiteColor(scr);
	altColor = WMCreateNamedColor(scr, "red", True);

	btn = WMCreateButton(win, WBTMomentaryChange);
	WMResizeWidget(btn, 60, 24);
	WMMoveWidget(btn, 20, 100);
	WMSetButtonBordered(btn, False);
	WMSetButtonImagePosition(btn, WIPOverlaps);
	WMSetButtonImage(btn, pix1);
	WMSetButtonAltImage(btn, pix2);
	WMSetButtonText(btn, "Cool");
	WMSetButtonTextColor(btn, color);
	WMSetButtonAltTextColor(btn, altColor);

	WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn));

	btn = WMCreateButton(win, WBTMomentaryChange);
	WMResizeWidget(btn, 60, 24);
	WMMoveWidget(btn, 90, 100);
	WMSetButtonBordered(btn, False);
	WMSetButtonImagePosition(btn, WIPOverlaps);
	WMSetButtonImage(btn, pix1);
	WMSetButtonAltImage(btn, pix2);
	WMSetButtonText(btn, "Button");
	WMSetButtonTextColor(btn, color);

	WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn));

	WMReleaseColor(color);
	color = WMCreateNamedColor(scr, "orange", True);

	btn = WMCreateButton(win, WBTMomentaryChange);
	WMResizeWidget(btn, 60, 24);
	WMMoveWidget(btn, 160, 100);
	WMSetButtonBordered(btn, False);
	WMSetButtonImagePosition(btn, WIPOverlaps);
	WMSetButtonImage(btn, pix1);
	WMSetButtonAltImage(btn, pix2);
	WMSetButtonText(btn, "Test");
	WMSetButtonTextColor(btn, color);

	WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
				WMWidgetView(btn));

	WMReleaseColor(color);
	WMReleaseColor(altColor);

	WMRealizeWidget(win);
	WMMapSubwidgets(win);
	WMMapWidget(win);
}
Пример #9
0
void testList(WMScreen * scr)
{
	WMWindow *win;
	WMList *list;
	WMList *mlist;
	WMLabel *label;
	WMLabel *mlabel;
	WMLabel *title;
	WMLabel *mtitle;
	char text[100];
	int i;

	windowCount++;

	win = WMCreateWindow(scr, "testList");
	WMResizeWidget(win, 370, 250);
	WMSetWindowTitle(win, "List");
	WMSetWindowCloseAction(win, closeAction, NULL);

	title = WMCreateLabel(win);
	WMResizeWidget(title, 150, 20);
	WMMoveWidget(title, 10, 10);
	WMSetLabelRelief(title, WRRidge);
	WMSetLabelText(title, "Single selection list");

	mtitle = WMCreateLabel(win);
	WMResizeWidget(mtitle, 150, 20);
	WMMoveWidget(mtitle, 210, 10);
	WMSetLabelRelief(mtitle, WRRidge);
	WMSetLabelText(mtitle, "Multiple selection list");

	list = WMCreateList(win);
	/*WMSetListAllowEmptySelection(list, True); */
	WMMoveWidget(list, 10, 40);
	for (i = 0; i < 105; i++) {
		sprintf(text, "Item %i", i);
		WMAddListItem(list, text);
	}
	mlist = WMCreateList(win);
	WMSetListAllowMultipleSelection(mlist, True);
	/*WMSetListAllowEmptySelection(mlist, True); */
	WMMoveWidget(mlist, 210, 40);
	for (i = 0; i < 135; i++) {
		sprintf(text, "Item %i", i);
		WMAddListItem(mlist, text);
	}

	label = WMCreateLabel(win);
	WMResizeWidget(label, 150, 40);
	WMMoveWidget(label, 10, 200);
	WMSetLabelRelief(label, WRRidge);
	WMSetLabelText(label, "Selected items: 0");

	mlabel = WMCreateLabel(win);
	WMResizeWidget(mlabel, 150, 40);
	WMMoveWidget(mlabel, 210, 200);
	WMSetLabelRelief(mlabel, WRRidge);
	WMSetLabelText(mlabel, "Selected items: 0");

	WMSetListAction(list, singleClick, label);
	WMSetListDoubleAction(list, doubleClick, label);
	WMSetListAction(mlist, singleClick, mlabel);
	WMSetListDoubleAction(mlist, doubleClick, mlabel);

	WMAddNotificationObserver(listSelectionObserver, label, WMListSelectionDidChangeNotification, list);
	WMAddNotificationObserver(listSelectionObserver, mlabel, WMListSelectionDidChangeNotification, mlist);

	WMRealizeWidget(win);
	WMMapSubwidgets(win);
	WMMapWidget(win);
}
Пример #10
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;
}
Пример #11
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;
}