コード例 #1
0
ファイル: wtest.c プロジェクト: awmaker/awmaker
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);

}
コード例 #2
0
ファイル: Focus.c プロジェクト: 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);
}
コード例 #3
0
ファイル: dockedapp.c プロジェクト: crmafra/wmaker
void ShowDockAppSettingsPanel(WAppIcon * aicon)
{
	AppSettingsPanel *panel;
	WScreen *scr = aicon->icon->core->screen_ptr;
	Window parent;
	WMFont *font;
	int x, y;
	WMBox *vbox;

	panel = wmalloc(sizeof(AppSettingsPanel));

	panel->editedIcon = aicon;

	aicon->panel = panel;
	aicon->editing = 1;

	panel->win = WMCreateWindow(scr->wmscreen, "applicationSettings");
	WMResizeWidget(panel->win, PWIDTH, PHEIGHT);

	panel->iconLabel = WMCreateLabel(panel->win);
	WMResizeWidget(panel->iconLabel, 64, 64);
	WMMoveWidget(panel->iconLabel, 10, 10);
	WMSetLabelImagePosition(panel->iconLabel, WIPImageOnly);

	panel->nameLabel = WMCreateLabel(panel->win);
	WMResizeWidget(panel->nameLabel, 190, 18);
	WMMoveWidget(panel->nameLabel, 80, 35);
	WMSetLabelTextAlignment(panel->nameLabel, WALeft);
	font = WMBoldSystemFontOfSize(scr->wmscreen, 14);
	WMSetLabelFont(panel->nameLabel, font);
	WMReleaseFont(font);
	if (aicon->wm_class && strcmp(aicon->wm_class, "DockApp") == 0)
		WMSetLabelText(panel->nameLabel, aicon->wm_instance);
	else
		WMSetLabelText(panel->nameLabel, aicon->wm_class);

	vbox = WMCreateBox(panel->win);
	WMResizeWidget(vbox, PWIDTH - 20, PHEIGHT - 84 - 10);
	WMMoveWidget(vbox, 10, 84);

	panel->autoLaunchBtn = WMCreateSwitchButton(vbox);
	WMAddBoxSubview(vbox, WMWidgetView(panel->autoLaunchBtn), False, True, 20, 20, 2);
	WMSetButtonText(panel->autoLaunchBtn, _("Start when Window Maker is started"));
	WMSetButtonSelected(panel->autoLaunchBtn, aicon->auto_launch);

	panel->lockBtn = WMCreateSwitchButton(vbox);
	WMAddBoxSubview(vbox, WMWidgetView(panel->lockBtn), False, True, 20, 20, 5);
	WMSetButtonText(panel->lockBtn, _("Lock (prevent accidental removal)"));
	WMSetButtonSelected(panel->lockBtn, aicon->lock);

	panel->commandFrame = WMCreateFrame(vbox);
	WMSetFrameTitle(panel->commandFrame, _("Application path and arguments"));
	WMAddBoxSubview(vbox, WMWidgetView(panel->commandFrame), False, True, 50, 50, 5);

	panel->commandField = WMCreateTextField(panel->commandFrame);
	WMResizeWidget(panel->commandField, 256, 20);
	WMMoveWidget(panel->commandField, 10, 20);
	WMSetTextFieldText(panel->commandField, aicon->command);

	WMMapSubwidgets(panel->commandFrame);

	panel->pasteCommandFrame = WMCreateFrame(vbox);
	WMSetFrameTitle(panel->pasteCommandFrame, _("Command for middle-click launch"));
	WMAddBoxSubview(vbox, WMWidgetView(panel->pasteCommandFrame), False, True, 70, 70, 5);

	panel->pasteCommandField = WMCreateTextField(panel->pasteCommandFrame);
	WMResizeWidget(panel->pasteCommandField, 256, 20);
	WMMoveWidget(panel->pasteCommandField, 10, 20);

	panel->pasteCommandLabel = WMCreateLabel(panel->pasteCommandFrame);
	WMResizeWidget(panel->pasteCommandLabel, 256, 18);
	WMMoveWidget(panel->pasteCommandLabel, 10, 45);

	WMSetTextFieldText(panel->pasteCommandField, aicon->paste_command);
	WMSetLabelText(panel->pasteCommandLabel, _("%s will be replaced with current selection"));
	WMMapSubwidgets(panel->pasteCommandFrame);

	panel->dndCommandFrame = WMCreateFrame(vbox);
	WMSetFrameTitle(panel->dndCommandFrame, _("Command for files dropped with DND"));
	WMAddBoxSubview(vbox, WMWidgetView(panel->dndCommandFrame), False, True, 70, 70, 5);

	panel->dndCommandField = WMCreateTextField(panel->dndCommandFrame);
	WMResizeWidget(panel->dndCommandField, 256, 20);
	WMMoveWidget(panel->dndCommandField, 10, 20);

	panel->dndCommandLabel = WMCreateLabel(panel->dndCommandFrame);
	WMResizeWidget(panel->dndCommandLabel, 256, 18);
	WMMoveWidget(panel->dndCommandLabel, 10, 45);
#ifdef XDND
	WMSetTextFieldText(panel->dndCommandField, aicon->dnd_command);
	WMSetLabelText(panel->dndCommandLabel, _("%d will be replaced with the file name"));
#else
	WMSetTextFieldEditable(panel->dndCommandField, False);
	WMSetLabelText(panel->dndCommandLabel, _("DND support was not compiled in"));
#endif
	WMMapSubwidgets(panel->dndCommandFrame);

	panel->iconFrame = WMCreateFrame(vbox);
	WMSetFrameTitle(panel->iconFrame, _("Icon Image"));
	WMAddBoxSubview(vbox, WMWidgetView(panel->iconFrame), False, True, 50, 50, 10);

	panel->iconField = WMCreateTextField(panel->iconFrame);
	WMResizeWidget(panel->iconField, 176, 20);
	WMMoveWidget(panel->iconField, 10, 20);
	WMSetTextFieldText(panel->iconField, wDefaultGetIconFile(aicon->wm_instance, aicon->wm_class, False));

	panel->browseBtn = WMCreateCommandButton(panel->iconFrame);
	WMResizeWidget(panel->browseBtn, 70, 24);
	WMMoveWidget(panel->browseBtn, 195, 18);
	WMSetButtonText(panel->browseBtn, _("Browse..."));
	WMSetButtonAction(panel->browseBtn, chooseIconCallback, panel);

	{
		WMBox *hbox;

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

		panel->okBtn = WMCreateCommandButton(hbox);
		WMSetButtonText(panel->okBtn, _("OK"));
		WMSetButtonAction(panel->okBtn, panelBtnCallback, panel);
		WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->okBtn), False, True, 80, 80, 0);

		panel->cancelBtn = WMCreateCommandButton(hbox);
		WMSetButtonText(panel->cancelBtn, _("Cancel"));
		WMSetButtonAction(panel->cancelBtn, panelBtnCallback, panel);
		WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->cancelBtn), False, True, 80, 80, 5);

		WMMapSubwidgets(hbox);
	}

	WMRealizeWidget(panel->win);
	WMMapSubwidgets(panel->win);
	WMMapSubwidgets(vbox);
	WMMapSubwidgets(panel->iconFrame);

	updateSettingsPanelIcon(panel);

	parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, 0, 0, 0);
	XSelectInput(dpy, parent, KeyPressMask | KeyReleaseMask);

	XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);

	/*
	 * make things relative to head
	 */
	{
		WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr));

		y = aicon->y_pos;
		if (y < 0)
			y = 0;
		else if (y + PHEIGHT > rect.pos.y + rect.size.height)
			y = rect.pos.y + rect.size.height - PHEIGHT - 30;

		if (aicon->dock && aicon->dock->type == WM_DOCK) {
			if (aicon->dock->on_right_side)
				x = rect.pos.x + rect.size.width / 2;
			else
				x = rect.pos.x + rect.size.width / 2 - PWIDTH - 2;
		} else {
			x = rect.pos.x + (rect.size.width - PWIDTH) / 2;
		}
	}

	panel->wwin = wManageInternalWindow(scr, parent, None,
					    _("Docked Application Settings"), x, y, PWIDTH, PHEIGHT);

	panel->wwin->client_leader = WMWidgetXID(panel->win);

	panel->parent = parent;

	WMMapWidget(panel->win);

	wWindowMap(panel->wwin);
}