Пример #1
0
static void drawRelief(WMView * view, Bool beveled)
{
	WMScreen *scr = view->screen;
	Display *dpy = scr->display;
	GC wgc;
	GC lgc;
	GC dgc;
	int width = view->size.width;
	int height = view->size.height;

	dgc = WMColorGC(scr->darkGray);

	if (!beveled) {
		XDrawRectangle(dpy, view->window, dgc, 0, 0, width - 1, height - 1);

		return;
	}
	wgc = WMColorGC(scr->white);
	lgc = WMColorGC(scr->gray);

	/* top left */
	XDrawLine(dpy, view->window, dgc, 0, 0, width - 1, 0);
	XDrawLine(dpy, view->window, dgc, 0, 1, width - 2, 1);

	XDrawLine(dpy, view->window, dgc, 0, 0, 0, height - 2);
	XDrawLine(dpy, view->window, dgc, 1, 0, 1, height - 3);

	/* bottom right */
	XDrawLine(dpy, view->window, wgc, 0, height - 1, width - 1, height - 1);
	XDrawLine(dpy, view->window, lgc, 1, height - 2, width - 2, height - 2);

	XDrawLine(dpy, view->window, wgc, width - 1, 0, width - 1, height - 1);
	XDrawLine(dpy, view->window, lgc, width - 2, 1, width - 2, height - 3);
}
Пример #2
0
void
W_DrawRelief(W_Screen * scr, Drawable d, int x, int y, unsigned int width,
	     unsigned int height, WMReliefType relief)
{
	W_DrawReliefWithGC(scr, d, x, y, width, height, relief,
			   WMColorGC(scr->black), WMColorGC(scr->darkGray),
			   WMColorGC(scr->gray), WMColorGC(scr->white));
}
void drawProcedure(XEvent *event, void *data){

  WMDrawPixmap(pixmap, ((struct _pict*)data)->dwin,HOFF,30);
  XDrawRectangle(display,((struct _pict*)data)->dwin,g3, HOFF,VOFF,100,100);
  XFillRectangle(screen->display, ((struct _pict*)data)->dwin  , WMColorGC(screen->white),  HOFF, VOFF, 100, 100);
  XDrawSegments(display,  ((struct _pict*)data)->dwin, WMColorGC(screen->black),  ((struct _pict*)data)->segments,  ((struct _pict*)data)->seglen);
  XFlush(display);
  return;
}
Пример #4
0
static void paintDot(TabView * tPtr, Drawable d, int x, int y)
{
	WMScreen *scr = W_VIEW(tPtr)->screen;
	Display *dpy = scr->display;
	GC white = WMColorGC(scr->white);
	GC black = WMColorGC(scr->black);

	XFillRectangle(dpy, d, black, x, y, 2, 2);
	XDrawPoint(dpy, d, white, x, y);
}
Пример #5
0
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;
}
Пример #6
0
static void drawRelief(W_Screen * scr, Drawable d, int x, int y, unsigned int width, unsigned int height)
{
	Display *dpy = scr->display;
	GC bgc = WMColorGC(scr->black);
	GC wgc = WMColorGC(scr->white);
	GC dgc = WMColorGC(scr->darkGray);

	XDrawLine(dpy, d, wgc, x, y, x, y + height - 1);

	XDrawLine(dpy, d, bgc, x, y + height - 1, x + width - 1, y + height - 1);
	XDrawLine(dpy, d, dgc, x + 1, y + height - 2, x + width - 2, y + height - 2);

	XDrawLine(dpy, d, bgc, x + width - 1, y, x + width - 1, y + height - 1);
	XDrawLine(dpy, d, dgc, x + width - 2, y + 1, x + width - 2, y + height - 2);
}
Пример #7
0
static Pixmap makePixmap(WMScreen * scr, int width, int height, int side, Pixmap * mask)
{
	Display *dpy = WMScreenDisplay(scr);
	Pixmap bitmap;
	Pixmap pixmap;
	int x, y;
	WMColor *black = WMBlackColor(scr);

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

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

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

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

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

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

	*mask = bitmap;

	WMReleaseColor(black);

	return pixmap;
}
Пример #8
0
static void drawTitleOfColumn(WMBrowser * bPtr, int column)
{
	WMScreen *scr = bPtr->view->screen;
	int x;

	x = (column - bPtr->firstVisibleColumn) * (bPtr->columnSize.width + COLUMN_SPACING);

	XFillRectangle(scr->display, bPtr->view->window, WMColorGC(scr->darkGray), x, 0,
		       bPtr->columnSize.width, bPtr->titleHeight);
	W_DrawRelief(scr, bPtr->view->window, x, 0, bPtr->columnSize.width, bPtr->titleHeight, WRSunken);

	if (column < bPtr->usedColumnCount && bPtr->titles[column]) {
		int titleLen = strlen(bPtr->titles[column]);
		int widthC = bPtr->columnSize.width - 8;

		if (WMWidthOfString(scr->boldFont, bPtr->titles[column], titleLen)
		    > widthC) {
			char *titleBuf = createTruncatedString(scr->boldFont,
							       bPtr->titles[column],
							       &titleLen, widthC);
			W_PaintText(bPtr->view, bPtr->view->window, scr->boldFont, x,
				    (bPtr->titleHeight - WMFontHeight(scr->boldFont)) / 2,
				    bPtr->columnSize.width, WACenter, scr->white, False, titleBuf, titleLen);
			wfree(titleBuf);
		} else {
			W_PaintText(bPtr->view, bPtr->view->window, scr->boldFont, x,
				    (bPtr->titleHeight - WMFontHeight(scr->boldFont)) / 2,
				    bPtr->columnSize.width, WACenter, scr->white,
				    False, bPtr->titles[column], titleLen);
		}
	}
}
Пример #9
0
static void paintItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
{
	WMView *view = W_VIEW(lPtr);
	W_Screen *scr = view->screen;
	Display *display = scr->display;
	WMFont *font = ((state & WLDSIsBranch) ? scr->boldFont : scr->normalFont);
	WMColor *backColor = ((state & WLDSSelected) ? scr->white : view->backColor);
	int width, height, x, y;

	/* Parameter not used, but tell the compiler that it is ok */
	(void) index;

	width = rect->size.width;
	height = rect->size.height;
	x = rect->pos.x;
	y = rect->pos.y;

	XFillRectangle(display, d, WMColorGC(backColor), x, y, width, height);

	if (text) {
		int widthC, textLen;

		/* Avoid overlaping... */
		widthC = (state & WLDSIsBranch) ? width - 20 : width - 8;
		textLen = strlen(text);
		if (WMWidthOfString(font, text, textLen) > widthC) {
			char *textBuf = createTruncatedString(font, text, &textLen, widthC);
			W_PaintText(view, d, font, x + 4, y, widthC, WALeft, scr->black, False, textBuf, textLen);
			wfree(textBuf);
		} else {
			W_PaintText(view, d, font, x + 4, y, widthC, WALeft, scr->black, False, text, textLen);
		}
	}

	if (state & WLDSIsBranch) {
		WMColor *lineColor = ((state & WLDSSelected) ? scr->gray : scr->white);

		XDrawLine(display, d, WMColorGC(scr->darkGray), x + width - 11, y + 3,
			  x + width - 6, y + height / 2);
		XDrawLine(display, d, WMColorGC(lineColor), x + width - 11, y + height - 5,
			  x + width - 6, y + height / 2);
		XDrawLine(display, d, WMColorGC(scr->black), x + width - 12, y + 3,
			  x + width - 12, y + height - 5);
	}
}
Пример #10
0
static void renderPixmap(W_Screen * screen, Pixmap d, Pixmap mask, char **data, int width, int height)
{
	int x, y;
	GC whiteGC = WMColorGC(screen->white);
	GC blackGC = WMColorGC(screen->black);
	GC lightGC = WMColorGC(screen->gray);
	GC darkGC = WMColorGC(screen->darkGray);

	if (mask)
		XSetForeground(screen->display, screen->monoGC, 0);

	for (y = 0; y < height; y++) {
		for (x = 0; x < width; x++) {
			switch (data[y][x]) {
			case ' ':
			case 'w':
				XDrawPoint(screen->display, d, whiteGC, x, y);
				break;

			case '=':
				if (mask)
					XDrawPoint(screen->display, mask, screen->monoGC, x, y);

			case '.':
			case 'l':
				XDrawPoint(screen->display, d, lightGC, x, y);
				break;

			case '%':
			case 'd':
				XDrawPoint(screen->display, d, darkGC, x, y);
				break;

			case '#':
			case 'b':
			default:
				XDrawPoint(screen->display, d, blackGC, x, y);
				break;
			}
		}
	}
}
Пример #11
0
static void
drawTab(TabView *tPtr, Drawable d, int x, int y,
        unsigned width, unsigned height, Bool selected)
{
    WMScreen *scr = W_VIEW(tPtr)->screen;
    Display *dpy = scr->display;
    GC white = WMColorGC(selected ? scr->white : tPtr->lightGray);
    GC black = WMColorGC(scr->black);
    GC dark = WMColorGC(scr->darkGray);
    GC light = WMColorGC(scr->gray);
    XPoint trap[8];

    trap[0].x = x + (selected ? 0 : 1);
    trap[0].y = y + height - (selected ? 0 : 1);

    trap[1].x = x + 3;
    trap[1].y = y + height - 3;

    trap[2].x = x + 10 - 3;
    trap[2].y = y + 3;

    trap[3].x = x + 10;
    trap[3].y = y;

    trap[4].x = x + width - 10;
    trap[4].y = y;

    trap[5].x = x + width - 10 + 3;
    trap[5].y = y + 3;

    trap[6].x = x + width - 3;
    trap[6].y = y + height - 3;

    trap[7].x = x + width - (selected ? 0 : 1);
    trap[7].y = y + height - (selected ? 0 : 1);

    XFillPolygon(dpy, d, selected ? light : WMColorGC(tPtr->tabColor), trap, 8,
                 Convex, CoordModeOrigin);

    XDrawLine(dpy, d, white, trap[0].x, trap[0].y, trap[1].x, trap[1].y);
    XDrawLine(dpy, d, white, trap[1].x, trap[1].y, trap[2].x, trap[2].y);
    XDrawLine(dpy, d, white, trap[2].x, trap[2].y, trap[3].x, trap[3].y);
    XDrawLine(dpy, d, white, trap[3].x, trap[3].y, trap[4].x, trap[4].y);
    XDrawLine(dpy, d, dark,  trap[4].x, trap[4].y, trap[5].x, trap[5].y);
    XDrawLine(dpy, d, black, trap[5].x, trap[5].y, trap[6].x, trap[6].y);
    XDrawLine(dpy, d, black, trap[6].x, trap[6].y, trap[7].x, trap[7].y);

    XDrawLine(dpy, d, selected ? light : WMColorGC(scr->white),
              trap[0].x, trap[0].y, trap[7].x, trap[7].y);
}
Пример #12
0
static void
paintItem(WMList *lPtr, int index, Drawable d, char *text, int state, WMRect *rect)
{
    int width, height, x, y;
    _Panel *panel = (_Panel*)WMGetHangedData(lPtr);
    WMScreen *scr = WMWidgetScreen(lPtr);
    Display *dpy = WMScreenDisplay(scr);
    WMColor *backColor = (state & WLDSSelected) ? panel->white : panel->gray;

    width = rect->size.width;
    height = rect->size.height;
    x = rect->pos.x;
    y = rect->pos.y;

    XFillRectangle(dpy, d, WMColorGC(backColor), x, y, width, height);

    if (state & 1) {
        WMDrawString(scr, d, panel->red, panel->font, x+4, y, text, strlen(text));
    } else {
        WMDrawString(scr, d, panel->black, panel->font, x+4, y, text, strlen(text));
    }
}
Пример #13
0
static void paintTabView(TabView * tPtr)
{
	Pixmap buffer;
	WMScreen *scr = W_VIEW(tPtr)->screen;
	Display *dpy = scr->display;
	GC white = WMColorGC(scr->white);
	int i;

	if (tPtr->flags.type == WTTopTabsBevelBorder) {
		int count = tPtr->visibleTabs;
		int first = tPtr->firstVisible;
		int moreAtLeft;
		int moreAtRight;
		int selectedIsVisible;
		int ty;
		int twidth, theight;

		ty = 2;
		theight = tPtr->tabHeight;

		buffer = XCreatePixmap(dpy, W_VIEW(tPtr)->window,
				       W_VIEW(tPtr)->size.width, theight, W_VIEW(tPtr)->screen->depth);

		XFillRectangle(dpy, buffer, WMColorGC(W_VIEW(tPtr)->backColor),
			       0, 0, W_VIEW(tPtr)->size.width, tPtr->tabHeight);

		if (tPtr->flags.dontFitAll) {
			moreAtLeft = first > 0;
			moreAtRight = (first + count) < tPtr->itemCount;
			if (tPtr->selectedItem >= first && tPtr->selectedItem < first + count)
				selectedIsVisible = 1;
			else
				selectedIsVisible = 0;
		} else {
			moreAtLeft = 0;
			moreAtRight = 0;
			selectedIsVisible = 1;
		}

		if (moreAtRight) {
			drawTab(tPtr, buffer, positionOfTab(tPtr, first + count), 0,
				W_VIEW_WIDTH(tPtr->view), theight, False);
		}
		for (i = first + count - 1; i >= first; i--) {
			if (!selectedIsVisible || i != tPtr->selectedItem) {
				twidth = W_TabViewItemTabWidth(tPtr->items[i]);

				drawTab(tPtr, buffer, positionOfTab(tPtr, i), 0, twidth, theight, False);
			}
		}
		if (moreAtLeft) {
			drawTab(tPtr, buffer, positionOfTab(tPtr, 0) - 2 * BUTTONED_SIDE_OFFSET,
				0, BUTTONED_SIDE_OFFSET * 4, theight, False);
		}

		if (selectedIsVisible) {
			int idx = tPtr->selectedItem;

			drawTab(tPtr, buffer, positionOfTab(tPtr, idx),
				0, W_TabViewItemTabWidth(tPtr->items[idx]), theight, True);

			XDrawLine(dpy, buffer, white, 0, theight - 1, positionOfTab(tPtr, idx), theight - 1);

			XDrawLine(dpy, buffer, white,
				  positionOfTab(tPtr, idx) + W_TabViewItemTabWidth(tPtr->items[idx]),
				  tPtr->tabHeight - 1, W_VIEW_WIDTH(tPtr->view) - 1, tPtr->tabHeight - 1);
		} else {
			XDrawLine(dpy, buffer, white, 0, theight - 1, W_VIEW_WIDTH(tPtr->view), theight - 1);
		}

		for (i = 0; i < count; i++) {
			WMRect rect;

			rect.pos.x = 15 + positionOfTab(tPtr, first + i);
			rect.pos.y = ty;
			rect.size.width = W_TabViewItemTabWidth(tPtr->items[first + i]);
			rect.size.height = theight;
			W_DrawLabel(tPtr->items[first + i], buffer, rect,
				    tPtr->flags.enabled && tPtr->items[first + i]->flags.enabled);
		}

		if (moreAtLeft) {
			paintDot(tPtr, buffer, 4, 10);
			paintDot(tPtr, buffer, 7, 10);
			paintDot(tPtr, buffer, 10, 10);
		}
		if (moreAtRight) {
			int x;

			x = positionOfTab(tPtr, tPtr->firstVisible + tPtr->visibleTabs);

			x = x + (W_VIEW_WIDTH(tPtr->view) - x) / 2;
			paintDot(tPtr, buffer, x + 5, 10);
			paintDot(tPtr, buffer, x + 8, 10);
			paintDot(tPtr, buffer, x + 11, 10);
		}

		XCopyArea(dpy, buffer, W_VIEW(tPtr)->window, scr->copyGC, 0, 0,
			  W_VIEW_WIDTH(tPtr->view), theight, 0, 0);

		XFreePixmap(dpy, buffer);
	}
	switch (tPtr->flags.type) {
	case WTTopTabsBevelBorder:
		drawRelief(scr, W_VIEW(tPtr)->window, 0, tPtr->tabHeight - 1,
			   W_VIEW(tPtr)->size.width, W_VIEW(tPtr)->size.height - tPtr->tabHeight + 1);
		break;

	case WTNoTabsBevelBorder:
		W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width,
			     W_VIEW(tPtr)->size.height, WRRaised);
		break;

	case WTNoTabsLineBorder:
		W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width,
			     W_VIEW(tPtr)->size.height, WRSimple);
		break;

	case WTNoTabsNoBorder:
		break;
	}
}
Пример #14
0
void
W_PaintTextAndImage(W_View * view, int wrap, WMColor * textColor, W_Font * font,
		    WMReliefType relief, const char *text,
		    WMAlignment alignment, W_Pixmap * image,
		    WMImagePosition position, WMColor * backColor, int ofs)
{
	W_Screen *screen = view->screen;
	int ix, iy;
	int x, y, w, h;
	Drawable d = view->window;

#ifdef DOUBLE_BUFFER
	d = XCreatePixmap(screen->display, view->window, view->size.width, view->size.height, screen->depth);
#endif

	/* background */
	if (backColor) {
		XFillRectangle(screen->display, d, WMColorGC(backColor),
			       0, 0, view->size.width, view->size.height);
	} else {
#ifndef DOUBLE_BUFFER
		XClearWindow(screen->display, d);
#else
		XSetForeground(screen->display, screen->copyGC, view->attribs.background_pixel);
		XFillRectangle(screen->display, d, screen->copyGC, 0, 0, view->size.width, view->size.height);
#endif
	}

	if (relief == WRFlat) {
		x = 0;
		y = 0;
		w = view->size.width;
		h = view->size.height;
	} else {
		x = 1;
		y = 1;
		w = view->size.width - 3;
		h = view->size.height - 3;
	}

	/* calc. image alignment */
	if (position != WIPNoImage && image != NULL) {
		switch (position) {
		case WIPOverlaps:
		case WIPImageOnly:
			ix = (view->size.width - image->width) / 2;
			iy = (view->size.height - image->height) / 2;
			/*
			   x = 2;
			   y = 0;
			 */
			break;

		case WIPLeft:
			ix = x;
			iy = y + (h - image->height) / 2;
			x = x + image->width + 5;
			y = 0;
			w -= image->width + 5;
			break;

		case WIPRight:
			ix = view->size.width - image->width - x;
			iy = y + (h - image->height) / 2;
			w -= image->width + 5;
			break;

		case WIPBelow:
			ix = (view->size.width - image->width) / 2;
			iy = h - image->height;
			y = 0;
			h -= image->height;
			break;

		default:
		case WIPAbove:
			ix = (view->size.width - image->width) / 2;
			iy = y;
			y = image->height;
			h -= image->height;
			break;
		}

		ix += ofs;
		iy += ofs;

		XSetClipOrigin(screen->display, screen->clipGC, ix, iy);
		XSetClipMask(screen->display, screen->clipGC, image->mask);

		if (image->depth == 1)
			XCopyPlane(screen->display, image->pixmap, d, screen->clipGC,
				   0, 0, image->width, image->height, ix, iy, 1);
		else
			XCopyArea(screen->display, image->pixmap, d, screen->clipGC,
				  0, 0, image->width, image->height, ix, iy);
	}

	/* draw text */
	if (position != WIPImageOnly && text != NULL) {
		int textHeight;

		textHeight = W_GetTextHeight(font, text, w - 8, wrap);
		W_PaintText(view, d, font, x + ofs + 4, y + ofs + (h - textHeight) / 2, w - 8,
			    alignment, textColor, wrap, text, strlen(text));
	}

	/* draw relief */
	W_DrawRelief(screen, d, 0, 0, view->size.width, view->size.height, relief);

#ifdef DOUBLE_BUFFER
	XCopyArea(screen->display, d, view->window, screen->copyGC, 0, 0,
		  view->size.width, view->size.height, 0, 0);
	XFreePixmap(screen->display, d);
#endif
}
Пример #15
0
static void paintTextField(TextField * tPtr)
{
	W_Screen *screen = tPtr->view->screen;
	W_View *view = tPtr->view;
	W_View viewbuffer;
	int tx, ty, tw;
	int rx;
	int bd;
	int totalWidth;
	char *text;
	Pixmap drawbuffer;
	WMColor *color;

	if (!view->flags.realized || !view->flags.mapped)
		return;

	if (!tPtr->flags.bordered) {
		bd = 0;
	} else {
		bd = 2;
	}

	if (tPtr->flags.secure) {
		text = makeHiddenString(strlen(tPtr->text));
	} else {
		text = tPtr->text;
	}

	totalWidth = tPtr->view->size.width - 2 * bd;

	drawbuffer = XCreatePixmap(screen->display, view->window,
				   view->size.width, view->size.height, screen->depth);
	XFillRectangle(screen->display, drawbuffer, WMColorGC(screen->white),
		       0, 0, view->size.width, view->size.height);
	/* this is quite dirty */
	viewbuffer.screen = view->screen;
	viewbuffer.size = view->size;
	viewbuffer.window = drawbuffer;

	if (tPtr->textLen > 0) {
		tw = WMWidthOfString(tPtr->font, &(text[tPtr->viewPosition]), tPtr->textLen - tPtr->viewPosition);

		ty = tPtr->offsetWidth;
		switch (tPtr->flags.alignment) {
		case WALeft:
			tx = tPtr->offsetWidth + 1;
			if (tw < tPtr->usableWidth)
				XFillRectangle(screen->display, drawbuffer,
					       WMColorGC(screen->white),
					       bd + tw, bd, totalWidth - tw, view->size.height - 2 * bd);
			break;

		case WACenter:
			tx = tPtr->offsetWidth + (tPtr->usableWidth - tw) / 2;
			if (tw < tPtr->usableWidth)
				XClearArea(screen->display, view->window, bd, bd,
					   totalWidth, view->size.height - 2 * bd, False);
			break;

		default:
		case WARight:
			tx = tPtr->offsetWidth + tPtr->usableWidth - tw - 1;
			if (tw < tPtr->usableWidth)
				XClearArea(screen->display, view->window, bd, bd,
					   totalWidth - tw, view->size.height - 2 * bd, False);
			break;
		}

		color = tPtr->flags.enabled ? screen->black : screen->darkGray;

		WMDrawImageString(screen, drawbuffer, color, screen->white,
				  tPtr->font, tx, ty, &(text[tPtr->viewPosition]),
				  tPtr->textLen - tPtr->viewPosition);

		if (tPtr->selection.count) {
			int count, count2;

			count = tPtr->selection.count < 0
			    ? tPtr->selection.position + tPtr->selection.count : tPtr->selection.position;
			count2 = abs(tPtr->selection.count);
			if (count < tPtr->viewPosition) {
				count2 = abs(count2 - abs(tPtr->viewPosition - count));
				count = tPtr->viewPosition;
			}

			rx = tPtr->offsetWidth + 1 + WMWidthOfString(tPtr->font, text, count)
			    - WMWidthOfString(tPtr->font, text, tPtr->viewPosition);

			WMDrawImageString(screen, drawbuffer, color, screen->gray,
					  tPtr->font, rx, ty, &(text[count]), count2);
		}
	} else {
		XFillRectangle(screen->display, drawbuffer, WMColorGC(screen->white),
			       bd, bd, totalWidth, view->size.height - 2 * bd);
	}

	/* draw relief */
	if (tPtr->flags.bordered) {
		drawRelief(&viewbuffer, tPtr->flags.beveled);
	}

	if (tPtr->flags.secure)
		wfree(text);
	XCopyArea(screen->display, drawbuffer, view->window,
		  screen->copyGC, 0, 0, view->size.width, view->size.height, 0, 0);
	XFreePixmap(screen->display, drawbuffer);

	/* draw cursor */
	if (tPtr->flags.focused && tPtr->flags.enabled && tPtr->flags.cursorOn) {
		paintCursor(tPtr);
	}
}
Пример #16
0
static void showWorkspaceName(WScreen * scr, int workspace)
{
	WorkspaceNameData *data;
	RXImage *ximg;
	Pixmap text, mask;
	int w, h;
	int px, py;
	char *name = w_global.workspace.array[workspace]->name;
	int len = strlen(name);
	int x, y;
#ifdef USE_XINERAMA
	int head;
	WMRect rect;
	int xx, yy;
#endif

	if (wPreferences.workspace_name_display_position == WD_NONE || w_global.workspace.count < 2)
		return;

	if (scr->workspace_name_timer) {
		WMDeleteTimerHandler(scr->workspace_name_timer);
		XUnmapWindow(dpy, scr->workspace_name);
		XFlush(dpy);
	}
	scr->workspace_name_timer = WMAddTimerHandler(WORKSPACE_NAME_DELAY, hideWorkspaceName, scr);

	if (scr->workspace_name_data) {
		RReleaseImage(scr->workspace_name_data->back);
		RReleaseImage(scr->workspace_name_data->text);
		wfree(scr->workspace_name_data);
	}

	data = wmalloc(sizeof(WorkspaceNameData));
	data->back = NULL;

	w = WMWidthOfString(w_global.workspace.font_for_name, name, len);
	h = WMFontHeight(w_global.workspace.font_for_name);

#ifdef USE_XINERAMA
	head = wGetHeadForPointerLocation(scr);
	rect = wGetRectForHead(scr, head);
	if (scr->xine_info.count) {
		xx = rect.pos.x + (scr->xine_info.screens[head].size.width - (w + 4)) / 2;
		yy = rect.pos.y + (scr->xine_info.screens[head].size.height - (h + 4)) / 2;
	}
	else {
		xx = (scr->scr_width - (w + 4)) / 2;
		yy = (scr->scr_height - (h + 4)) / 2;
	}
#endif

	switch (wPreferences.workspace_name_display_position) {
	case WD_TOP:
#ifdef USE_XINERAMA
		px = xx;
#else
		px = (scr->scr_width - (w + 4)) / 2;
#endif
		py = WORKSPACE_NAME_DISPLAY_PADDING;
		break;
	case WD_BOTTOM:
#ifdef USE_XINERAMA
		px = xx;
#else
		px = (scr->scr_width - (w + 4)) / 2;
#endif
		py = scr->scr_height - (h + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
		break;
	case WD_TOPLEFT:
		px = WORKSPACE_NAME_DISPLAY_PADDING;
		py = WORKSPACE_NAME_DISPLAY_PADDING;
		break;
	case WD_TOPRIGHT:
		px = scr->scr_width - (w + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
		py = WORKSPACE_NAME_DISPLAY_PADDING;
		break;
	case WD_BOTTOMLEFT:
		px = WORKSPACE_NAME_DISPLAY_PADDING;
		py = scr->scr_height - (h + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
		break;
	case WD_BOTTOMRIGHT:
		px = scr->scr_width - (w + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
		py = scr->scr_height - (h + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
		break;
	case WD_CENTER:
	default:
#ifdef USE_XINERAMA
		px = xx;
		py = yy;
#else
		px = (scr->scr_width - (w + 4)) / 2;
		py = (scr->scr_height - (h + 4)) / 2;
#endif
		break;
	}
	XResizeWindow(dpy, scr->workspace_name, w + 4, h + 4);
	XMoveWindow(dpy, scr->workspace_name, px, py);

	text = XCreatePixmap(dpy, scr->w_win, w + 4, h + 4, scr->w_depth);
	mask = XCreatePixmap(dpy, scr->w_win, w + 4, h + 4, 1);

	/*XSetForeground(dpy, scr->mono_gc, 0);
	   XFillRectangle(dpy, mask, scr->mono_gc, 0, 0, w+4, h+4); */

	XFillRectangle(dpy, text, WMColorGC(scr->black), 0, 0, w + 4, h + 4);

	for (x = 0; x <= 4; x++)
		for (y = 0; y <= 4; y++)
			WMDrawString(scr->wmscreen, text, scr->white, w_global.workspace.font_for_name, x, y, name, len);

	XSetForeground(dpy, scr->mono_gc, 1);
	XSetBackground(dpy, scr->mono_gc, 0);

	XCopyPlane(dpy, text, mask, scr->mono_gc, 0, 0, w + 4, h + 4, 0, 0, 1 << (scr->w_depth - 1));

	/*XSetForeground(dpy, scr->mono_gc, 1); */
	XSetBackground(dpy, scr->mono_gc, 1);

	XFillRectangle(dpy, text, WMColorGC(scr->black), 0, 0, w + 4, h + 4);

	WMDrawString(scr->wmscreen, text, scr->white, w_global.workspace.font_for_name, 2, 2, name, len);

#ifdef USE_XSHAPE
	if (w_global.xext.shape.supported)
		XShapeCombineMask(dpy, scr->workspace_name, ShapeBounding, 0, 0, mask, ShapeSet);
#endif
	XSetWindowBackgroundPixmap(dpy, scr->workspace_name, text);
	XClearWindow(dpy, scr->workspace_name);

	data->text = RCreateImageFromDrawable(scr->rcontext, text, None);

	XFreePixmap(dpy, text);
	XFreePixmap(dpy, mask);

	if (!data->text) {
		XMapRaised(dpy, scr->workspace_name);
		XFlush(dpy);

		goto erro;
	}

	ximg = RGetXImage(scr->rcontext, scr->root_win, px, py, data->text->width, data->text->height);

	if (!ximg || !ximg->image) {
		goto erro;
	}

	XMapRaised(dpy, scr->workspace_name);
	XFlush(dpy);

	data->back = RCreateImageFromXImage(scr->rcontext, ximg->image, NULL);
	RDestroyXImage(scr->rcontext, ximg);

	if (!data->back) {
		goto erro;
	}

	data->count = 10;

	/* set a timeout for the effect */
	data->timeout = time(NULL) + 2 + (WORKSPACE_NAME_DELAY + WORKSPACE_NAME_FADE_DELAY * data->count) / 1000;

	scr->workspace_name_data = data;

	return;

 erro:
	if (scr->workspace_name_timer)
		WMDeleteTimerHandler(scr->workspace_name_timer);

	if (data->text)
		RReleaseImage(data->text);
	if (data->back)
		RReleaseImage(data->back);
	wfree(data);

	scr->workspace_name_data = NULL;

	scr->workspace_name_timer = WMAddTimerHandler(WORKSPACE_NAME_DELAY +
						      10 * WORKSPACE_NAME_FADE_DELAY, hideWorkspaceName, scr);
}
Пример #17
0
static void paintArrow(WMScroller * sPtr, Drawable d, int part)
/*
 * part- 0 paints the decrement arrow, 1 the increment arrow
 */
{
	WMView *view = sPtr->view;
	WMScreen *scr = view->screen;
	int ofs;
	W_Pixmap *arrow;

#ifndef DOUBLE_BUFFER
	GC gc = scr->lightGC;
#endif

	if (part == 0) {	/* decrement button */
		if (sPtr->flags.horizontal) {
			if (sPtr->flags.arrowsPosition == WSAMaxEnd) {
				ofs = view->size.width - 2 * (BUTTON_SIZE + 1) - 1;
			} else {
				ofs = 2;
			}
			if (sPtr->flags.decrDown)
				arrow = scr->hiLeftArrow;
			else
				arrow = scr->leftArrow;

		} else {
			if (sPtr->flags.arrowsPosition == WSAMaxEnd) {
				ofs = view->size.height - 2 * (BUTTON_SIZE + 1) - 1;
			} else {
				ofs = 2;
			}
			if (sPtr->flags.decrDown)
				arrow = scr->hiUpArrow;
			else
				arrow = scr->upArrow;
		}

#ifndef DOUBLE_BUFFER
		if (sPtr->flags.decrDown)
			gc = WMColorGC(scr->white);
#endif
	} else {		/* increment button */
		if (sPtr->flags.horizontal) {
			if (sPtr->flags.arrowsPosition == WSAMaxEnd) {
				ofs = view->size.width - BUTTON_SIZE + 1 - 3;
			} else {
				ofs = 2 + BUTTON_SIZE + 1;
			}
			if (sPtr->flags.incrDown)
				arrow = scr->hiRightArrow;
			else
				arrow = scr->rightArrow;
		} else {
			if (sPtr->flags.arrowsPosition == WSAMaxEnd) {
				ofs = view->size.height - BUTTON_SIZE + 1 - 3;
			} else {
				ofs = 2 + BUTTON_SIZE + 1;
			}
			if (sPtr->flags.incrDown)
				arrow = scr->hiDownArrow;
			else
				arrow = scr->downArrow;
		}

#ifndef DOUBLE_BUFFER
		if (sPtr->flags.incrDown)
			gc = scr->whiteGC;
#endif
	}

	if (sPtr->flags.horizontal) {
		/* paint button */
#ifndef DOUBLE_BUFFER
		XFillRectangle(scr->display, d, gc, ofs + 1, 2 + 1, BUTTON_SIZE + 1 - 3, BUTTON_SIZE - 3);
#else
		if ((!part && sPtr->flags.decrDown) || (part && sPtr->flags.incrDown))
			XFillRectangle(scr->display, d, WMColorGC(scr->white),
				       ofs + 1, 2 + 1, BUTTON_SIZE + 1 - 3, BUTTON_SIZE - 3);
#endif				/* DOUBLE_BUFFER */
		W_DrawRelief(scr, d, ofs, 2, BUTTON_SIZE, BUTTON_SIZE, WRRaised);

		/* paint arrow */
		XSetClipMask(scr->display, scr->clipGC, arrow->mask);
		XSetClipOrigin(scr->display, scr->clipGC,
			       ofs + (BUTTON_SIZE - arrow->width) / 2, 2 + (BUTTON_SIZE - arrow->height) / 2);

		XCopyArea(scr->display, arrow->pixmap, d, scr->clipGC,
			  0, 0, arrow->width, arrow->height,
			  ofs + (BUTTON_SIZE - arrow->width) / 2, 2 + (BUTTON_SIZE - arrow->height) / 2);

	} else {		/* vertical */

		/* paint button */
#ifndef DOUBLE_BUFFER
		XFillRectangle(scr->display, d, gc, 2 + 1, ofs + 1, BUTTON_SIZE - 3, BUTTON_SIZE + 1 - 3);
#else
		if ((!part && sPtr->flags.decrDown) || (part && sPtr->flags.incrDown))
			XFillRectangle(scr->display, d, WMColorGC(scr->white),
				       2 + 1, ofs + 1, BUTTON_SIZE - 3, BUTTON_SIZE + 1 - 3);
#endif				/* DOUBLE_BUFFER */
		W_DrawRelief(scr, d, 2, ofs, BUTTON_SIZE, BUTTON_SIZE, WRRaised);

		/* paint arrow */

		XSetClipMask(scr->display, scr->clipGC, arrow->mask);
		XSetClipOrigin(scr->display, scr->clipGC,
			       2 + (BUTTON_SIZE - arrow->width) / 2, ofs + (BUTTON_SIZE - arrow->height) / 2);
		XCopyArea(scr->display, arrow->pixmap, d, scr->clipGC,
			  0, 0, arrow->width, arrow->height,
			  2 + (BUTTON_SIZE - arrow->width) / 2, ofs + (BUTTON_SIZE - arrow->height) / 2);
	}
}
Пример #18
0
static void paintScroller(Scroller * sPtr)
{
	WMView *view = sPtr->view;
	WMScreen *scr = view->screen;
#ifdef DOUBLE_BUFFER
	Pixmap d;
#else
	Drawable d = view->window;
#endif
	int length, ofs;
	float knobP, knobL;

#ifdef DOUBLE_BUFFER
	d = XCreatePixmap(scr->display, view->window, view->size.width, view->size.height, scr->depth);
	XFillRectangle(scr->display, d, WMColorGC(scr->gray), 0, 0, view->size.width, view->size.height);
#endif

	XDrawRectangle(scr->display, d, WMColorGC(scr->black), 0, 0, view->size.width - 1, view->size.height - 1);
#ifndef DOUBLE_BUFFER
	XDrawRectangle(scr->display, d, WMColorGC(scr->gray), 1, 1, view->size.width - 3, view->size.height - 3);
#endif

	if (sPtr->flags.horizontal)
		length = view->size.width - 4;
	else
		length = view->size.height - 4;

	if (sPtr->flags.documentFullyVisible) {
		XFillRectangle(scr->display, d, scr->stippleGC, 2, 2, view->size.width - 4, view->size.height - 4);
	} else {
		ofs = 2;
		if (sPtr->flags.arrowsPosition == WSAMaxEnd) {
			length -= (BUTTON_SIZE + 1) * 2;
		} else if (sPtr->flags.arrowsPosition == WSAMinEnd) {
			ofs += (BUTTON_SIZE + 1) * 2;
			length -= (BUTTON_SIZE + 1) * 2;
		}

		knobL = (float)knobLength(sPtr);

		knobP = sPtr->floatValue * ((float)length - knobL);

		if (sPtr->flags.horizontal) {
			/* before */
			XFillRectangle(scr->display, d, scr->stippleGC, ofs, 2, (int)knobP, view->size.height - 4);

			/* knob */
#ifndef DOUBLE_BUFFER
			XFillRectangle(scr->display, d, scr->lightGC,
				       ofs + (int)knobP + 2, 2 + 2, (int)knobL - 4, view->size.height - 4 - 4);
#endif
			W_DrawRelief(scr, d, ofs + (int)knobP, 2, (int)knobL, view->size.height - 4, WRRaised);

			XCopyArea(scr->display, scr->scrollerDimple->pixmap, d,
				  scr->copyGC, 0, 0,
				  scr->scrollerDimple->width, scr->scrollerDimple->height,
				  ofs + (int)knobP + ((int)knobL - scr->scrollerDimple->width - 1) / 2,
				  (view->size.height - scr->scrollerDimple->height - 1) / 2);

			/* after */
			if ((int)(knobP + knobL) < length)
				XFillRectangle(scr->display, d, scr->stippleGC,
					       ofs + (int)(knobP + knobL), 2,
					       length - (int)(knobP + knobL), view->size.height - 4);
		} else {
			/* before */
			if (knobP > 0.0)
				XFillRectangle(scr->display, d, scr->stippleGC,
					       2, ofs, view->size.width - 4, (int)knobP);

			/* knob */
#ifndef DOUBLE_BUFFER
			XFillRectangle(scr->display, d, scr->lightGC,
				       2 + 2, ofs + (int)knobP + 2, view->size.width - 4 - 4, (int)knobL - 4);
#endif
			XCopyArea(scr->display, scr->scrollerDimple->pixmap, d,
				  scr->copyGC, 0, 0,
				  scr->scrollerDimple->width, scr->scrollerDimple->height,
				  (view->size.width - scr->scrollerDimple->width - 1) / 2,
				  ofs + (int)knobP + ((int)knobL - scr->scrollerDimple->height - 1) / 2);

			W_DrawRelief(scr, d, 2, ofs + (int)knobP, view->size.width - 4, (int)knobL, WRRaised);

			/* after */
			if ((int)(knobP + knobL) < length)
				XFillRectangle(scr->display, d, scr->stippleGC,
					       2, ofs + (int)(knobP + knobL),
					       view->size.width - 4, length - (int)(knobP + knobL));
		}

		if (sPtr->flags.arrowsPosition != WSANone) {
			paintArrow(sPtr, d, 0);
			paintArrow(sPtr, d, 1);
		}
	}

#ifdef DOUBLE_BUFFER
	XCopyArea(scr->display, d, view->window, scr->copyGC, 0, 0, view->size.width, view->size.height, 0, 0);
	XFreePixmap(scr->display, d);
#endif
}
Пример #19
0
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);
	}
}
Пример #20
0
static void drawBalloon(WMScreen * scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, int h, int side)
{
	Display *dpy = scr->display;
	WMColor *white = WMWhiteColor(scr);
	WMColor *black = WMBlackColor(scr);
	GC bgc = scr->monoGC;
	GC gc = WMColorGC(white);
	int rad = h * 3 / 10;
	XPoint pt[3], ipt[3];
	int w1;

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

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

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

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

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

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

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

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

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

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

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

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

	WMReleaseColor(white);
	WMReleaseColor(black);
}
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);
}
Пример #22
0
static void handleEvents(XEvent * event, void *data)
{
	Ruler *rPtr = (Ruler *) data;

	switch (event->type) {
	case Expose:
		rulerDidResize(rPtr->view->delegate, rPtr->view);
		break;

	case MotionNotify:
		if (rPtr->flags.buttonPressed && (event->xmotion.state & Button1Mask)) {
			if (verifyMarkerMove(rPtr, event->xmotion.x)) {
				GC gc = WMColorGC(WMDarkGrayColor(rPtr->view->screen));

				if (rPtr->moveAction)
					(rPtr->moveAction) (rPtr, rPtr->clientData);
				rPtr->flags.redraw = True;
				paintRuler(rPtr);
				XSetLineAttributes(rPtr->view->screen->display, gc, 1,
						   LineSolid, CapNotLast, JoinMiter);
				XDrawLine(rPtr->pview->screen->display,
					  rPtr->pview->window,
					  gc, rPtr->motion + 1, 40,
					  rPtr->motion + 1, rPtr->pview->size.height - 5);
			}
		}
		break;

	case ButtonPress:
		if (event->xbutton.button != Button1)
			return;
		rPtr->flags.buttonPressed = True;
		rPtr->flags.whichMarker = whichMarker(rPtr, event->xmotion.x, event->xmotion.y);
		break;

	case ButtonRelease:
		if (event->xbutton.button != Button1)
			return;
		rPtr->flags.buttonPressed = False;
		switch (rPtr->flags.whichMarker) {
		case 1:{
				int change = rPtr->margins.left - rPtr->motion;

				rPtr->margins.first -= change;
				rPtr->margins.body -= change;
				rPtr->margins.left = rPtr->motion;
				rPtr->flags.redraw = True;
				paintRuler(rPtr);
				break;
			}
		case 2:
			rPtr->margins.right = rPtr->motion;
			break;
		case 3:
			rPtr->margins.first = rPtr->motion;
			break;
		case 4:
			rPtr->margins.body = rPtr->motion;
			break;
		case 6:
			rPtr->margins.first = rPtr->margins.body = rPtr->motion;
			break;
		}
		if (rPtr->releaseAction)
			(rPtr->releaseAction) (rPtr, rPtr->clientData);
		break;
	}
}