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); } } }
static void paintScrollView(ScrollView *sPtr) { W_DrawRelief(sPtr->view->screen, sPtr->view->window, 0, 0, sPtr->view->size.width, sPtr->view->size.height, sPtr->flags.relief); }
static void paintBrowser(WMBrowser * bPtr) { int i; if (!bPtr->view->flags.mapped) return; W_DrawRelief(bPtr->view->screen, bPtr->view->window, 0, bPtr->view->size.height - SCROLLER_WIDTH - 2, bPtr->view->size.width, 22, WRSunken); if (bPtr->flags.isTitled) { for (i = 0; i < bPtr->maxVisibleColumns; i++) { drawTitleOfColumn(bPtr, i + bPtr->firstVisibleColumn); } } }
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; } }
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 }
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); } }
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 }