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); }
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; }
WMRuler *WMCreateRuler(WMWidget * parent) { Ruler *rPtr = wmalloc(sizeof(Ruler)); unsigned int w = WMWidgetWidth(parent); rPtr->widgetClass = WC_Ruler; rPtr->view = W_CreateView(W_VIEW(parent)); if (!rPtr->view) { wfree(rPtr); return NULL; } rPtr->view->self = rPtr; rPtr->drawBuffer = (Pixmap) NULL; W_ResizeView(rPtr->view, w, 40); WMCreateEventHandler(rPtr->view, ExposureMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask | ButtonReleaseMask | ButtonPressMask | KeyReleaseMask | KeyPressMask | Button1MotionMask, handleEvents, rPtr); rPtr->view->delegate = &_RulerViewDelegate; rPtr->fg = WMBlackColor(rPtr->view->screen); rPtr->fgGC = WMColorGC(rPtr->fg); rPtr->bgGC = WMColorGC(WMGrayColor(rPtr->view->screen)); rPtr->font = WMSystemFontOfSize(rPtr->view->screen, 8); rPtr->offset = 22; rPtr->margins.left = 22; rPtr->margins.body = 22; rPtr->margins.first = 42; rPtr->margins.right = (w < 502 ? w : 502); rPtr->margins.tabs = NULL; rPtr->flags.whichMarker = 0; /* none */ rPtr->flags.buttonPressed = False; rPtr->flags.redraw = True; rPtr->moveAction = NULL; rPtr->releaseAction = NULL; rPtr->pview = W_VIEW(parent); return rPtr; }
static void createPanel(_Panel * p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); WMColor *black = WMBlackColor(scr); WMColor *white = WMWhiteColor(scr); WMColor *gray = WMGrayColor(scr); WMFont *bold = WMBoldSystemFontOfSize(scr, 12); WMFont *font = WMSystemFontOfSize(scr, 12); WMLabel *label; int width; menuDelegate.data = panel; panel->boldFont = bold; panel->normalFont = font; panel->black = black; panel->white = white; panel->gray = gray; { Pixmap pix; Display *dpy = WMScreenDisplay(scr); GC gc; WMPixmap *pixm; pixm = WMCreatePixmap(scr, 7, 7, WMScreenDepth(scr), True); pix = WMGetPixmapXID(pixm); XDrawLine(dpy, pix, WMColorGC(black), 0, 3, 6, 3); XDrawLine(dpy, pix, WMColorGC(black), 3, 0, 3, 6); /* XDrawLine(dpy, pix, WMColorGC(black), 1, 0, 3, 3); XDrawLine(dpy, pix, WMColorGC(black), 1, 6, 3, 3); XDrawLine(dpy, pix, WMColorGC(black), 0, 0, 0, 6); */ pix = WMGetPixmapMaskXID(pixm); gc = XCreateGC(dpy, pix, 0, NULL); XSetForeground(dpy, gc, 0); XFillRectangle(dpy, pix, gc, 0, 0, 7, 7); XSetForeground(dpy, gc, 1); XDrawLine(dpy, pix, gc, 0, 3, 6, 3); XDrawLine(dpy, pix, gc, 3, 0, 3, 6); panel->markerPix[ExternalInfo] = pixm; panel->markerPix[PipeInfo] = pixm; panel->markerPix[PLPipeInfo] = pixm; panel->markerPix[DirectoryInfo] = pixm; panel->markerPix[WSMenuInfo] = pixm; panel->markerPix[WWindowListInfo] = pixm; XFreeGC(dpy, gc); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); panel->typeP = WMCreatePopUpButton(panel->box); WMResizeWidget(panel->typeP, 150, 20); WMMoveWidget(panel->typeP, 10, 10); WMAddPopUpButtonItem(panel->typeP, _("New Items")); WMAddPopUpButtonItem(panel->typeP, _("Sample Commands")); WMAddPopUpButtonItem(panel->typeP, _("Sample Submenus")); WMSetPopUpButtonAction(panel->typeP, changedItemPad, panel); WMSetPopUpButtonSelectedItem(panel->typeP, 0); { WEditMenu *pad; pad = makeFactoryMenu(panel->box, 150); WMMoveWidget(pad, 10, 40); putNewItem(panel, pad, ExecInfo, _("Run Program")); putNewItem(panel, pad, CommandInfo, _("Internal Command")); putNewSubmenu(pad, _("Submenu")); putNewItem(panel, pad, ExternalInfo, _("External Submenu")); putNewItem(panel, pad, PipeInfo, _("Generated Submenu")); putNewItem(panel, pad, PLPipeInfo, _("Generated PL Menu")); putNewItem(panel, pad, DirectoryInfo, _("Directory Contents")); putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu")); putNewItem(panel, pad, WWindowListInfo, _("Window List Menu")); panel->itemPad[0] = pad; } { WEditMenu *pad; ItemData *data; WMScrollView *sview; sview = WMCreateScrollView(panel->box); WMResizeWidget(sview, 150, 180); WMMoveWidget(sview, 10, 40); WMSetScrollViewHasVerticalScroller(sview, True); pad = makeFactoryMenu(panel->box, 130); WMSetScrollViewContentView(sview, WMWidgetView(pad)); data = putNewItem(panel, pad, ExecInfo, _("XTerm")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; data = putNewItem(panel, pad, ExecInfo, _("rxvt")); data->param.exec.command = "rxvt"; data = putNewItem(panel, pad, ExecInfo, _("ETerm")); data->param.exec.command = "eterm"; data = putNewItem(panel, pad, ExecInfo, _("Run...")); data->param.exec.command = _("%A(Run,Type command to run)"); data = putNewItem(panel, pad, ExecInfo, _("Firefox")); data->param.exec.command = "firefox"; data = putNewItem(panel, pad, ExecInfo, _("gimp")); data->param.exec.command = "gimp"; data = putNewItem(panel, pad, ExecInfo, _("epic")); data->param.exec.command = "xterm -e epic"; data = putNewItem(panel, pad, ExecInfo, _("ee")); data->param.exec.command = "ee"; data = putNewItem(panel, pad, ExecInfo, _("xv")); data->param.exec.command = "xv"; data = putNewItem(panel, pad, ExecInfo, _("Evince")); data->param.exec.command = "evince"; data = putNewItem(panel, pad, ExecInfo, _("ghostview")); data->param.exec.command = "gv"; data = putNewItem(panel, pad, CommandInfo, _("Exit Window Maker")); data->param.command.command = 3; WMMapWidget(pad); panel->itemPad[1] = sview; } { WEditMenu *pad, *smenu; ItemData *data; WMScrollView *sview; sview = WMCreateScrollView(panel->box); WMResizeWidget(sview, 150, 180); WMMoveWidget(sview, 10, 40); WMSetScrollViewHasVerticalScroller(sview, True); pad = makeFactoryMenu(panel->box, 130); WMSetScrollViewContentView(sview, WMWidgetView(pad)); data = putNewItem(panel, pad, ExternalInfo, _("Debian Menu")); data->param.pipe.command = "/etc/GNUstep/Defaults/menu.hook"; data = putNewItem(panel, pad, PipeInfo, _("RedHat Menu")); data->param.pipe.command = "wmconfig --output wmaker"; data = putNewItem(panel, pad, PipeInfo, _("Menu Conectiva")); data->param.pipe.command = "wmconfig --output wmaker"; data = putNewItem(panel, pad, DirectoryInfo, _("Themes")); data->param.directory.command = "setstyle"; data->param.directory.directory = "/usr/share/WindowMaker/Themes /usr/local/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes"; data->param.directory.stripExt = 1; data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (scale)")); data->param.directory.command = "wmsetbg -u -s"; data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; data->param.directory.stripExt = 1; data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (tile)")); data->param.directory.command = "wmsetbg -u -t"; data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; data->param.directory.stripExt = 1; smenu = putNewSubmenu(pad, _("Assorted XTerms")); data = putNewItem(panel, smenu, ExecInfo, _("XTerm Yellow on Blue")); data->param.exec.command = "xterm -sb -sl 2000 -bg midnightblue -fg yellow"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Black")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on White")); data->param.exec.command = "xterm -sb -sl 2000 -bg white -fg black"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on Beige")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#bbbb99' -fg black"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Green")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#228822' -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Olive")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#335533' -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Blue on Blue")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#112244' -fg '#88aabb'"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm BIG FONTS")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white -fn 10x20"; WMMapWidget(pad); panel->itemPad[2] = sview; } width = FRAME_WIDTH - 20 - 150 - 10 - 2; panel->optionsF = WMCreateFrame(panel->box); WMResizeWidget(panel->optionsF, width, FRAME_HEIGHT - 15); WMMoveWidget(panel->optionsF, 10 + 150 + 10, 5); width -= 20; /* command */ panel->commandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->commandF, width, 50); WMMoveWidget(panel->commandF, 10, 20); WMSetFrameTitle(panel->commandF, _("Program to Run")); WMSetFrameTitlePosition(panel->commandF, WTPAtTop); panel->commandT = WMCreateTextField(panel->commandF); WMResizeWidget(panel->commandT, width - 95, 20); WMMoveWidget(panel->commandT, 10, 20); panel->browseB = WMCreateCommandButton(panel->commandF); WMResizeWidget(panel->browseB, 70, 24); WMMoveWidget(panel->browseB, width - 80, 18); WMSetButtonText(panel->browseB, _("Browse")); WMSetButtonAction(panel->browseB, browseForFile, panel); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->commandT); #if 0 panel->xtermC = WMCreateSwitchButton(panel->commandF); WMResizeWidget(panel->xtermC, width - 20, 20); WMMoveWidget(panel->xtermC, 10, 50); WMSetButtonText(panel->xtermC, _("Run the program inside a Xterm")); #endif WMMapSubwidgets(panel->commandF); /* path */ panel->pathF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->pathF, width, 150); WMMoveWidget(panel->pathF, 10, 40); WMSetFrameTitle(panel->pathF, _("Path for Menu")); panel->pathT = WMCreateTextField(panel->pathF); WMResizeWidget(panel->pathT, width - 20, 20); WMMoveWidget(panel->pathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pathT); label = WMCreateLabel(panel->pathF); WMResizeWidget(label, width - 20, 80); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter the path for a file containing a menu\n" "or a list of directories with the programs you\n" "want to have listed in the menu. Ex:\n" "~/GNUstep/Library/WindowMaker/menu\n" "or\n" "/usr/bin ~/xbin")); WMMapSubwidgets(panel->pathF); /* pipe */ panel->pipeF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->pipeF, width, 155); WMMoveWidget(panel->pipeF, 10, 30); WMSetFrameTitle(panel->pipeF, _("Command")); panel->pipeT = WMCreateTextField(panel->pipeF); WMResizeWidget(panel->pipeT, width - 20, 20); WMMoveWidget(panel->pipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pipeT); label = WMCreateLabel(panel->pipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a menu\n" "definition to stdout when invoked.")); panel->pipeCacheB = WMCreateSwitchButton(panel->pipeF); WMResizeWidget(panel->pipeCacheB, width - 20, 40); WMMoveWidget(panel->pipeCacheB, 10, 110); WMSetButtonText(panel->pipeCacheB, _("Cache menu contents after opening for\n" "the first time")); WMMapSubwidgets(panel->pipeF); /* proplist pipe */ panel->plpipeF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->plpipeF, width, 155); WMMoveWidget(panel->plpipeF, 10, 30); WMSetFrameTitle(panel->plpipeF, _("Command")); panel->plpipeT = WMCreateTextField(panel->plpipeF); WMResizeWidget(panel->plpipeT, width - 20, 20); WMMoveWidget(panel->plpipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->plpipeT); label = WMCreateLabel(panel->plpipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a proplist menu\n" "definition to stdout when invoked.")); panel->plpipeCacheB = WMCreateSwitchButton(panel->plpipeF); WMResizeWidget(panel->plpipeCacheB, width - 20, 40); WMMoveWidget(panel->plpipeCacheB, 10, 110); WMSetButtonText(panel->plpipeCacheB, _("Cache menu contents after opening for\n" "the first time")); WMMapSubwidgets(panel->plpipeF); /* directory menu */ panel->dcommandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->dcommandF, width, 90); WMMoveWidget(panel->dcommandF, 10, 25); WMSetFrameTitle(panel->dcommandF, _("Command to Open Files")); panel->dcommandT = WMCreateTextField(panel->dcommandF); WMResizeWidget(panel->dcommandT, width - 20, 20); WMMoveWidget(panel->dcommandT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dcommandT); label = WMCreateLabel(panel->dcommandF); WMResizeWidget(label, width - 20, 45); WMMoveWidget(label, 10, 40); WMSetLabelText(label, _("Enter the command you want to use to open the\n" "files in the directories listed below.")); WMMapSubwidgets(panel->dcommandF); panel->dpathF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->dpathF, width, 80); WMMoveWidget(panel->dpathF, 10, 125); WMSetFrameTitle(panel->dpathF, _("Directories with Files")); panel->dpathT = WMCreateTextField(panel->dpathF); WMResizeWidget(panel->dpathT, width - 20, 20); WMMoveWidget(panel->dpathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dpathT); panel->dstripB = WMCreateSwitchButton(panel->dpathF); WMResizeWidget(panel->dstripB, width - 20, 20); WMMoveWidget(panel->dstripB, 10, 50); WMSetButtonText(panel->dstripB, _("Strip extensions from file names")); WMSetButtonAction(panel->dstripB, buttonClicked, panel); WMMapSubwidgets(panel->dpathF); /* shortcut */ panel->shortF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->shortF, width, 50); WMMoveWidget(panel->shortF, 10, 160); WMSetFrameTitle(panel->shortF, _("Keyboard Shortcut")); panel->shortT = WMCreateTextField(panel->shortF); WMResizeWidget(panel->shortT, width - 20 - 150, 20); WMMoveWidget(panel->shortT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->shortT); panel->sgrabB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sgrabB, 70, 24); WMMoveWidget(panel->sgrabB, width - 80, 18); WMSetButtonText(panel->sgrabB, _("Capture")); WMSetButtonAction(panel->sgrabB, sgrabClicked, panel); panel->sclearB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sclearB, 70, 24); WMMoveWidget(panel->sclearB, width - 155, 18); WMSetButtonText(panel->sclearB, _("Clear")); WMSetButtonAction(panel->sclearB, sgrabClicked, panel); WMMapSubwidgets(panel->shortF); /* internal command */ panel->icommandL = WMCreateList(panel->optionsF); WMResizeWidget(panel->icommandL, width, 80); WMMoveWidget(panel->icommandL, 10, 20); WMSetListAction(panel->icommandL, icommandLClicked, panel); WMAddNotificationObserver(dataChanged, panel, WMListSelectionDidChangeNotification, panel->icommandL); WMInsertListItem(panel->icommandL, 0, _("Arrange Icons")); WMInsertListItem(panel->icommandL, 1, _("Hide All Windows Except For The Focused One")); WMInsertListItem(panel->icommandL, 2, _("Show All Windows")); WMInsertListItem(panel->icommandL, 3, _("Exit Window Maker")); WMInsertListItem(panel->icommandL, 4, _("Exit X Session")); WMInsertListItem(panel->icommandL, 5, _("Restart Window Maker")); WMInsertListItem(panel->icommandL, 6, _("Start Another Window Manager : (")); WMInsertListItem(panel->icommandL, 7, _("Save Current Session")); WMInsertListItem(panel->icommandL, 8, _("Clear Saved Session")); WMInsertListItem(panel->icommandL, 9, _("Refresh Screen")); WMInsertListItem(panel->icommandL, 10, _("Open Info Panel")); WMInsertListItem(panel->icommandL, 11, _("Open Copyright Panel")); panel->paramF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->paramF, width, 50); WMMoveWidget(panel->paramF, 10, 105); WMSetFrameTitle(panel->paramF, _("Window Manager to Start")); panel->paramT = WMCreateTextField(panel->paramF); WMResizeWidget(panel->paramT, width - 20, 20); WMMoveWidget(panel->paramT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->paramT); WMMapSubwidgets(panel->paramF); panel->quickB = WMCreateSwitchButton(panel->optionsF); WMResizeWidget(panel->quickB, width, 20); WMMoveWidget(panel->quickB, 10, 120); WMSetButtonText(panel->quickB, _("Do not confirm action.")); WMSetButtonAction(panel->quickB, buttonClicked, panel); label = WMCreateLabel(panel->optionsF); WMResizeWidget(label, width + 5, FRAME_HEIGHT - 50); WMMoveWidget(label, 7, 20); WMSetLabelText(label, _("Instructions:\n\n" " - drag items from the left to the menu to add new items\n" " - drag items out of the menu to remove items\n" " - drag items in menu to change their position\n" " - drag items with Control pressed to copy them\n" " - double click in a menu item to change the label\n" " - click on a menu item to change related information")); WMMapWidget(label); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); WMMapWidget(panel->box); { int i; for (i = 0; i < wlengthof(panel->itemPad); i++) WMUnmapWidget(panel->itemPad[i]); } changedItemPad(panel->typeP, panel); panel->sections[NoInfo][0] = label; panel->sections[ExecInfo][0] = panel->commandF; panel->sections[ExecInfo][1] = panel->shortF; panel->sections[CommandInfo][0] = panel->icommandL; panel->sections[CommandInfo][1] = panel->shortF; panel->sections[ExternalInfo][0] = panel->pathF; panel->sections[PipeInfo][0] = panel->pipeF; panel->sections[PLPipeInfo][0] = panel->plpipeF; panel->sections[DirectoryInfo][0] = panel->dpathF; panel->sections[DirectoryInfo][1] = panel->dcommandF; panel->currentType = NoInfo; showData(panel); { WMPoint pos; pos = WMGetViewScreenPosition(WMWidgetView(panel->box)); if (pos.x < 200) { pos.x += FRAME_WIDTH + 20; } else { pos.x = 10; } pos.y = WMAX(pos.y - 100, 0); if (panel->menu) WEditMenuShowAt(panel->menu, pos.x, pos.y); } }
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); }
static void createPanel(Panel *p) { _Panel *panel = (_Panel*)p; WMScreen *scr = WMWidgetScreen(panel->parent); WMTabViewItem *tab; panel->white = WMWhiteColor(scr); panel->black = WMBlackColor(scr); panel->gray = WMGrayColor(scr); panel->red = WMCreateRGBColor(scr, 0xffff, 0, 0, True); panel->font = WMSystemFontOfSize(scr, 12); panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); panel->tabv = WMCreateTabView(panel->box); WMMoveWidget(panel->tabv, 12, 10); WMResizeWidget(panel->tabv, 500, 215); /* icon path */ panel->icoF = WMCreateFrame(panel->box); WMSetFrameRelief(panel->icoF, WRFlat); WMResizeWidget(panel->icoF, 230, 210); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(panel->icoF)); WMAddItemInTabView(panel->tabv, tab); WMSetTabViewItemLabel(tab, _("Icon Search Paths")); panel->icoL = WMCreateList(panel->icoF); WMResizeWidget(panel->icoL, 480, 147); WMMoveWidget(panel->icoL, 10, 10); WMSetListUserDrawProc(panel->icoL, paintItem); WMHangData(panel->icoL, panel); panel->icoaB = WMCreateCommandButton(panel->icoF); WMResizeWidget(panel->icoaB, 95, 24); WMMoveWidget(panel->icoaB, 293, 165); WMSetButtonText(panel->icoaB, _("Add")); WMSetButtonAction(panel->icoaB, browseForFile, panel); WMSetButtonImagePosition(panel->icoaB, WIPRight); panel->icorB = WMCreateCommandButton(panel->icoF); WMResizeWidget(panel->icorB, 95, 24); WMMoveWidget(panel->icorB, 395, 165); WMSetButtonText(panel->icorB, _("Remove")); WMSetButtonAction(panel->icorB, pushButton, panel); WMMapSubwidgets(panel->icoF); /* pixmap path */ panel->pixF = WMCreateFrame(panel->box); WMSetFrameRelief(panel->pixF, WRFlat); WMResizeWidget(panel->pixF, 230, 210); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(panel->pixF)); WMAddItemInTabView(panel->tabv, tab); WMSetTabViewItemLabel(tab, _("Pixmap Search Paths")); panel->pixL = WMCreateList(panel->pixF); WMResizeWidget(panel->pixL, 480, 147); WMMoveWidget(panel->pixL, 10, 10); WMSetListUserDrawProc(panel->pixL, paintItem); WMHangData(panel->pixL, panel); panel->pixaB = WMCreateCommandButton(panel->pixF); WMResizeWidget(panel->pixaB, 95, 24); WMMoveWidget(panel->pixaB, 293, 165); WMSetButtonText(panel->pixaB, _("Add")); WMSetButtonAction(panel->pixaB, browseForFile, panel); WMSetButtonImagePosition(panel->pixaB, WIPRight); panel->pixrB = WMCreateCommandButton(panel->pixF); WMResizeWidget(panel->pixrB, 95, 24); WMMoveWidget(panel->pixrB, 395, 165); WMSetButtonText(panel->pixrB, _("Remove")); WMSetButtonAction(panel->pixrB, pushButton, panel); WMMapSubwidgets(panel->pixF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }
WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * context) { W_Screen *scrPtr; XGCValues gcv; Pixmap stipple; static int initialized = 0; static char *atomNames[] = { "_GNUSTEP_WM_ATTR", "WM_DELETE_WINDOW", "WM_PROTOCOLS", "CLIPBOARD", "XdndAware", "XdndSelection", "XdndEnter", "XdndLeave", "XdndPosition", "XdndDrop", "XdndFinished", "XdndTypeList", "XdndActionList", "XdndActionDescription", "XdndStatus", "XdndActionCopy", "XdndActionMove", "XdndActionLink", "XdndActionAsk", "XdndActionPrivate", "_WINGS_DND_MOUSE_OFFSET", "WM_STATE", "UTF8_STRING", "_NET_WM_NAME", "_NET_WM_ICON_NAME", "_NET_WM_ICON", }; Atom atoms[wlengthof(atomNames)]; int i; if (!initialized) { initialized = 1; W_ReadConfigurations(); assert(W_ApplicationInitialized()); } scrPtr = malloc(sizeof(W_Screen)); if (!scrPtr) return NULL; memset(scrPtr, 0, sizeof(W_Screen)); scrPtr->aflags.hasAppIcon = 1; scrPtr->display = display; scrPtr->screen = screen; scrPtr->rcontext = context; scrPtr->depth = context->depth; scrPtr->visual = context->visual; scrPtr->lastEventTime = 0; scrPtr->colormap = context->cmap; scrPtr->rootWin = RootWindow(display, screen); scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks); scrPtr->xftdraw = XftDrawCreate(scrPtr->display, W_DRAWABLE(scrPtr), scrPtr->visual, scrPtr->colormap); /* Create missing CUT_BUFFERs */ { Atom *rootWinProps; int exists[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; int count; rootWinProps = XListProperties(display, scrPtr->rootWin, &count); for (i = 0; i < count; i++) { switch (rootWinProps[i]) { case XA_CUT_BUFFER0: exists[0] = 1; break; case XA_CUT_BUFFER1: exists[1] = 1; break; case XA_CUT_BUFFER2: exists[2] = 1; break; case XA_CUT_BUFFER3: exists[3] = 1; break; case XA_CUT_BUFFER4: exists[4] = 1; break; case XA_CUT_BUFFER5: exists[5] = 1; break; case XA_CUT_BUFFER6: exists[6] = 1; break; case XA_CUT_BUFFER7: exists[7] = 1; break; default: break; } } if (rootWinProps) { XFree(rootWinProps); } for (i = 0; i < 8; i++) { if (!exists[i]) { XStoreBuffer(display, "", 0, i); } } } scrPtr->ignoredModifierMask = 0; { int i; XModifierKeymap *modmap; KeyCode nlock, slock; static int mask_table[8] = { ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask }; unsigned int numLockMask = 0, scrollLockMask = 0; nlock = XKeysymToKeycode(display, XK_Num_Lock); slock = XKeysymToKeycode(display, XK_Scroll_Lock); /* * Find out the masks for the NumLock and ScrollLock modifiers, * so that we can bind the grabs for when they are enabled too. */ modmap = XGetModifierMapping(display); if (modmap != NULL && modmap->max_keypermod > 0) { for (i = 0; i < 8 * modmap->max_keypermod; i++) { if (modmap->modifiermap[i] == nlock && nlock != 0) numLockMask = mask_table[i / modmap->max_keypermod]; else if (modmap->modifiermap[i] == slock && slock != 0) scrollLockMask = mask_table[i / modmap->max_keypermod]; } } if (modmap) XFreeModifiermap(modmap); scrPtr->ignoredModifierMask = numLockMask | scrollLockMask | LockMask; } /* initially allocate some colors */ WMWhiteColor(scrPtr); WMBlackColor(scrPtr); WMGrayColor(scrPtr); WMDarkGrayColor(scrPtr); gcv.graphics_exposures = False; gcv.function = GXxor; gcv.foreground = W_PIXEL(scrPtr->white); if (gcv.foreground == 0) gcv.foreground = 1; scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures | GCForeground, &gcv); gcv.function = GXxor; gcv.foreground = W_PIXEL(scrPtr->gray); gcv.subwindow_mode = IncludeInferiors; scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures | GCForeground | GCSubwindowMode, &gcv); gcv.function = GXcopy; scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures, &gcv); scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures, &gcv); stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr), STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT); gcv.foreground = W_PIXEL(scrPtr->darkGray); gcv.background = W_PIXEL(scrPtr->gray); gcv.fill_style = FillStippled; gcv.stipple = stipple; scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCForeground | GCBackground | GCStipple | GCFillStyle | GCGraphicsExposures, &gcv); scrPtr->drawStringGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCGraphicsExposures, &gcv); scrPtr->drawImStringGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCGraphicsExposures, &gcv); /* we need a 1bpp drawable for the monoGC, so borrow this one */ scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL); scrPtr->stipple = stipple; scrPtr->antialiasedText = WINGsConfiguration.antialiasedText; scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 0); scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 0); if (!scrPtr->boldFont) scrPtr->boldFont = scrPtr->normalFont; if (!scrPtr->normalFont) { wwarning(_("could not load any fonts. Make sure your font installation" " and locale settings are correct.")); return NULL; } /* create input method stuff */ W_InitIM(scrPtr); scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON, CHECK_BUTTON_ON_WIDTH, CHECK_BUTTON_ON_HEIGHT, False); scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF, CHECK_BUTTON_OFF_WIDTH, CHECK_BUTTON_OFF_HEIGHT, False); scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON, RADIO_BUTTON_ON_WIDTH, RADIO_BUTTON_ON_HEIGHT, False); scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF, RADIO_BUTTON_OFF_WIDTH, RADIO_BUTTON_OFF_HEIGHT, False); scrPtr->tristateButtonImageOn = makePixmap(scrPtr, TRISTATE_BUTTON_ON, TRISTATE_BUTTON_ON_WIDTH, TRISTATE_BUTTON_ON_HEIGHT, False); scrPtr->tristateButtonImageOff = makePixmap(scrPtr, TRISTATE_BUTTON_OFF, TRISTATE_BUTTON_OFF_WIDTH, TRISTATE_BUTTON_OFF_HEIGHT, False); scrPtr->tristateButtonImageTri = makePixmap(scrPtr, TRISTATE_BUTTON_TRI, TRISTATE_BUTTON_TRI_WIDTH, TRISTATE_BUTTON_TRI_HEIGHT, False); scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW, BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT, False); scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2, BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT, False); scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, False); scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP, SCROLLER_ARROW_UP_WIDTH, SCROLLER_ARROW_UP_HEIGHT, True); scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN, SCROLLER_ARROW_DOWN_WIDTH, SCROLLER_ARROW_DOWN_HEIGHT, True); scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT, SCROLLER_ARROW_LEFT_WIDTH, SCROLLER_ARROW_LEFT_HEIGHT, True); scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT, SCROLLER_ARROW_RIGHT_WIDTH, SCROLLER_ARROW_RIGHT_HEIGHT, True); scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP, SCROLLER_ARROW_UP_WIDTH, SCROLLER_ARROW_UP_HEIGHT, True); scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN, SCROLLER_ARROW_DOWN_WIDTH, SCROLLER_ARROW_DOWN_HEIGHT, True); scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT, SCROLLER_ARROW_LEFT_WIDTH, SCROLLER_ARROW_LEFT_HEIGHT, True); scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT, SCROLLER_ARROW_RIGHT_WIDTH, SCROLLER_ARROW_RIGHT_HEIGHT, True); scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR, POPUP_INDICATOR_WIDTH, POPUP_INDICATOR_HEIGHT, True); scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR, PULLDOWN_INDICATOR_WIDTH, PULLDOWN_INDICATOR_HEIGHT, True); scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK, CHECK_MARK_WIDTH, CHECK_MARK_HEIGHT, True); loadPixmaps(scrPtr); scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr); scrPtr->textCursor = XCreateFontCursor(display, XC_xterm); { XColor bla; Pixmap blank; blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1); XSetForeground(display, scrPtr->monoGC, 0); XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1); scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank, &bla, &bla, 0, 0); XFreePixmap(display, blank); } #ifdef HAVE_XINTERNATOMS XInternAtoms(display, atomNames, wlengthof(atomNames), False, atoms); #else for (i = 0; i < wlengthof(atomNames); i++) { atoms[i] = XInternAtom(display, atomNames[i], False); } #endif i = 0; scrPtr->attribsAtom = atoms[i++]; scrPtr->deleteWindowAtom = atoms[i++]; scrPtr->protocolsAtom = atoms[i++]; scrPtr->clipboardAtom = atoms[i++]; scrPtr->xdndAwareAtom = atoms[i++]; scrPtr->xdndSelectionAtom = atoms[i++]; scrPtr->xdndEnterAtom = atoms[i++]; scrPtr->xdndLeaveAtom = atoms[i++]; scrPtr->xdndPositionAtom = atoms[i++]; scrPtr->xdndDropAtom = atoms[i++]; scrPtr->xdndFinishedAtom = atoms[i++]; scrPtr->xdndTypeListAtom = atoms[i++]; scrPtr->xdndActionListAtom = atoms[i++]; scrPtr->xdndActionDescriptionAtom = atoms[i++]; scrPtr->xdndStatusAtom = atoms[i++]; scrPtr->xdndActionCopy = atoms[i++]; scrPtr->xdndActionMove = atoms[i++]; scrPtr->xdndActionLink = atoms[i++]; scrPtr->xdndActionAsk = atoms[i++]; scrPtr->xdndActionPrivate = atoms[i++]; scrPtr->wmIconDragOffsetAtom = atoms[i++]; scrPtr->wmStateAtom = atoms[i++]; scrPtr->utf8String = atoms[i++]; scrPtr->netwmName = atoms[i++]; scrPtr->netwmIconName = atoms[i++]; scrPtr->netwmIcon = atoms[i++]; scrPtr->rootView = W_CreateRootView(scrPtr); scrPtr->balloon = W_CreateBalloon(scrPtr); W_InitApplication(scrPtr); return scrPtr; }