Esempio n. 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);
}
Esempio n. 2
0
File: Docks.c Progetto: jafd/wmaker
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;

	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], 365, 100);
		WMMoveWidget(panel->autoDelayF[k], 15, 10 + k * 110);
		if (k == 0)
			WMSetFrameTitle(panel->autoDelayF[k], _("Delays in milliseconds for autocollapsing clips"));
		else
			WMSetFrameTitle(panel->autoDelayF[k], _("Delays in milliseconds for autoraising clips"));

		for (i = 0; i < 2; i++)
		{
			panel->autoDelayL[i + k * 2] = WMCreateLabel(panel->autoDelayF[k]);
			WMResizeWidget(panel->autoDelayL[i + k * 2], 165, 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], 175 + (25 * 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], 310, 27 + 40 * i);
			WMAddNotificationObserver(autoDelayChanged, panel, WMTextDidChangeNotification, panel->autoDelayT[i + k * 2]);
		}

		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);
}
Esempio n. 3
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);
}
Esempio n. 4
0
static void createPanel(Panel *p)
{
	_Panel *panel = (_Panel *) p;
	WMScreen *scr = WMWidgetScreen(panel->parent);
	char *buf1, *buf2;
	WMPixmap *icon, *altIcon;
	RImage *xis = NULL;
	int i;
	RContext *rc = WMScreenRContext(scr);
	WMFont *font = WMSystemFontOfSize(scr, 10);
	char *path;

	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);

    /*********** Icon Slide Speed **********/
	panel->icoF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->icoF, 212, 45);
	WMMoveWidget(panel->icoF, 15, 10);
	WMSetFrameTitle(panel->icoF, _("Icon Slide Speed"));

    /*********** Shade Animation Speed **********/
	panel->shaF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->shaF, 212, 45);
	WMMoveWidget(panel->shaF, 15, 65);
	WMSetFrameTitle(panel->shaF, _("Shade Animation Speed"));

	buf1 = wmalloc(strlen(SPEED_IMAGE) + 1);
	buf2 = wmalloc(strlen(SPEED_IMAGE_S) + 1);

	for (i = 0; i < 5; i++) {
		panel->icoB[i] = WMCreateCustomButton(panel->icoF, WBBStateChangeMask);
		panel->shaB[i] = WMCreateCustomButton(panel->shaF, WBBStateChangeMask);
		WMResizeWidget(panel->icoB[i], 40, 24);
		WMMoveWidget(panel->icoB[i], 2 + (40 * i), 15);
		WMResizeWidget(panel->shaB[i], 40, 24);
		WMMoveWidget(panel->shaB[i], 2 + (40 * i), 15);
		WMSetButtonBordered(panel->icoB[i], False);
		WMSetButtonImagePosition(panel->icoB[i], WIPImageOnly);
		if (i > 0) {
			WMGroupButtons(panel->icoB[0], panel->icoB[i]);
		}
		WMSetButtonBordered(panel->shaB[i], False);
		WMSetButtonImagePosition(panel->shaB[i], WIPImageOnly);
		if (i > 0) {
			WMGroupButtons(panel->shaB[0], panel->shaB[i]);
		}
		sprintf(buf1, SPEED_IMAGE, i);
		sprintf(buf2, SPEED_IMAGE_S, i);
		path = LocateImage(buf1);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonImage(panel->icoB[i], icon);
				WMSetButtonImage(panel->shaB[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->icoB[i], icon);
				WMSetButtonAltImage(panel->shaB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
	}
	wfree(buf1);
	wfree(buf2);

	WMMapSubwidgets(panel->icoF);
	WMMapSubwidgets(panel->shaF);

    /***************** Smoothed Scaling *****************/
	panel->smoF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->smoF, 94, 100);
	WMMoveWidget(panel->smoF, 420, 10);
	WMSetFrameTitle(panel->smoF, _("Smooth Scaling"));

	panel->smoB = WMCreateButton(panel->smoF, WBTToggle);
	WMResizeWidget(panel->smoB, 64, 64);
	WMMoveWidget(panel->smoB, 15, 23);
	WMSetButtonImagePosition(panel->smoB, WIPImageOnly);
	path = LocateImage(SMOOTH_IMAGE);
	if (path) {
		RImage *image, *scaled;

		image = RLoadImage(WMScreenRContext(scr), path, 0);
		wfree(path);

		scaled = RScaleImage(image, 61, 61);
		icon = WMCreatePixmapFromRImage(scr, scaled, 128);
		RReleaseImage(scaled);
		if (icon) {
			WMSetButtonImage(panel->smoB, icon);
			WMReleasePixmap(icon);
		}

		scaled = RSmoothScaleImage(image, 61, 61);
		icon = WMCreatePixmapFromRImage(scr, scaled, 128);
		RReleaseImage(scaled);
		if (icon) {
			WMSetButtonAltImage(panel->smoB, icon);
			WMReleasePixmap(icon);
		}

		RReleaseImage(image);
	}
	WMSetBalloonTextForView(_("Smooth scaled background images, neutralizing\n"
				  "the `pixelization' effect. This will slow\n"
				  "down loading of background images considerably."), WMWidgetView(panel->smoB));

	WMMapSubwidgets(panel->smoF);

    /***************** Titlebar Style Size ****************/
	panel->titlF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->titlF, 212, 97);
	WMMoveWidget(panel->titlF, 15, 120);
	WMSetFrameTitle(panel->titlF, _("Titlebar Style"));

	panel->oldsB = WMCreateButton(panel->titlF, WBTOnOff);
	WMResizeWidget(panel->oldsB, 60, 40);
	WMMoveWidget(panel->oldsB, 16, 32);
	WMSetButtonImagePosition(panel->oldsB, WIPImageOnly);
	path = LocateImage(OLDS_IMAGE);
	if (path) {
		icon = WMCreatePixmapFromFile(scr, path);
		if (icon) {
			WMSetButtonImage(panel->oldsB, icon);
			WMReleasePixmap(icon);
		}
		wfree(path);
	}

	panel->newsB = WMCreateButton(panel->titlF, WBTOnOff);
	WMResizeWidget(panel->newsB, 60, 40);
	WMMoveWidget(panel->newsB, 76, 32);
	WMSetButtonImagePosition(panel->newsB, WIPImageOnly);
	path = LocateImage(NEWS_IMAGE);
	if (path) {
		icon = WMCreatePixmapFromFile(scr, path);
		if (icon) {
			WMSetButtonImage(panel->newsB, icon);
			WMReleasePixmap(icon);
		}
		wfree(path);
	}

	panel->nextB = WMCreateButton(panel->titlF, WBTOnOff);
	WMResizeWidget(panel->nextB, 60, 40);
	WMMoveWidget(panel->nextB, 136, 32);
	WMSetButtonImagePosition(panel->nextB, WIPImageOnly);
	path = LocateImage(NEXT_IMAGE);
	if (path) {
		icon = WMCreatePixmapFromFile(scr, path);
		if (icon) {
			WMSetButtonImage(panel->nextB, icon);
			WMReleasePixmap(icon);
		}
		wfree(path);
	}

	WMGroupButtons(panel->newsB, panel->oldsB);
	WMGroupButtons(panel->newsB, panel->nextB);

	WMMapSubwidgets(panel->titlF);

    /**************** Features ******************/
	panel->animF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->animF, 173, 100);
	WMMoveWidget(panel->animF, 237, 10);
	WMSetFrameTitle(panel->animF, _("Animations"));

	panel->animB = WMCreateButton(panel->animF, WBTToggle);
	WMResizeWidget(panel->animB, 64, 64);
	WMMoveWidget(panel->animB, 15, 23);
	WMSetButtonFont(panel->animB, font);
	WMSetButtonText(panel->animB, _("Animations"));
	WMSetButtonImagePosition(panel->animB, WIPAbove);
	CreateImages(scr, rc, xis, ANIM_IMAGE, &altIcon, &icon);
	if (icon) {
		WMSetButtonImage(panel->animB, icon);
		WMReleasePixmap(icon);
	}
	if (altIcon) {
		WMSetButtonAltImage(panel->animB, altIcon);
		WMReleasePixmap(altIcon);
	}
	WMSetBalloonTextForView(_("Disable/enable animations such as those shown\n"
				  "for window miniaturization, shading etc."), WMWidgetView(panel->animB));

	panel->supB = WMCreateButton(panel->animF, WBTToggle);
	WMResizeWidget(panel->supB, 64, 64);
	WMMoveWidget(panel->supB, 94, 23);
	WMSetButtonFont(panel->supB, font);
	WMSetButtonText(panel->supB, _("Superfluous"));
	WMSetButtonImagePosition(panel->supB, WIPAbove);
	CreateImages(scr, rc, xis, SUPERF_IMAGE, &altIcon, &icon);
	if (icon) {
		WMSetButtonImage(panel->supB, icon);
		WMReleasePixmap(icon);
	}
	if (altIcon) {
		WMSetButtonAltImage(panel->supB, altIcon);
		WMReleasePixmap(altIcon);
	}
	WMSetBalloonTextForView(_("Disable/enable `superfluous' features and\n"
				  "animations. These include the `ghosting' of the\n"
				  "dock when it's being moved to another side and\n"
				  "the explosion animation when undocking icons."), WMWidgetView(panel->supB));

	WMMapSubwidgets(panel->animF);

    /*********** Dithering **********/
	panel->cmapSize = 4;

	panel->dithF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->dithF, 277, 97);
	WMMoveWidget(panel->dithF, 237, 120);
	WMSetFrameTitle(panel->dithF, _("Dithering colormap for 8bpp"));

	WMSetBalloonTextForView(_("Number of colors to reserve for Window Maker\n"
				  "on displays that support only 8bpp (PseudoColor)."),
				WMWidgetView(panel->dithF));

	panel->dithB = WMCreateSwitchButton(panel->dithF);
	WMResizeWidget(panel->dithB, 235, 32);
	WMMoveWidget(panel->dithB, 15, 15);
	WMSetButtonText(panel->dithB, _("Disable dithering in any visual/depth"));

	panel->dithL = WMCreateLabel(panel->dithF);
	WMResizeWidget(panel->dithL, 75, 16);
	WMMoveWidget(panel->dithL, 98, 50);
	WMSetLabelTextAlignment(panel->dithL, WACenter);
	WMSetLabelText(panel->dithL, "64");

	panel->dithS = WMCreateSlider(panel->dithF);
	WMResizeWidget(panel->dithS, 95, 16);
	WMMoveWidget(panel->dithS, 90, 65);
	WMSetSliderMinValue(panel->dithS, 2);
	WMSetSliderMaxValue(panel->dithS, 6);
	WMSetSliderContinuous(panel->dithS, True);
	WMSetSliderAction(panel->dithS, updateLabel, panel);

	panel->dith1L = WMCreateLabel(panel->dithF);
	WMResizeWidget(panel->dith1L, 80, 35);
	WMMoveWidget(panel->dith1L, 5, 50);
	WMSetLabelTextAlignment(panel->dith1L, WACenter);
	WMSetLabelFont(panel->dith1L, font);
	WMSetLabelText(panel->dith1L, _("More colors for\napplications"));

	panel->dith2L = WMCreateLabel(panel->dithF);
	WMResizeWidget(panel->dith2L, 80, 35);
	WMMoveWidget(panel->dith2L, 190, 50);
	WMSetLabelTextAlignment(panel->dith2L, WACenter);
	WMSetLabelFont(panel->dith2L, font);
	WMSetLabelText(panel->dith2L, _("More colors for\nWindow Maker"));

	WMMapSubwidgets(panel->dithF);

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

	if (xis)
		RReleaseImage(xis);
	WMReleaseFont(font);
	showData(panel);
}
Esempio n. 5
0
static void
createPanel(Panel *p)
{
    _Panel *panel = (_Panel*)p;
    WMScreen *scr = WMWidgetScreen(panel->parent);
    WMPixmap *icon;
    int i;
    char *buf1, *buf2;
    char *path;

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

    /***************** Menu Scroll Speed ****************/
    panel->scrF = WMCreateFrame(panel->box);
    WMResizeWidget(panel->scrF, 235, 90);
    WMMoveWidget(panel->scrF, 25, 20);
    WMSetFrameTitle(panel->scrF, _("Menu Scrolling Speed"));


    buf1 = wmalloc(strlen(SPEED_IMAGE)+1);
    buf2 = wmalloc(strlen(SPEED_IMAGE_S)+1);
    for (i = 0; i < 5; i++) {
        panel->scrB[i] = WMCreateCustomButton(panel->scrF, WBBStateChangeMask);
        WMResizeWidget(panel->scrB[i], 40, 40);
        WMMoveWidget(panel->scrB[i], 15+(40*i), 30);
        WMSetButtonBordered(panel->scrB[i], False);
        WMSetButtonImagePosition(panel->scrB[i], WIPImageOnly);
        if (i > 0) {
            WMGroupButtons(panel->scrB[0], panel->scrB[i]);
        }
        sprintf(buf1, SPEED_IMAGE, i);
        sprintf(buf2, SPEED_IMAGE_S, i);
        path = LocateImage(buf1);
        if (path) {
            icon = WMCreatePixmapFromFile(scr, path);
            if (icon) {
                WMSetButtonImage(panel->scrB[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->scrB[i], icon);
                WMReleasePixmap(icon);
            } else {
                wwarning(_("could not load icon file %s"), path);
            }
            wfree(path);
        }
    }
    wfree(buf1);
    wfree(buf2);

    WMMapSubwidgets(panel->scrF);

    /***************** Submenu Alignment ****************/

    panel->aliF = WMCreateFrame(panel->box);
    WMResizeWidget(panel->aliF, 220, 90);
    WMMoveWidget(panel->aliF, 280, 20);
    WMSetFrameTitle(panel->aliF, _("Submenu Alignment"));

    panel->alinB = WMCreateButton(panel->aliF, WBTOnOff);
    WMResizeWidget(panel->alinB, 48, 48);
    WMMoveWidget(panel->alinB, 56, 25);
    WMSetButtonImagePosition(panel->alinB, WIPImageOnly);
    path = LocateImage(MENU_ALIGN1);
    if (path) {
        icon = WMCreatePixmapFromFile(scr, path);
        if (icon) {
            WMSetButtonImage(panel->alinB, icon);
            WMReleasePixmap(icon);
        } else {
            wwarning(_("could not load icon file %s"), path);
        }
        wfree(path);
    }
    panel->aliyB = WMCreateButton(panel->aliF, WBTOnOff);
    WMResizeWidget(panel->aliyB, 48, 48);
    WMMoveWidget(panel->aliyB, 120, 25);
    WMSetButtonImagePosition(panel->aliyB, WIPImageOnly);
    path = LocateImage(MENU_ALIGN2);
    if (path) {
        icon = WMCreatePixmapFromFile(scr, path);
        if (icon) {
            WMSetButtonImage(panel->aliyB, icon);
            WMReleasePixmap(icon);
        } else {
            wwarning(_("could not load icon file %s"), path);
        }
        wfree(path);
    }
    WMGroupButtons(panel->alinB, panel->aliyB);

    WMMapSubwidgets(panel->aliF);

    /***************** Options ****************/
    panel->optF = WMCreateFrame(panel->box);
    WMResizeWidget(panel->optF, 475, 80);
    WMMoveWidget(panel->optF, 25, 130);

    panel->wrapB = WMCreateSwitchButton(panel->optF);
    WMResizeWidget(panel->wrapB, 440, 32);
    WMMoveWidget(panel->wrapB, 25, 8);
    WMSetButtonText(panel->wrapB, _("Always open submenus inside the screen, instead of scrolling.\nNote: this is annoying."));

    panel->autoB = WMCreateSwitchButton(panel->optF);
    WMResizeWidget(panel->autoB, 440, 32);
    WMMoveWidget(panel->autoB, 25, 45);
    WMSetButtonText(panel->autoB, _("Scroll off-screen menus when pointer is moved over them."));

    WMMapSubwidgets(panel->optF);

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

    showData(panel);
}
Esempio n. 6
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);
}
Esempio n. 7
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;
}
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;
}