static void doRearrange(void *object, void *cdata) { SubviewItem *item = (SubviewItem *) object; BoxData *eData = (BoxData *) cdata; if (eData->box->horizontal) { eData->w = item->minSize; if (item->expand) eData->w += eData->total / eData->expands; } else { eData->h = item->minSize; if (item->expand) eData->h += eData->total / eData->expands; } if (!item->end) { W_MoveView(item->view, eData->x, eData->y); } W_ResizeView(item->view, eData->w, eData->h); if (eData->box->horizontal) { if (item->end) eData->xe -= eData->w + item->space; else eData->x += eData->w + item->space; } else { if (item->end) eData->ye -= eData->h + item->space; else eData->y += eData->h + item->space; } if (item->end) { W_MoveView(item->view, eData->xe, eData->ye); } }
static void resizedParent(void *self, WMNotification * notif) { WMSize size = WMGetViewSize((WMView *) WMGetNotificationObject(notif)); WMView *view = (WMView *) self; W_MoveView(view, view->leftOffs, view->topOffs); W_ResizeView(view, size.width - (view->leftOffs + view->rightOffs), size.height - (view->topOffs + view->bottomOffs)); }
void WMSetViewExpandsToParent(WMView * view, int leftOffs, int topOffs, int rightOffs, int bottomOffs) { WMSize size = view->parent->size; view->topOffs = topOffs; view->bottomOffs = bottomOffs; view->leftOffs = leftOffs; view->rightOffs = rightOffs; WMAddNotificationObserver(resizedParent, view, WMViewSizeDidChangeNotification, view->parent); WMSetViewNotifySizeChanges(view->parent, True); W_MoveView(view, leftOffs, topOffs); W_ResizeView(view, size.width - (leftOffs + rightOffs), size.height - (topOffs + bottomOffs)); }
static void moveView(WMSplitView * sPtr, WMView * view, int pos) { int x, y; if (sPtr->flags.vertical) { x = pos; y = 0; } else { x = 0; y = pos; } if (view->self) WMMoveWidget(view->self, x, y); else W_MoveView(view, x, y); }
static void rearrange(TabView * tPtr) { int i; int width, height; int bordered = tPtr->flags.bordered; recalcTabWidth(tPtr); width = tPtr->view->size.width - (bordered ? 3 : 0); height = tPtr->view->size.height - tPtr->tabHeight - (bordered ? 3 : 0); for (i = 0; i < tPtr->itemCount; i++) { W_MoveView(W_TabViewItemView(tPtr->items[i]), 1 * bordered, tPtr->tabHeight + 1 * bordered); W_ResizeView(W_TabViewItemView(tPtr->items[i]), width, height); } if (W_VIEW_MAPPED(tPtr->view) && W_VIEW_REALIZED(tPtr->view)) paintTabView(tPtr); }
void WMScrollViewScrollPoint(WMScrollView *sPtr, WMPoint point) { float xsize, ysize; float xpos, ypos; xsize = sPtr->contentView->size.width-sPtr->viewport->size.width; ysize = sPtr->contentView->size.height-sPtr->viewport->size.height; xpos = point.x / xsize; ypos = point.y / ysize; if (sPtr->hScroller) WMSetScrollerParameters(sPtr->hScroller, xpos, WMGetScrollerKnobProportion(sPtr->hScroller)); if (sPtr->vScroller) WMSetScrollerParameters(sPtr->vScroller, ypos, WMGetScrollerKnobProportion(sPtr->vScroller)); W_MoveView(sPtr->contentView, -point.x, -point.y); }
static void applyScrollerValues(WMScrollView *sPtr) { int x, y; if (sPtr->contentView == NULL) return; if (sPtr->flags.hasHScroller) { float v = WMGetScrollerValue(sPtr->hScroller); int size; size = sPtr->contentView->size.width-sPtr->viewport->size.width; x = v * size; } else { x = 0; } if (sPtr->flags.hasVScroller) { float v = WMGetScrollerValue(sPtr->vScroller); int size; size = sPtr->contentView->size.height-sPtr->viewport->size.height; y = v * size; } else { y = 0; } x = WMAX(0, x); y = WMAX(0, y); W_MoveView(sPtr->contentView, -x, -y); W_RaiseView(sPtr->viewport); }
static void doScrolling(WMWidget *self, void *data) { ScrollView *sPtr = (ScrollView*)data; float value; int pos; int vpsize; float size; if (sPtr->hScroller == (WMScroller *)self) { pos = -sPtr->contentView->pos.x; size = sPtr->contentView->size.width-sPtr->viewport->size.width; vpsize = sPtr->viewport->size.width - sPtr->pageScroll; } else { pos = -sPtr->contentView->pos.y; size = sPtr->contentView->size.height-sPtr->viewport->size.height; vpsize = sPtr->viewport->size.height - sPtr->pageScroll; } if (vpsize <= 0) vpsize = 1; switch (WMGetScrollerHitPart(self)) { case WSDecrementLine: if (pos > 0) { pos-=sPtr->lineScroll; if (pos < 0) pos = 0; value = (float)pos / size; WMSetScrollerParameters(self, value, WMGetScrollerKnobProportion(self)); } break; case WSIncrementLine: if (pos < size) { pos+=sPtr->lineScroll; if (pos > size) pos = size; value = (float)pos / size; WMSetScrollerParameters(self, value, WMGetScrollerKnobProportion(self)); } break; case WSKnob: value = WMGetScrollerValue(self); pos = value*size; break; case WSDecrementPage: if (pos > 0) { pos -= vpsize; if (pos < 0) pos = 0; value = (float)pos / size; WMSetScrollerParameters(self, value, WMGetScrollerKnobProportion(self)); } break; case WSDecrementWheel: if (pos > 0) { pos -= vpsize/3; if (pos < 0) pos = 0; value = (float)pos / size; WMSetScrollerParameters(self, value, WMGetScrollerKnobProportion(self)); } break; case WSIncrementPage: if (pos < size) { pos += vpsize; if (pos > size) pos = size; value = (float)pos / size; WMSetScrollerParameters(self, value, WMGetScrollerKnobProportion(self)); } break; case WSIncrementWheel: if (pos < size) { pos += vpsize/3; if (pos > size) pos = size; value = (float)pos / size; WMSetScrollerParameters(self, value, WMGetScrollerKnobProportion(self)); } break; case WSNoPart: case WSKnobSlot: break; } if (sPtr->hScroller == (WMScroller *)self) { W_MoveView(sPtr->contentView, -pos, sPtr->contentView->pos.y); } else { W_MoveView(sPtr->contentView, sPtr->contentView->pos.x, -pos); } }
static void reorganizeInterior(WMScrollView *sPtr) { int hx, hy, hw; int vx, vy, vh; int cx, cy, cw, ch; cw = hw = sPtr->view->size.width; vh = ch = sPtr->view->size.height; if (sPtr->flags.relief == WRSimple) { cw -= 2; ch -= 2; cx = 1; cy = 1; } else if (sPtr->flags.relief != WRFlat) { cw -= 3; ch -= 3; cx = 2; cy = 2; } else { cx = 0; cy = 0; } if (sPtr->flags.hasHScroller) { int h = 20; ch -= h; if (sPtr->flags.relief == WRSimple) { hx = 0; hy = sPtr->view->size.height - h; } else if (sPtr->flags.relief != WRFlat) { hx = 1; hy = sPtr->view->size.height - h - 1; hw -= 2; } else { hx = 0; hy = sPtr->view->size.height - h; } } else { /* make compiler shutup */ hx = 0; hy = 0; } if (sPtr->flags.hasVScroller) { int w = 20; cw -= w; cx += w; hx += w - 1; hw -= w - 1; if (sPtr->flags.relief == WRSimple) { vx = 0; vy = 0; } else if (sPtr->flags.relief != WRFlat) { vx = 1; vy = 1; vh -= 2; } else { vx = 0; vy = 0; } } else { /* make compiler shutup */ vx = 0; vy = 0; } W_ResizeView(sPtr->viewport, cw, ch); W_MoveView(sPtr->viewport, cx, cy); if (sPtr->flags.hasHScroller) { WMResizeWidget(sPtr->hScroller, hw, 20); WMMoveWidget(sPtr->hScroller, hx, hy); } if (sPtr->flags.hasVScroller) { WMResizeWidget(sPtr->vScroller, 20, vh); WMMoveWidget(sPtr->vScroller, vx, vy); } applyScrollerValues(sPtr); }
static void showText(Balloon * bPtr, int x, int y, int w, int h, const char *text) { WMScreen *scr = bPtr->view->screen; Display *dpy = WMScreenDisplay(scr); int width; int height; Pixmap pixmap; Pixmap mask; WMFont *font = bPtr->font ? bPtr->font : scr->normalFont; int textHeight; int side = 0; int ty; int bx, by; { int w; const char *ptr, *ptr2; ptr2 = ptr = text; width = 0; while (ptr && ptr2) { ptr2 = strchr(ptr, '\n'); if (ptr2) { w = WMWidthOfString(font, ptr, ptr2 - ptr); } else { w = WMWidthOfString(font, ptr, strlen(ptr)); } if (w > width) width = w; ptr = ptr2 + 1; } } width += 16; textHeight = W_GetTextHeight(font, text, width, False); height = textHeight + 4; if (height < 16) height = 16; if (width < height) width = height; if (x + width > scr->rootView->size.width) { side = RIGHT; bx = x - width + w / 2; if (bx < 0) bx = 0; } else { side = LEFT; bx = x + w / 2; } if (bx + width > scr->rootView->size.width) bx = scr->rootView->size.width - width; if (y - (height + SPACE) < 0) { side |= TOP; by = y + h - 1; ty = SPACE; } else { side |= BOTTOM; by = y - (height + SPACE); ty = 0; } pixmap = makePixmap(scr, width, height, side, &mask); W_PaintText(bPtr->view, pixmap, font, 8, ty + (height - textHeight) / 2, width, bPtr->flags.alignment, bPtr->textColor ? bPtr->textColor : scr->black, False, text, strlen(text)); XSetWindowBackgroundPixmap(dpy, bPtr->view->window, pixmap); W_ResizeView(bPtr->view, width, height + SPACE); XFreePixmap(dpy, pixmap); #ifdef USE_XSHAPE XShapeCombineMask(dpy, bPtr->view->window, ShapeBounding, 0, 0, mask, ShapeSet); #endif XFreePixmap(dpy, mask); W_MoveView(bPtr->view, bx, by); W_MapView(bPtr->view); }
void WMMoveWidget(WMWidget * w, int x, int y) { W_MoveView(W_VIEW(w), x, y); }