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); }
void testTextField(WMScreen * scr) { WMWindow *win; WMTextField *field, *field2; windowCount++; win = WMCreateWindow(scr, "testTextField"); WMResizeWidget(win, 400, 300); WMSetWindowCloseAction(win, closeAction, NULL); field = WMCreateTextField(win); WMResizeWidget(field, 200, 20); WMMoveWidget(field, 20, 20); WMSetTextFieldText(field, "the little \xc2\xa9 sign"); field2 = WMCreateTextField(win); WMResizeWidget(field2, 200, 20); WMMoveWidget(field2, 20, 50); WMSetTextFieldAlignment(field2, WARight); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
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); }
void testText(WMScreen * scr) { WMWindow *win; WMText *text; WMFont *font; void *tb; FILE *file = fopen("wm.html", "rb"); windowCount++; win = WMCreateWindow(scr, "testText"); WMResizeWidget(win, 500, 300); WMSetWindowCloseAction(win, closeAction, NULL); text = WMCreateText(win); WMResizeWidget(text, 480, 280); WMMoveWidget(text, 10, 10); WMSetTextHasVerticalScroller(text, True); WMSetTextEditable(text, False); WMSetTextIgnoresNewline(text, False); #define FNAME "Verdana,sans serif:pixelsize=12" #define MSG \ "Window Maker is the GNU window manager for the " \ "X Window System. It was designed to emulate the " \ "look and feel of part of the NEXTSTEP(tm) GUI. It's " \ "supposed to be relatively fast and small, feature " \ "rich, easy to configure and easy to use, with a simple " \ "and elegant appearance borrowed from NEXTSTEP(tm)." font = WMCreateFont(scr, FNAME ":autohint=false"); WMSetTextDefaultFont(text, font); WMReleaseFont(font); if (0 && file) { char buf[1024]; WMFreezeText(text); while (fgets(buf, 1023, file)) WMAppendTextStream(text, buf); fclose(file); WMThawText(text); } else { WMAppendTextStream(text, "First paragraph has autohinting turned off, " "while the second has it turned on:"); WMAppendTextStream(text, "\n\n\n"); WMAppendTextStream(text, MSG); WMAppendTextStream(text, "\n\n\n"); font = WMCreateFont(scr, FNAME ":autohint=true"); tb = WMCreateTextBlockWithText(text, MSG, font, WMBlackColor(scr), 0, strlen(MSG)); WMAppendTextBlock(text, tb); WMReleaseFont(font); } WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
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); }
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; }
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); }
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); }
void testProgressIndicator(WMScreen * scr) { WMWindow *win; WMProgressIndicator *pPtr; windowCount++; win = WMCreateWindow(scr, "testProgressIndicator"); WMResizeWidget(win, 292, 32); WMSetWindowCloseAction(win, closeAction, NULL); pPtr = WMCreateProgressIndicator(win); WMMoveWidget(pPtr, 8, 8); WMSetProgressIndicatorValue(pPtr, 75); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void testColorWell(WMScreen * scr) { WMWindow *win; WMColorWell *well1, *well2; windowCount++; win = WMCreateWindow(scr, "testColor"); WMResizeWidget(win, 300, 300); WMSetWindowCloseAction(win, closeAction, NULL); well1 = WMCreateColorWell(win); WMResizeWidget(well1, 60, 40); WMMoveWidget(well1, 100, 100); WMSetColorWellColor(well1, WMCreateRGBColor(scr, 0x8888, 0, 0x1111, True)); well2 = WMCreateColorWell(win); WMResizeWidget(well2, 60, 40); WMMoveWidget(well2, 200, 100); WMSetColorWellColor(well2, WMCreateRGBColor(scr, 0, 0, 0x8888, True)); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void testPullDown(WMScreen * scr) { WMWindow *win; WMPopUpButton *pop, *pop2; windowCount++; win = WMCreateWindow(scr, "pullDown"); WMResizeWidget(win, 400, 300); WMSetWindowCloseAction(win, closeAction, NULL); pop = WMCreatePopUpButton(win); WMResizeWidget(pop, 100, 20); WMMoveWidget(pop, 50, 60); WMSetPopUpButtonPullsDown(pop, True); WMSetPopUpButtonText(pop, "Commands"); WMAddPopUpButtonItem(pop, "Add"); WMAddPopUpButtonItem(pop, "Remove"); WMAddPopUpButtonItem(pop, "Check"); WMAddPopUpButtonItem(pop, "Eat"); pop2 = WMCreatePopUpButton(win); WMResizeWidget(pop2, 100, 20); WMMoveWidget(pop2, 200, 60); WMSetPopUpButtonText(pop2, "Select"); WMAddPopUpButtonItem(pop2, "Apples"); WMAddPopUpButtonItem(pop2, "Bananas"); WMAddPopUpButtonItem(pop2, "Strawberries"); WMAddPopUpButtonItem(pop2, "Blueberries"); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void testTabView(WMScreen * scr) { WMWindow *win; WMTabView *tabv; WMTabViewItem *tab; WMFrame *frame; WMLabel *label; windowCount++; win = WMCreateWindow(scr, "testTabs"); WMResizeWidget(win, 400, 300); WMSetWindowCloseAction(win, closeAction, NULL); tabv = WMCreateTabView(win); WMMoveWidget(tabv, 50, 50); WMResizeWidget(tabv, 300, 200); frame = WMCreateFrame(win); WMSetFrameRelief(frame, WRFlat); label = WMCreateLabel(frame); WMResizeWidget(label, 100, 100); WMSetLabelText(label, "Label 1"); WMMapWidget(label); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(frame)); WMAddItemInTabView(tabv, tab); WMSetTabViewItemLabel(tab, "Instances"); frame = WMCreateFrame(win); WMSetFrameRelief(frame, WRFlat); label = WMCreateLabel(frame); WMResizeWidget(label, 40, 50); WMSetLabelText(label, "Label 2"); WMMapWidget(label); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(frame)); WMAddItemInTabView(tabv, tab); WMSetTabViewItemLabel(tab, "Classes"); frame = WMCreateFrame(win); WMSetFrameRelief(frame, WRFlat); label = WMCreateLabel(frame); WMResizeWidget(label, 100, 100); WMMoveWidget(label, 60, 40); WMSetLabelText(label, "Label 3"); WMMapWidget(label); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(frame)); WMAddItemInTabView(tabv, tab); WMSetTabViewItemLabel(tab, "Something"); frame = WMCreateFrame(win); WMSetFrameRelief(frame, WRFlat); label = WMCreateLabel(frame); WMResizeWidget(label, 100, 100); WMMoveWidget(label, 160, 40); WMSetLabelText(label, "Label 4"); WMMapWidget(label); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(frame)); WMAddItemInTabView(tabv, tab); WMSetTabViewItemLabel(tab, "Bla!"); frame = WMCreateFrame(win); WMSetFrameRelief(frame, WRFlat); label = WMCreateLabel(frame); WMResizeWidget(label, 100, 100); WMMoveWidget(label, 160, 40); WMSetLabelText(label, "Label fjweqklrj qwl"); WMMapWidget(label); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(frame)); WMAddItemInTabView(tabv, tab); WMSetTabViewItemLabel(tab, "Weee!"); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypos, Bool showSelectPanel) { WScreen *scr = wwin->screen_ptr; InspectorPanel *panel; Window parent; char *str = NULL, *tmp = NULL; int x, y, btn_width, frame_width; WMButton *selectedBtn = NULL; spec_text = _("The configuration will apply to all\n" "windows that have their WM_CLASS\n" "property set to the above selected\n" "name, when saved."); panel = wmalloc(sizeof(InspectorPanel)); memset(panel, 0, sizeof(InspectorPanel)); panel->destroyed = 0; panel->inspected = wwin; panel->nextPtr = panelList; panelList = panel; panel->win = WMCreateWindow(scr->wmscreen, "windowInspector"); WMResizeWidget(panel->win, PWIDTH, PHEIGHT); /**** create common stuff ****/ /* command buttons */ btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3; panel->saveBtn = WMCreateCommandButton(panel->win); WMSetButtonAction(panel->saveBtn, saveSettings, panel); WMMoveWidget(panel->saveBtn, (2 * (btn_width + 10)) + 15, PHEIGHT - 40); WMSetButtonText(panel->saveBtn, _("Save")); WMResizeWidget(panel->saveBtn, btn_width, 28); if (wPreferences.flags.noupdates || !(wwin->wm_class || wwin->wm_instance)) WMSetButtonEnabled(panel->saveBtn, False); panel->applyBtn = WMCreateCommandButton(panel->win); WMSetButtonAction(panel->applyBtn, applySettings, panel); WMMoveWidget(panel->applyBtn, btn_width + 10 + 15, PHEIGHT - 40); WMSetButtonText(panel->applyBtn, _("Apply")); WMResizeWidget(panel->applyBtn, btn_width, 28); panel->revertBtn = WMCreateCommandButton(panel->win); WMSetButtonAction(panel->revertBtn, revertSettings, panel); WMMoveWidget(panel->revertBtn, 15, PHEIGHT - 40); WMSetButtonText(panel->revertBtn, _("Reload")); WMResizeWidget(panel->revertBtn, btn_width, 28); /* page selection popup button */ panel->pagePopUp = WMCreatePopUpButton(panel->win); WMSetPopUpButtonAction(panel->pagePopUp, changePage, panel); WMMoveWidget(panel->pagePopUp, 25, 15); WMResizeWidget(panel->pagePopUp, PWIDTH - 50, 20); WMAddPopUpButtonItem(panel->pagePopUp, _("Window Specification")); WMAddPopUpButtonItem(panel->pagePopUp, _("Window Attributes")); WMAddPopUpButtonItem(panel->pagePopUp, _("Advanced Options")); WMAddPopUpButtonItem(panel->pagePopUp, _("Icon and Initial Workspace")); WMAddPopUpButtonItem(panel->pagePopUp, _("Application Specific")); /**** window spec ****/ frame_width = PWIDTH - (2 * 15); panel->specFrm = WMCreateFrame(panel->win); WMSetFrameTitle(panel->specFrm, _("Window Specification")); WMMoveWidget(panel->specFrm, 15, 65); WMResizeWidget(panel->specFrm, frame_width, 145); panel->defaultRb = WMCreateRadioButton(panel->specFrm); WMMoveWidget(panel->defaultRb, 10, 78); WMResizeWidget(panel->defaultRb, frame_width - (2 * 10), 20); WMSetButtonText(panel->defaultRb, _("Defaults for all windows")); WMSetButtonSelected(panel->defaultRb, False); WMSetButtonAction(panel->defaultRb, selectSpecification, panel); if (wwin->wm_class && wwin->wm_instance) { tmp = wstrconcat(wwin->wm_instance, "."); str = wstrconcat(tmp, wwin->wm_class); panel->bothRb = WMCreateRadioButton(panel->specFrm); WMMoveWidget(panel->bothRb, 10, 18); WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20); WMSetButtonText(panel->bothRb, str); wfree(tmp); wfree(str); WMGroupButtons(panel->defaultRb, panel->bothRb); if (!selectedBtn) selectedBtn = panel->bothRb; WMSetButtonAction(panel->bothRb, selectSpecification, panel); } if (wwin->wm_instance) { panel->instRb = WMCreateRadioButton(panel->specFrm); WMMoveWidget(panel->instRb, 10, 38); WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20); WMSetButtonText(panel->instRb, wwin->wm_instance); WMGroupButtons(panel->defaultRb, panel->instRb); if (!selectedBtn) selectedBtn = panel->instRb; WMSetButtonAction(panel->instRb, selectSpecification, panel); } if (wwin->wm_class) { panel->clsRb = WMCreateRadioButton(panel->specFrm); WMMoveWidget(panel->clsRb, 10, 58); WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20); WMSetButtonText(panel->clsRb, wwin->wm_class); WMGroupButtons(panel->defaultRb, panel->clsRb); if (!selectedBtn) selectedBtn = panel->clsRb; WMSetButtonAction(panel->clsRb, selectSpecification, panel); } panel->selWinB = WMCreateCommandButton(panel->specFrm); WMMoveWidget(panel->selWinB, 20, 145 - 24 - 10); WMResizeWidget(panel->selWinB, frame_width - 2 * 10 - 20, 24); WMSetButtonText(panel->selWinB, _("Select window")); WMSetButtonAction(panel->selWinB, selectWindow, panel); panel->specLbl = WMCreateLabel(panel->win); WMMoveWidget(panel->specLbl, 15, 210); WMResizeWidget(panel->specLbl, frame_width, 100); WMSetLabelText(panel->specLbl, spec_text); WMSetLabelWraps(panel->specLbl, True); WMSetLabelTextAlignment(panel->specLbl, WALeft); /**** attributes ****/ create_tab_window_attributes(wwin, panel, frame_width); create_tab_window_advanced(wwin, panel, frame_width); create_tab_icon_workspace(wwin, panel); create_tab_app_specific(wwin, panel, frame_width); /* if the window is a transient, don't let it have a miniaturize button */ if (wwin->transient_for != None && wwin->transient_for != scr->root_win) WMSetButtonEnabled(panel->attrChk[3], False); else WMSetButtonEnabled(panel->attrChk[3], True); if (!wwin->wm_class && !wwin->wm_instance) WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False); WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); WMMapSubwidgets(panel->specFrm); WMMapSubwidgets(panel->attrFrm); WMMapSubwidgets(panel->moreFrm); WMMapSubwidgets(panel->iconFrm); WMMapSubwidgets(panel->wsFrm); if (panel->appFrm) WMMapSubwidgets(panel->appFrm); if (showSelectPanel) { WMSetPopUpButtonSelectedItem(panel->pagePopUp, 0); changePage(panel->pagePopUp, panel); } else { WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1); changePage(panel->pagePopUp, panel); } parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, 0, 0, 0); XSelectInput(dpy, parent, KeyPressMask | KeyReleaseMask); panel->parent = parent; XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); WMMapWidget(panel->win); XSetTransientForHint(dpy, parent, wwin->client_win); if (xpos == UNDEFINED_POS) { x = wwin->frame_x + wwin->frame->core->width / 2; y = wwin->frame_y + wwin->frame->top_width * 2; if (y + PHEIGHT > scr->scr_height) y = scr->scr_height - PHEIGHT - 30; if (x + PWIDTH > scr->scr_width) x = scr->scr_width - PWIDTH; } else { x = xpos; y = ypos; } panel->frame = wManageInternalWindow(scr, parent, wwin->client_win, "Inspector", x, y, PWIDTH, PHEIGHT); if (!selectedBtn) selectedBtn = panel->defaultRb; WMSetButtonSelected(selectedBtn, True); selectSpecification(selectedBtn, panel); /* kluge to know who should get the key events */ panel->frame->client_leader = WMWidgetXID(panel->win); WSETUFLAG(panel->frame, no_closable, 0); WSETUFLAG(panel->frame, no_close_button, 0); wWindowUpdateButtonImages(panel->frame); wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON); panel->frame->frame->on_click_right = destroyInspector; wWindowMap(panel->frame); showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance, wwin->wm_class, UPDATE_TEXT_FIELD); return panel; }
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; }
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); }
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); }
void testSplitView(WMScreen * scr) { WMWindow *win; WMSplitView *splitv1, *splitv2; WMFrame *frame; WMLabel *label; WMButton *button; windowCount++; win = WMCreateWindow(scr, "testTabs"); WMResizeWidget(win, 300, 400); WMSetWindowCloseAction(win, closeAction, NULL); frame = WMCreateFrame(win); WMSetFrameRelief(frame, WRSunken); WMMoveWidget(frame, 5, 5); WMResizeWidget(frame, 290, 40); splitv1 = WMCreateSplitView(win); WMMoveWidget(splitv1, 5, 50); WMResizeWidget(splitv1, 290, 345); WMSetSplitViewConstrainProc(splitv1, splitViewConstrainProc); WMCreateEventHandler(WMWidgetView(win), StructureNotifyMask, resizeSplitView, splitv1); button = WMCreateCommandButton(frame); WMSetButtonText(button, "+"); WMSetButtonAction(button, appendSubviewButtonAction, splitv1); WMMoveWidget(button, 10, 8); WMMapWidget(button); button = WMCreateCommandButton(frame); WMSetButtonText(button, "-"); WMSetButtonAction(button, removeSubviewButtonAction, splitv1); WMMoveWidget(button, 80, 8); WMMapWidget(button); button = WMCreateCommandButton(frame); WMSetButtonText(button, "="); WMMoveWidget(button, 150, 8); WMSetButtonAction(button, adjustSubviewsButtonAction, splitv1); WMMapWidget(button); button = WMCreateCommandButton(frame); WMSetButtonText(button, "#"); WMMoveWidget(button, 220, 8); WMSetButtonAction(button, orientationButtonAction, splitv1); WMMapWidget(button); label = WMCreateLabel(splitv1); WMSetLabelText(label, "Subview 1"); WMSetLabelRelief(label, WRSunken); WMMapWidget(label); WMAddSplitViewSubview(splitv1, WMWidgetView(label)); splitv2 = WMCreateSplitView(splitv1); WMResizeWidget(splitv2, 150, 150); WMSetSplitViewVertical(splitv2, True); label = WMCreateLabel(splitv2); WMSetLabelText(label, "Subview 2.1"); WMSetLabelRelief(label, WRSunken); WMMapWidget(label); WMAddSplitViewSubview(splitv2, WMWidgetView(label)); label = WMCreateLabel(splitv2); WMSetLabelText(label, "Subview 2.2"); WMSetLabelRelief(label, WRSunken); WMMapWidget(label); WMAddSplitViewSubview(splitv2, WMWidgetView(label)); label = WMCreateLabel(splitv2); WMSetLabelText(label, "Subview 2.3"); WMSetLabelRelief(label, WRSunken); WMMapWidget(label); WMAddSplitViewSubview(splitv2, WMWidgetView(label)); WMMapWidget(splitv2); WMAddSplitViewSubview(splitv1, WMWidgetView(splitv2)); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
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); }
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); }
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; }