Example #1
0
static void destroyTabView(TabView * tPtr)
{
	int i;

	for (i = 0; i < tPtr->itemCount; i++) {
		WMSetTabViewItemView(tPtr->items[i], NULL);
		WMDestroyTabViewItem(tPtr->items[i]);
	}
	wfree(tPtr->items);

	WMReleaseColor(tPtr->lightGray);
	WMReleaseColor(tPtr->tabColor);
	WMReleaseFont(tPtr->font);

	wfree(tPtr);
}
Example #2
0
static Pixmap makePixmap(WMScreen * scr, int width, int height, int side, Pixmap * mask)
{
	Display *dpy = WMScreenDisplay(scr);
	Pixmap bitmap;
	Pixmap pixmap;
	int x, y;
	WMColor *black = WMBlackColor(scr);

	bitmap = XCreatePixmap(dpy, scr->rootWin, width + SPACE, height + SPACE, 1);

	XSetForeground(dpy, scr->monoGC, 0);
	XFillRectangle(dpy, bitmap, scr->monoGC, 0, 0, width + SPACE, height + SPACE);

	pixmap = XCreatePixmap(dpy, scr->rootWin, width + SPACE, height + SPACE, scr->depth);

	XFillRectangle(dpy, pixmap, WMColorGC(black), 0, 0, width + SPACE, height + SPACE);

	if (side & BOTTOM) {
		y = 0;
	} else {
		y = SPACE;
	}
	x = 0;

	drawBalloon(scr, bitmap, pixmap, x, y, width, height, side);

	*mask = bitmap;

	WMReleaseColor(black);

	return pixmap;
}
Example #3
0
void WMSetBalloonTextColor(WMScreen * scr, WMColor * color)
{
	Balloon *bPtr = scr->balloon;

	if (bPtr->textColor)
		WMReleaseColor(bPtr->textColor);

	bPtr->textColor = WMRetainColor(color);
}
Example #4
0
void WMSetLabelTextColor(WMLabel * lPtr, WMColor * color)
{
	if (lPtr->textColor)
		WMReleaseColor(lPtr->textColor);
	lPtr->textColor = WMRetainColor(color);

	if (lPtr->view->flags.realized) {
		paintLabel(lPtr);
	}
}
Example #5
0
void W_SetViewBackgroundColor(W_View * view, WMColor * color)
{
	if (view->backColor)
		WMReleaseColor(view->backColor);
	view->backColor = WMRetainColor(color);

	view->attribFlags |= CWBackPixel;
	view->attribs.background_pixel = W_PIXEL(color);
	if (view->flags.realized) {
		XSetWindowBackground(view->screen->display, view->window, W_PIXEL(color));
		XClearWindow(view->screen->display, view->window);
	}
}
Example #6
0
static void destroyLabel(Label * lPtr)
{
	if (lPtr->textColor)
		WMReleaseColor(lPtr->textColor);

	if (lPtr->caption)
		wfree(lPtr->caption);

	if (lPtr->font)
		WMReleaseFont(lPtr->font);

	if (lPtr->image)
		WMReleasePixmap(lPtr->image);

	wfree(lPtr);
}
Example #7
0
static void destroyBalloon(Balloon * bPtr)
{
	WMHashEnumerator e;
	char *str;

	e = WMEnumerateHashTable(bPtr->table);

	while ((str = WMNextHashEnumeratorItem(&e))) {
		wfree(str);
	}
	WMFreeHashTable(bPtr->table);

	if (bPtr->textColor)
		WMReleaseColor(bPtr->textColor);

	if (bPtr->font)
		WMReleaseFont(bPtr->font);

	wfree(bPtr);
}
Example #8
0
Bool WMSetBlackColor(W_Screen *scr, WMColor *col) {
  if (!scr || !col) return False;
  WMReleaseColor(scr->black);
  scr->black = col;
  return True;
}
Example #9
0
Bool WMSetWhiteColor(W_Screen *scr, WMColor *col) {
  if (!scr || !col) return False;
  WMReleaseColor(scr->white);
  scr->white = col;
  return True;
}
Example #10
0
Bool WMSetDarkGrayColor(W_Screen *scr, WMColor *col) {
  if (!scr || !col) return False;
  WMReleaseColor(scr->darkGray);
  scr->darkGray = col;
  return True;
}
Example #11
0
static void createPanel(Panel *p)
{
	_Panel *panel = (_Panel *) p;
	WMScreen *scr = WMWidgetScreen(panel->parent);
	WMPixmap *icon1, *icon2;
	RImage *xis = NULL;
	RContext *rc = WMScreenRContext(scr);
	char *path;
	int i, j, k;
	char *buf1, *buf2;
	WMColor *color;
	WMFont *font;

	path = LocateImage(ARQUIVO_XIS);
	if (path) {
		xis = RLoadImage(rc, path, 0);
		if (!xis) {
			wwarning(_("could not load image file %s"), path);
		}
		wfree(path);
	}

	panel->box = WMCreateBox(panel->parent);
	WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);

	/***************** Auto-delays *****************/
	buf1 = wmalloc(strlen(DELAY_ICON) + 1);
	buf2 = wmalloc(strlen(DELAY_ICON_S) + 1);

	for (k = 0; k < 2; k++)
	{
		panel->autoDelayF[k] = WMCreateFrame(panel->box);
		WMResizeWidget(panel->autoDelayF[k], 370, 100);
		WMMoveWidget(panel->autoDelayF[k], 15, 10 + k * 110);
		if (k == 0)
			WMSetFrameTitle(panel->autoDelayF[k], _("Clip autocollapsing delays"));
		else
			WMSetFrameTitle(panel->autoDelayF[k], _("Clip autoraising delays"));

		for (i = 0; i < 2; i++)
		{
			panel->autoDelayL[i + k * 2] = WMCreateLabel(panel->autoDelayF[k]);
			WMResizeWidget(panel->autoDelayL[i + k * 2], 155, 20);
			WMMoveWidget(panel->autoDelayL[i + k * 2], 10, 27 + 40 * i);
			WMSetLabelText(panel->autoDelayL[i + k * 2], _(auto_delay[i + k * 2].string));
			/* WMSetLabelTextAlignment(panel->autoDelayL[i + k * 2], WARight); */

			for (j = 0; j < 5; j++)
			{
				panel->autoDelayB[i + k * 2][j] = WMCreateCustomButton(panel->autoDelayF[k], WBBStateChangeMask);
				WMResizeWidget(panel->autoDelayB[i + k * 2][j], 25, 25);
				WMMoveWidget(panel->autoDelayB[i + k * 2][j], 145 + (28 * j), 25 + 40 * i);
				WMSetButtonBordered(panel->autoDelayB[i + k * 2][j], False);
				WMSetButtonImagePosition(panel->autoDelayB[i + k * 2][j], WIPImageOnly);
				WMSetButtonAction(panel->autoDelayB[i + k * 2][j], pushAutoDelayButton, panel);
				if (j > 0)
					WMGroupButtons(panel->autoDelayB[i + k * 2][0], panel->autoDelayB[i + k * 2][j]);
				sprintf(buf1, DELAY_ICON, j);
				CreateImages(scr, rc, NULL, buf1, &icon1, NULL);
				if (icon1) {
					WMSetButtonImage(panel->autoDelayB[i + k * 2][j], icon1);
					WMReleasePixmap(icon1);
				} else {
					wwarning(_("could not load icon file %s"), buf1);
				}
				sprintf(buf2, DELAY_ICON_S, j);
				CreateImages(scr, rc, NULL, buf2, &icon2, NULL);
				if (icon2) {
					WMSetButtonAltImage(panel->autoDelayB[i + k * 2][j], icon2);
					WMReleasePixmap(icon2);
				} else {
					wwarning(_("could not load icon file %s"), buf2);
				}
			}

			panel->autoDelayT[i + k * 2] = WMCreateTextField(panel->autoDelayF[k]);
			WMResizeWidget(panel->autoDelayT[i + k * 2], 36, 20);
			WMMoveWidget(panel->autoDelayT[i + k * 2], 287, 27 + 40 * i);
			WMAddNotificationObserver(autoDelayChanged, panel, WMTextDidChangeNotification, panel->autoDelayT[i + k * 2]);

			color = WMDarkGrayColor(scr);
			font = WMSystemFontOfSize(scr, 10);
			panel->autoDelayMsL[i + k * 2] = WMCreateLabel(panel->autoDelayF[k]);
			WMResizeWidget(panel->autoDelayMsL[i + k * 2], 36, 16);
			WMMoveWidget(panel->autoDelayMsL[i + k * 2], 327, 33 + 40 *i);
			WMSetLabelText(panel->autoDelayMsL[i + k * 2], _("msec"));
			WMSetLabelTextColor(panel->autoDelayMsL[i + k * 2], color);
			WMSetLabelFont(panel->autoDelayMsL[i + k * 2], font);
			WMReleaseColor(color);
			WMReleaseFont(font);
		}

		WMMapSubwidgets(panel->autoDelayF[k]);
	}
	wfree(buf1);
	wfree(buf2);

	/***************** Enable/disable clip/dock/drawers *****************/
	panel->dockF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->dockF, 115, 210);
	WMMoveWidget(panel->dockF, 390, 10);
	WMSetFrameTitle(panel->dockF, _("Dock/Clip/Drawer"));

	for (i = 0; i < 3; i++)
	{
		panel->docksB[i] = WMCreateButton(panel->dockF, WBTToggle);
		WMResizeWidget(panel->docksB[i], 56, 56);
		WMMoveWidget(panel->docksB[i], 30, 20 + 62 * i);
		WMSetButtonImagePosition(panel->docksB[i], WIPImageOnly);
		CreateImages(scr, rc, xis, dock_config[i].icon_file, &icon1, &icon2);
		if (icon2) {
			WMSetButtonImage(panel->docksB[i], icon2);
			WMReleasePixmap(icon2);
		}
		if (icon1) {
			WMSetButtonAltImage(panel->docksB[i], icon1);
			WMReleasePixmap(icon1);
		}
		switch(i)
		{
		case 0:
			WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n"
						  "vertical icon bar in the side of the screen)."), WMWidgetView(panel->docksB[i]));
			break;
		case 1:
			WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n"
						  "a paper clip icon)."), WMWidgetView(panel->docksB[i]));
			break;
		case 2:
			WMSetBalloonTextForView(_("Disable/enable Drawers (a dock that stores\n"
						  "application icons horizontally). The dock is required."), WMWidgetView(panel->docksB[i]));
			break;
		}
		WMSetButtonAction(panel->docksB[i], pushDockButton, panel);
	}
	
	WMMapSubwidgets(panel->dockF);

	if (xis)
		RReleaseImage(xis);

	WMRealizeWidget(panel->box);
	WMMapSubwidgets(panel->box);

	showData(panel);
}
Example #12
0
static void createPanel(Panel * p)
{
	_Panel *panel = (_Panel *) p;
	WMScreen *scr = WMWidgetScreen(panel->parent);
	int i;
	WMColor *color;
	WMFont *font;

	color = WMDarkGrayColor(scr);
	font = WMSystemFontOfSize(scr, 10);

	panel->box = WMCreateBox(panel->parent);
	WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);

    /**************** Initial Key Repeat ***************/
	panel->delaF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->delaF, 495, 60);
	WMMoveWidget(panel->delaF, 15, 10);
	WMSetFrameTitle(panel->delaF, _("Initial Key Repeat"));

	for (i = 0; i < 4; i++) {
		panel->delaB[i] = WMCreateButton(panel->delaF, WBTOnOff);
		WMResizeWidget(panel->delaB[i], 60, 20);
		WMMoveWidget(panel->delaB[i], 70 + i * 60, 25);
		if (i > 0)
			WMGroupButtons(panel->delaB[0], panel->delaB[i]);
		switch (i) {
		case 0:
			WMSetButtonText(panel->delaB[i], "....a");
			break;
		case 1:
			WMSetButtonText(panel->delaB[i], "...a");
			break;
		case 2:
			WMSetButtonText(panel->delaB[i], "..a");
			break;
		case 3:
			WMSetButtonText(panel->delaB[i], ".a");
			break;
		}
	}
	panel->dmsT = WMCreateTextField(panel->delaF);
	WMResizeWidget(panel->dmsT, 50, 20);
	WMMoveWidget(panel->dmsT, 345, 25);
	/*    WMSetTextFieldAlignment(panel->dmsT, WARight); */

	panel->dmsL = WMCreateLabel(panel->delaF);
	WMResizeWidget(panel->dmsL, 30, 16);
	WMMoveWidget(panel->dmsL, 400, 30);
	WMSetLabelTextColor(panel->dmsL, color);
	WMSetLabelFont(panel->dmsL, font);
	WMSetLabelText(panel->dmsL, "msec");

	WMMapSubwidgets(panel->delaF);

    /**************** Key Repeat Rate ***************/
	panel->rateF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->rateF, 495, 60);
	WMMoveWidget(panel->rateF, 15, 95);
	WMSetFrameTitle(panel->rateF, _("Key Repeat Rate"));

	for (i = 0; i < 4; i++) {
		panel->rateB[i] = WMCreateButton(panel->rateF, WBTOnOff);
		WMResizeWidget(panel->rateB[i], 60, 20);
		WMMoveWidget(panel->rateB[i], 70 + i * 60, 25);
		if (i > 0)
			WMGroupButtons(panel->rateB[0], panel->rateB[i]);
		switch (i) {
		case 0:
			WMSetButtonText(panel->rateB[i], "a....a");
			break;
		case 1:
			WMSetButtonText(panel->rateB[i], "a...a");
			break;
		case 2:
			WMSetButtonText(panel->rateB[i], "a..a");
			break;
		case 3:
			WMSetButtonText(panel->rateB[i], "a.a");
			break;
		}
	}
	panel->rmsT = WMCreateTextField(panel->rateF);
	WMResizeWidget(panel->rmsT, 50, 20);
	WMMoveWidget(panel->rmsT, 345, 25);
	/*    WMSetTextFieldAlignment(panel->rmsT, WARight); */

	panel->rmsL = WMCreateLabel(panel->rateF);
	WMResizeWidget(panel->rmsL, 30, 16);
	WMMoveWidget(panel->rmsL, 400, 30);
	WMSetLabelTextColor(panel->rmsL, color);
	WMSetLabelFont(panel->rmsL, font);
	WMSetLabelText(panel->rmsL, "msec");

	WMMapSubwidgets(panel->rateF);

	panel->testT = WMCreateTextField(panel->box);
	WMResizeWidget(panel->testT, 480, 20);
	WMMoveWidget(panel->testT, 20, 180);
	WMSetTextFieldText(panel->testT, _("Type here to test"));

	WMReleaseColor(color);
	WMReleaseFont(font);

	WMRealizeWidget(panel->box);
	WMMapSubwidgets(panel->box);
}
Example #13
0
static void destroyView(W_View * view)
{
	W_View *ptr;

	if (view->flags.alreadyDead)
		return;
	view->flags.alreadyDead = 1;

	/* delete the balloon text for the view, if there's any */
	WMSetBalloonTextForView(NULL, view);

	if (view->nextFocusChain)
		view->nextFocusChain->prevFocusChain = view->prevFocusChain;
	if (view->prevFocusChain)
		view->prevFocusChain->nextFocusChain = view->nextFocusChain;

	/* Do not leave focus in a inexisting control */
	if (W_FocusedViewOfToplevel(W_TopLevelOfView(view)) == view)
		W_SetFocusOfTopLevel(W_TopLevelOfView(view), NULL);

	if (view->flags.topLevel) {
		W_FocusInfo *info = view->screen->focusInfo;
		/* remove focus information associated to this toplevel */

		if (info) {
			if (info->toplevel == view) {
				view->screen->focusInfo = info->next;
				wfree(info);
			} else {
				while (info->next) {
					if (info->next->toplevel == view)
						break;
					info = info->next;
				}
				if (info->next) {
					W_FocusInfo *next = info->next->next;
					wfree(info->next);
					info->next = next;
				}
				/* else the toplevel did not have any focused subview */
			}
		}
	}

	/* destroy children recursively */
	while (view->childrenList != NULL) {
		ptr = view->childrenList;
		ptr->flags.parentDying = 1;

		W_DestroyView(ptr);

		if (ptr == view->childrenList) {
			view->childrenList = ptr->nextSister;
			ptr->parent = NULL;
		}
	}

	W_CallDestroyHandlers(view);

	if (view->flags.realized) {
		XDeleteContext(view->screen->display, view->window, ViewContext);

		/* if parent is being destroyed, it will die naturaly */
		if (!view->flags.parentDying || view->flags.topLevel)
			XDestroyWindow(view->screen->display, view->window);
	}

	/* remove self from parent's children list */
	unparentView(view);

	/* the array has a wfree() destructor that will be called automatically */
	WMFreeArray(view->eventHandlers);
	view->eventHandlers = NULL;

	WMRemoveNotificationObserver(view);

	W_FreeViewXdndPart(view);

	if (view->backColor)
		WMReleaseColor(view->backColor);

	wfree(view);
}
Example #14
0
static void drawBalloon(WMScreen * scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, int h, int side)
{
	Display *dpy = scr->display;
	WMColor *white = WMWhiteColor(scr);
	WMColor *black = WMBlackColor(scr);
	GC bgc = scr->monoGC;
	GC gc = WMColorGC(white);
	int rad = h * 3 / 10;
	XPoint pt[3], ipt[3];
	int w1;

	/* outline */
	XSetForeground(dpy, bgc, 1);

	XFillArc(dpy, bitmap, bgc, x, y, rad, rad, 90 * 64, 90 * 64);
	XFillArc(dpy, bitmap, bgc, x, y + h - 1 - rad, rad, rad, 180 * 64, 90 * 64);

	XFillArc(dpy, bitmap, bgc, x + w - 1 - rad, y, rad, rad, 0 * 64, 90 * 64);
	XFillArc(dpy, bitmap, bgc, x + w - 1 - rad, y + h - 1 - rad, rad, rad, 270 * 64, 90 * 64);

	XFillRectangle(dpy, bitmap, bgc, x, y + rad / 2, w, h - rad);
	XFillRectangle(dpy, bitmap, bgc, x + rad / 2, y, w - rad, h);

	/* interior */
	XFillArc(dpy, pix, gc, x + 1, y + 1, rad, rad, 90 * 64, 90 * 64);
	XFillArc(dpy, pix, gc, x + 1, y + h - 2 - rad, rad, rad, 180 * 64, 90 * 64);

	XFillArc(dpy, pix, gc, x + w - 2 - rad, y + 1, rad, rad, 0 * 64, 90 * 64);
	XFillArc(dpy, pix, gc, x + w - 2 - rad, y + h - 2 - rad, rad, rad, 270 * 64, 90 * 64);

	XFillRectangle(dpy, pix, gc, x + 1, y + 1 + rad / 2, w - 2, h - 2 - rad);
	XFillRectangle(dpy, pix, gc, x + 1 + rad / 2, y + 1, w - 2 - rad, h - 2);

	if (side & BOTTOM) {
		pt[0].y = y + h - 1;
		pt[1].y = y + h - 1 + SPACE;
		pt[2].y = y + h - 1;
		ipt[0].y = pt[0].y - 1;
		ipt[1].y = pt[1].y - 1;
		ipt[2].y = pt[2].y - 1;
	} else {
		pt[0].y = y;
		pt[1].y = y - SPACE;
		pt[2].y = y;
		ipt[0].y = pt[0].y + 1;
		ipt[1].y = pt[1].y + 1;
		ipt[2].y = pt[2].y + 1;
	}

	/*w1 = WMAX(h, 24); */
	w1 = WMAX(h, 21);

	if (side & RIGHT) {
		pt[0].x = x + w - w1 + 2 * w1 / 16;
		pt[1].x = x + w - w1 + 11 * w1 / 16;
		pt[2].x = x + w - w1 + 7 * w1 / 16;
		ipt[0].x = x + 1 + w - w1 + 2 * (w1 - 1) / 16;
		ipt[1].x = x + 1 + w - w1 + 11 * (w1 - 1) / 16;
		ipt[2].x = x + 1 + w - w1 + 7 * (w1 - 1) / 16;
		/*ipt[0].x = pt[0].x+1;
		   ipt[1].x = pt[1].x;
		   ipt[2].x = pt[2].x; */
	} else {
		pt[0].x = x + w1 - 2 * w1 / 16;
		pt[1].x = x + w1 - 11 * w1 / 16;
		pt[2].x = x + w1 - 7 * w1 / 16;
		ipt[0].x = x - 1 + w1 - 2 * (w1 - 1) / 16;
		ipt[1].x = x - 1 + w1 - 11 * (w1 - 1) / 16;
		ipt[2].x = x - 1 + w1 - 7 * (w1 - 1) / 16;
		/*ipt[0].x = pt[0].x-1;
		   ipt[1].x = pt[1].x;
		   ipt[2].x = pt[2].x; */
	}

	XFillPolygon(dpy, bitmap, bgc, pt, 3, Convex, CoordModeOrigin);
	XFillPolygon(dpy, pix, gc, ipt, 3, Convex, CoordModeOrigin);

	/* fix outline */
	XDrawLines(dpy, pix, WMColorGC(black), pt, 3, CoordModeOrigin);
	if (side & RIGHT) {
		pt[0].x++;
		pt[2].x--;
	} else {
		pt[0].x--;
		pt[2].x++;
	}
	XDrawLines(dpy, pix, WMColorGC(black), pt, 3, CoordModeOrigin);

	WMReleaseColor(white);
	WMReleaseColor(black);
}
Example #15
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);
}
Example #16
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;
}
Example #17
0
static void createPanel(Panel * p)
{
	_Panel *panel = (_Panel *) p;
	WMScreen *scr = WMWidgetScreen(panel->parent);
	WMPixmap *icon;
	char *buf1, *buf2;
	int i;
	RColor color;
	char *path;

	color.red = 0xae;
	color.green = 0xaa;
	color.blue = 0xae;

	panel->box = WMCreateBox(panel->parent);
	WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);

    /**************** Mouse Speed ****************/
	panel->speedF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->speedF, 219, 85);
	WMMoveWidget(panel->speedF, 9, 54);
	WMSetFrameTitle(panel->speedF, _("Mouse Speed"));

	panel->speedL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->speedL, 40, 46);
	WMMoveWidget(panel->speedL, 8, 10);
	WMSetLabelImagePosition(panel->speedL, WIPImageOnly);
	path = LocateImage(SPEED_ICON_FILE);
	if (path) {
		icon = WMCreateBlendedPixmapFromFile(scr, path, &color);
		if (icon) {
			WMSetLabelImage(panel->speedL, icon);
			WMReleasePixmap(icon);
		} else {
			wwarning(_("could not load icon %s"), path);
		}
		wfree(path);
	}

	panel->speedS = WMCreateSlider(panel->speedF);
	WMResizeWidget(panel->speedS, 150, 15);
	WMMoveWidget(panel->speedS, 58, 30);
	WMSetSliderMinValue(panel->speedS, 0);
	WMSetSliderMaxValue(panel->speedS, 40);
	WMSetSliderContinuous(panel->speedS, False);
	WMSetSliderAction(panel->speedS, speedChange, panel);

	panel->acceL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->acceL, 50, 16);
	WMMoveWidget(panel->acceL, 8, 58);
	WMSetLabelTextAlignment(panel->acceL, WARight);
	WMSetLabelText(panel->acceL, _("Accel.:"));

	panel->acceT = WMCreateTextField(panel->speedF);
	WMResizeWidget(panel->acceT, 40, 20);
	WMMoveWidget(panel->acceT, 58, 56);
	WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->acceT);

	panel->threL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->threL, 80, 16);
	WMMoveWidget(panel->threL, 98, 58);
	WMSetLabelTextAlignment(panel->threL, WARight);
	WMSetLabelText(panel->threL, _("Threshold:"));

	panel->threT = WMCreateTextField(panel->speedF);
	WMResizeWidget(panel->threT, 30, 20);
	WMMoveWidget(panel->threT, 178, 56);
	WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->threT);

	WMMapSubwidgets(panel->speedF);

	/* ************** Grab Modifier **************** */
	panel->grabF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->grabF, 219, 46);
	WMMoveWidget(panel->grabF, 9, 5);
	WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier"));

	WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n"
				  "involve dragging windows with the mouse,\n"
				  "clicking inside the window."), WMWidgetView(panel->grabF));

	panel->grabP = WMCreatePopUpButton(panel->grabF);
	WMResizeWidget(panel->grabP, 178, 20);
	WMMoveWidget(panel->grabP, 20, 17);

	fillModifierPopUp(panel->grabP);
	WMMapSubwidgets(panel->grabF);

	/***************** Doubleclick Delay ****************/

	panel->ddelaF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->ddelaF, 219, 80);
	WMMoveWidget(panel->ddelaF, 9, 142);
	WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay"));

	buf1 = wmalloc(strlen(DELAY_ICON) + 2);
	buf2 = wmalloc(strlen(DELAY_ICON_S) + 2);

	for (i = 0; i < wlengthof(panel->ddelaB); i++) {
		panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, WBBStateChangeMask);
		WMResizeWidget(panel->ddelaB[i], 25, 25);
		WMMoveWidget(panel->ddelaB[i], 18 + (40 * i), 18);
		WMSetButtonBordered(panel->ddelaB[i], False);
		WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly);
		WMSetButtonAction(panel->ddelaB[i], doubleClick, panel);
		if (i > 0) {
			WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]);
		}
		sprintf(buf1, DELAY_ICON, i + 1);
		sprintf(buf2, DELAY_ICON_S, i + 1);
		path = LocateImage(buf1);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonImage(panel->ddelaB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
		path = LocateImage(buf2);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonAltImage(panel->ddelaB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
	}
	wfree(buf1);
	wfree(buf2);

	panel->tester = CreateDoubleTest(panel->ddelaF, _("Test"));
	WMResizeWidget(panel->tester, 84, 24);
	WMMoveWidget(panel->tester, 20, 48);

	panel->ddelaT = WMCreateTextField(panel->ddelaF);
	WMResizeWidget(panel->ddelaT, 40, 20);
	WMMoveWidget(panel->ddelaT, 130, 50);

	panel->ddelaL = WMCreateLabel(panel->ddelaF);
	WMResizeWidget(panel->ddelaL, 40, 16);
	WMMoveWidget(panel->ddelaL, 173, 54);
	{
		WMFont *font;
		WMColor *color;

		font = WMSystemFontOfSize(scr, 10);
		color = WMDarkGrayColor(scr);
		WMSetLabelTextColor(panel->ddelaL, color);
		WMSetLabelFont(panel->ddelaL, font);
		WMReleaseFont(font);
		WMReleaseColor(color);
	}
	WMSetLabelText(panel->ddelaL, _("ms"));

	WMMapSubwidgets(panel->ddelaF);

	/* ************** Workspace Action Buttons **************** */

	panel->menuF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->menuF, 276, 217);
	WMMoveWidget(panel->menuF, 236, 5);
	WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions"));

	panel->disaB = WMCreateSwitchButton(panel->menuF);
	WMResizeWidget(panel->disaB, 254, 18);
	WMMoveWidget(panel->disaB, 10, 15);
	WMSetButtonText(panel->disaB, _("Disable mouse actions"));
	WMSetButtonAction(panel->disaB, toggle_disabling_of_mouse_actions, panel);

	for (i = 0; i < wlengthof(button_list); i++) {
		int j;

		panel->mouse_action[i].label = WMCreateLabel(panel->menuF);
		WMResizeWidget(panel->mouse_action[i].label, 115, 20);
		WMMoveWidget(panel->mouse_action[i].label, 4, 37 + 25 * i);
		WMSetLabelTextAlignment(panel->mouse_action[i].label, WARight);
		WMSetLabelText(panel->mouse_action[i].label, _(button_list[i].display_label));

		panel->mouse_action[i].popup = WMCreatePopUpButton(panel->menuF);
		WMResizeWidget(panel->mouse_action[i].popup, 145, 20);
		WMMoveWidget(panel->mouse_action[i].popup, 121, 37 + 25 * i);

		if (button_list[i].type == T_BUTTON) {
			for (j = 0; j < wlengthof(button_actions); j++)
				WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(button_actions[j].label));
		} else {
			for (j = 0; j < wlengthof(wheel_actions); j++)
				WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(wheel_actions[j].label));
		}
	}
	WMMapSubwidgets(panel->menuF);

	WMRealizeWidget(panel->box);
	WMMapSubwidgets(panel->box);

	showData(panel);
}
Example #18
0
File: Focus.c Project: jafd/wmaker
static void createPanel(Panel * p)
{
	_Panel *panel = (_Panel *) p;
	WMScreen *scr = WMWidgetScreen(panel->parent);
	int i;
	char *buf1, *buf2;
	WMPixmap *icon;
	WMColor *color;
	WMFont *font;

	panel->box = WMCreateBox(panel->parent);
	WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);

    /***************** Input Focus Mode *****************/
	panel->kfocF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->kfocF, 240, 125);
	WMMoveWidget(panel->kfocF, 15, 10);
	WMSetFrameTitle(panel->kfocF, _("Input Focus Mode"));

	{
		WMBox *box = WMCreateBox(panel->kfocF);
		WMSetViewExpandsToParent(WMWidgetView(box), 10, 15, 10, 10);
		WMSetBoxHorizontal(box, False);

		panel->kfocB[0] = WMCreateRadioButton(box);
		WMSetButtonText(panel->kfocB[0], _("Manual:  Click on the window to set "
						   "keyboard input focus."));
		WMAddBoxSubview(box, WMWidgetView(panel->kfocB[0]), True, True, 20, 0, 0);

		panel->kfocB[1] = WMCreateRadioButton(box);
		WMGroupButtons(panel->kfocB[0], panel->kfocB[1]);
		WMSetButtonText(panel->kfocB[1], _("Auto:  Set keyboard input focus to "
						   "the window under the mouse pointer."));
		WMAddBoxSubview(box, WMWidgetView(panel->kfocB[1]), True, True, 20, 0, 0);

		WMMapSubwidgets(box);
		WMMapWidget(box);
	}

    /***************** Colormap Installation Mode ****************/

	panel->cfocF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->cfocF, 240, 77);
	WMMoveWidget(panel->cfocF, 15, 143);
	WMSetFrameTitle(panel->cfocF, _("Install colormap in the window..."));

	panel->manB = WMCreateRadioButton(panel->cfocF);
	WMResizeWidget(panel->manB, 225, 20);
	WMMoveWidget(panel->manB, 10, 20);
	WMSetButtonText(panel->manB, _("...that has the input focus."));

	panel->autB = WMCreateRadioButton(panel->cfocF);
	WMResizeWidget(panel->autB, 225, 20);
	WMMoveWidget(panel->autB, 10, 45);
	WMSetButtonText(panel->autB, _("...that's under the mouse pointer."));
	WMGroupButtons(panel->manB, panel->autB);

	WMMapSubwidgets(panel->cfocF);

    /***************** Automatic window raise delay *****************/
	panel->raisF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->raisF, 245, 68);
	WMMoveWidget(panel->raisF, 265, 10);
	WMSetFrameTitle(panel->raisF, _("Automatic Window Raise Delay"));

	buf1 = wmalloc(strlen(DELAY_ICON) + 1);
	buf2 = wmalloc(strlen(DELAY_ICON_S) + 1);

	for (i = 0; i < 5; i++) {
		char *path;

		panel->raisB[i] = WMCreateCustomButton(panel->raisF, WBBStateChangeMask);
		WMResizeWidget(panel->raisB[i], 25, 25);
		WMMoveWidget(panel->raisB[i], 12 + (30 * i), 25);
		WMSetButtonBordered(panel->raisB[i], False);
		WMSetButtonImagePosition(panel->raisB[i], WIPImageOnly);
		WMSetButtonAction(panel->raisB[i], pushDelayButton, panel);
		if (i > 0)
			WMGroupButtons(panel->raisB[0], panel->raisB[i]);
		sprintf(buf1, DELAY_ICON, i);
		sprintf(buf2, DELAY_ICON_S, i);
		path = LocateImage(buf1);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonImage(panel->raisB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
		path = LocateImage(buf2);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonAltImage(panel->raisB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
	}
	wfree(buf1);
	wfree(buf2);

	panel->raisT = WMCreateTextField(panel->raisF);
	WMResizeWidget(panel->raisT, 36, 20);
	WMMoveWidget(panel->raisT, 165, 28);
	WMAddNotificationObserver(raiseTextChanged, panel, WMTextDidChangeNotification, panel->raisT);

	color = WMDarkGrayColor(scr);
	font = WMSystemFontOfSize(scr, 10);

	panel->raisL = WMCreateLabel(panel->raisF);
	WMResizeWidget(panel->raisL, 36, 16);
	WMMoveWidget(panel->raisL, 205, 32);
	WMSetLabelText(panel->raisL, _("msec"));
	WMSetLabelTextColor(panel->raisL, color);
	WMSetLabelFont(panel->raisL, font);

	WMReleaseColor(color);
	WMReleaseFont(font);

	WMMapSubwidgets(panel->raisF);

    /***************** Options ****************/
	panel->optF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->optF, 245, 132);
	WMMoveWidget(panel->optF, 265, 88);

	panel->ignB = WMCreateSwitchButton(panel->optF);
	WMResizeWidget(panel->ignB, 225, 50);
	WMMoveWidget(panel->ignB, 10, 4);
	WMSetButtonText(panel->ignB, _("Do not let applications receive " "the click used to focus windows."));

	panel->newB = WMCreateSwitchButton(panel->optF);
	WMResizeWidget(panel->newB, 225, 35);
	WMMoveWidget(panel->newB, 10, 49);
	WMSetButtonText(panel->newB, _("Automatically focus new windows."));

	panel->craisB = WMCreateSwitchButton(panel->optF);
	WMResizeWidget(panel->craisB, 225, 36);
	WMMoveWidget(panel->craisB, 10, 85);
	WMSetButtonText(panel->craisB, _("Raise window when switching\nfocus with keyboard."));

	WMMapSubwidgets(panel->optF);

	WMRealizeWidget(panel->box);
	WMMapSubwidgets(panel->box);

	showData(panel);
}