void reposition(Screen_Obj *sop) { #ifdef HAVE_MOTIF /* Reposition frame if it has one */ if(sop->so_frame){ XtMoveWidget(sop->so_frame, sop->so_x, sop->so_y); } else { XtMoveWidget(sop->so_obj, sop->so_x, sop->so_y); } #endif /* HAVE_MOTIF */ }
void XawViewportSetCoordinates (Widget gw, Position x, Position y) { ViewportWidget w = (ViewportWidget) gw; Widget child = w->viewport.child; Widget clip = w->viewport.clip; Position mx, my; if (x > (int) child->core.width) x = child->core.width; else if (x < 0) x = child->core.x; if (y > (int) child->core.height) y = child->core.height; else if (y < 0) y = child->core.y; mx = -x, my = -y; if (- mx + (int) clip->core.width > (int) child->core.width) mx = - (child->core.width - clip->core.width); if (- my + (int) clip->core.height > (int) child->core.height) my = - (child->core.height - clip->core.height); /* make sure we never move past left/top borders */ if (mx >= 0) mx = 0; if (my >= 0) my = 0; XtMoveWidget (child, mx, my); XtUnmanageChild (child); XtManageChild (child); }
/***** * Name: drawBalloonSquared * Return Type: void * Description: pops up the balloon widget as a simple square * In: * w: XmBalloon Widget id; * x: absolute x popup position; * y: absolute y popup position; * width: desired widget width; * Returns: * nothing *****/ static void drawBalloonSquared(Widget w, Position x, Position y, int width) { XmBalloonWidget balloon = (XmBalloonWidget)w; Display *dpy = XtDisplay(w); /* resize to fit */ XtResizeWidget((Widget)balloon, 2*ATTR(margin_width) + width, 2*ATTR(margin_height) + ATTR(font_height), balloon->core.border_width); /* move to correct location */ XtMoveWidget(w, x + ATTR(left_offset), y + ATTR(top_offset)); /***** * pop it up. * Note that the label can change when the widget is already popped. *****/ if(!ATTR(popped)) XtPopup((Widget)balloon, XtGrabNone); ATTR(popped) = True; /* do a FillRect to clear current label */ XSetForeground(dpy, ATTR(gc), balloon->core.background_pixel); XFillRectangle(dpy, XtWindow((Widget)balloon), ATTR(gc), 0, 0, balloon->core.width, balloon->core.height); XSetForeground(dpy, ATTR(gc), ATTR(foreground)); /* draw the text in the window */ drawText(dpy, balloon, XtWindow((Widget)balloon), ATTR(gc), 0, 0); }
/*----------------------------------------------------------------------*/ /* extern */ void _XfeMoveWidget(Widget w,int x,int y) { assert( _XfeIsAlive(w) ); #if 0 printf("_XfeMoveWidget(%s,%d,%d)\n",XtName(w),width,height); #endif #if 0 assert( x >= 0 ); assert( y >= 0 ); #endif /* Make sure the positions are different */ if ((_XfeX(w) == x) && (_XfeY(w) == y)) { return; } /* Configure XfePrimitive or XfeManager classes */ if (XfeIsPrimitive(w) || XfeIsManager(w)) { XtMoveWidget(w,x,y); } /* Configure any other class */ else { _XmMoveObject(w,x,y); } }
/* * Don't look kids, this function is being naughty under the covers. * * There is some overlap between this and the scrolling for the mgvScroll * action but that can't really be helped without making more mess. */ static void pan(MGV *m, int dx, int dy) { WL_SBV h, v; Widget hw = NULL; Widget vw = NULL; Position x, y; Arg a[2]; Cardinal n; hw = wl_getsbvalues(m->main, "*view*HorScrollBar", &h); if(h.value + dx < h.min) dx = h.min - h.value; else if(h.value + dx > h.max - h.slider) dx = h.max - h.slider - h.value; vw = wl_getsbvalues(m->main, "*view*VertScrollBar", &v); if(v.value + dy < v.min) dy = v.min - v.value; else if(v.value + dy > v.max - v.slider) dy = v.max - v.slider - v.value; h.value += dx; v.value += dy; wl_setsbvalues(hw, &h, False); wl_setsbvalues(vw, &v, False); n = 0; XtSetArg(a[n], XmNx, &x); ++n; XtSetArg(a[n], XmNy, &y); ++n; wlGetValues(m->ghost, a, n); XtMoveWidget(m->ghost, x - dx, y - dy); }
static void XawViewportChangeManaged(Widget widget) { ViewportWidget w = (ViewportWidget)widget; int num_children = w->composite.num_children; Widget child, *childP; int i; child = NULL; for (childP = w->composite.children, i = 0; i < num_children; childP++, i++) { if (XtIsManaged(*childP) && *childP != w->viewport.clip && *childP != w->viewport.horiz_bar && *childP != w->viewport.vert_bar) { child = *childP; break; } } if (child != w->viewport.child) { w->viewport.child = child; if (child != NULL) { XtResizeWidget(child, XtWidth(child), XtHeight(child), 0); if (XtIsRealized(widget)) { ViewportConstraints constraints = (ViewportConstraints)child->core.constraints; if (!XtIsRealized(child)) { Window window = XtWindow(w); XtMoveWidget(child, 0, 0); w->core.window = XtWindow(w->viewport.clip); XtRealizeWidget(child); w->core.window = window; constraints->viewport.reparented = True; } else if (!constraints->viewport.reparented) { XReparentWindow(XtDisplay(w), XtWindow(child), XtWindow(w->viewport.clip), 0, 0); constraints->viewport.reparented = True; if (child->core.mapped_when_managed) XtMapWidget(child); } } GetGeometry(widget, XtWidth(child), XtHeight(child)); (*((ViewportWidgetClass)w->core.widget_class)->form_class.layout) ((FormWidget)w, XtWidth(w), XtHeight(w), True /* True? */); } } #ifdef notdef (*Superclass->composite_class.change_managed)(widget); #endif }
static void Layout(Widget w) { ScrollByLineWidget sblw = (ScrollByLineWidget) w; Dimension width, height; Widget bar; Position bar_bw; CreateScrollbar(w); /* * For now always show the bar. */ bar = sblw->scroll.bar; height = sblw->core.height; width = sblw->core.width; bar_bw = bar->core.border_width; /* Move child and v_bar to correct location. */ if (sblw->scroll.use_right) { XtMoveWidget(bar, width - (bar->core.width + bar_bw), - bar_bw); sblw->scroll.offset = 0; } else { XtMoveWidget(bar, - bar_bw, - bar_bw); sblw->scroll.offset = bar->core.width + bar_bw; } /* resize the scrollbar to be the correct height or width. */ XtResizeWidget(bar, bar->core.width, height, bar->core.border_width); SetThumbHeight(w); sblw->scroll.num_visible_lines = height / sblw->scroll.font_height + 1; }
/*!\reimp */ void KXtWidget::moveEvent( QMoveEvent* ) { if ( xtparent ) return; XConfigureEvent c; c.type = ConfigureNotify; c.event = winId(); c.window = winId(); c.x = x(); c.y = y(); c.width = width(); c.height = height(); c.border_width = 0; XSendEvent( qt_xdisplay(), c.event, TRUE, NoEventMask, (XEvent*)&c ); XtMoveWidget( xtw, x(), y() ); }
/* * Function: * ResizeChildren * * Parameters: * w - form widget * * Description: * Resizes all children to new_x and new_y. */ static void ResizeChildren(Widget w) { FormWidget fw = (FormWidget)w; int num_children = fw->composite.num_children; WidgetList children = fw->composite.children; Widget *childP; for (childP = children; childP - children < num_children; childP++) { FormConstraints form; Position x, y; if (!XtIsManaged(*childP)) continue; form = (FormConstraints)(*childP)->core.constraints; if (fw->form.old_width && fw->form.old_height) { x = TransformCoord(form->form.new_x, fw->form.old_width, XtWidth(fw), form->form.left); y = TransformCoord(form->form.new_y, fw->form.old_height, XtHeight(fw), form->form.top); } else { x = form->form.new_x; y = form->form.new_y; } if (fw->form.no_refigure) { /* * I am changing the widget wrapper w/o modifing the window. This is * risky, but I can get away with it since I am the parent of this * widget, and he must ask me for any geometry changes * * The window will be updated when no_refigure is set back to False */ XtX(*childP) = x; XtY(*childP) = y; } else XtMoveWidget(*childP, x, y); } }
void XSilChessWindow::UpdateMovesList() { XmString xms; Widget clpwin,scrbar; char * buf, * p; int i,smax,ssiz; Position x,y; Dimension h,hc; buf=(char*)malloc(65536); p=buf; for (i=0; i<Machine->GetMoveCount(); i++) { if ((i&1)==0) p+=sprintf(p,"%03d",i/2+1); *p++=' '; Machine->GetMove(i).ToString(p); p+=4; if ((i&1)!=0 || i==Machine->GetMoveCount()-1) *p++='\n'; } *p=0; if (p==buf) strcpy(buf,"<empty>"); xms=XmStringCreateLtoR(buf,XmFONTLIST_DEFAULT_TAG); free(buf); XtVaSetValues(LDList,XmNlabelString,xms,(char*)NULL); XmStringFree(xms); // Make last entry visible clpwin=NULL; XtVaGetValues(LDScroll,XmNclipWindow,&clpwin,(char*)NULL); if (clpwin) { XtVaGetValues(LDList,XmNx,&x,XmNy,&y,XmNheight,&h,(char*)NULL); XtVaGetValues(clpwin,XmNheight,&hc,(char*)NULL); if (((Position)hc-h)<y) { XtMoveWidget(LDList,x,hc-h); scrbar=NULL; XtVaGetValues(LDScroll,XmNverticalScrollBar,&scrbar,(char*)NULL); if (scrbar) { XtVaGetValues(scrbar,XmNmaximum,&smax,XmNsliderSize,&ssiz,(char*)NULL); XtVaSetValues(scrbar,XmNvalue,smax-ssiz,(char*)NULL); } } } }
static void XawViewportRealize(Widget widget, XtValueMask *value_mask, XSetWindowAttributes *attributes) { ViewportWidget w = (ViewportWidget)widget; Widget child = w->viewport.child; Widget clip = w->viewport.clip; *value_mask |= CWBitGravity; attributes->bit_gravity = NorthWestGravity; (*Superclass->core_class.realize)(widget, value_mask, attributes); (*w->core.widget_class->core_class.resize)(widget); /* turn on bars */ if (child != NULL) { XtMoveWidget(child, 0, 0); XtRealizeWidget(clip); XtRealizeWidget(child); XReparentWindow(XtDisplay(w), XtWindow(child), XtWindow(clip), 0, 0); XtMapWidget(child); } }
void iupmotSetPosition(Widget widget, int x, int y) { /* avoid setting both at the same time, so if one is invalid all will fail */ XtVaSetValues(widget, XmNx, (XtArgVal)x, NULL); XtVaSetValues(widget, XmNy, (XtArgVal)y, NULL); /* to position ouside parent area */ { int new_x, new_y; XtVaGetValues(widget, XmNx, &new_x, XmNy, &new_y, NULL); if (x!=new_x || y!=new_y) XtMoveWidget(widget, x, y); } }
static void set_positions(TreeWidget tw, Widget w, int level) { int i; if (w) { TreeConstraints tc = TREE_CONSTRAINT(w); if (level > 0) { /* * mirror if necessary */ switch (tw->tree.gravity) { case EastGravity: tc->tree.x = (((Position) tw->tree.maxwidth) - ((Position) w->core.width) - tc->tree.x); break; case SouthGravity: tc->tree.y = (((Position) tw->tree.maxheight) - ((Position) w->core.height) - tc->tree.y); break; } /* * Move the widget into position. */ XtMoveWidget (w, tc->tree.x, tc->tree.y); } /* * Set the positions of all children. */ for (i = 0; i < tc->tree.n_children; i++) set_positions (tw, tc->tree.children[i], level + 1); } }
static void MoveChild(ViewportWidget w, int x, int y) { Widget child = w->viewport.child; Widget clip = w->viewport.clip; /* make sure we never move past right/bottom borders */ if (-x + (int)XtWidth(clip) > XtWidth(child)) x = -(int)(XtWidth(child) - XtWidth(clip)); if (-y + (int)XtHeight(clip) > XtHeight(child)) y = -(int)(XtHeight(child) - XtHeight(clip)); /* make sure we never move past left/top borders */ if (x >= 0) x = 0; if (y >= 0) y = 0; XtMoveWidget(child, x, y); SendReport(w, (XawPRSliderX | XawPRSliderY)); RedrawThumbs(w); }
static void SetGeometry (Widget w, String geometry, Position * x, Position * y) { int x_return, y_return; unsigned int width_return, height_return; long flags; flags = XParseGeometry (geometry, &x_return, &y_return, &width_return, &height_return); if (flags) { if (flags & XValue) *x = (Position) x_return; if (flags & XNegative) *x = (Position) (WidthOfScreen (XtScreen (w)) - XtWidth(w)) + x_return; if (flags & YValue) *y = (Position) y_return; if (flags & YNegative) { *y = (Position) (HeightOfScreen (XtScreen (w)) - XtHeight(w)) + y_return; } if (flags & XValue || flags & YValue || flags & XNegative || flags & YNegative) { XtMoveWidget (w, *x, *y); } } }
static void DoLayout(Widget w, Boolean doit) { ScrollBoxWidget sbw = (ScrollBoxWidget)w; Widget wmain, vscroll, hscroll, child; Dimension mw, mh; /* main window */ Dimension vh; /* vertical scrollbar length (height) */ Dimension hw; /* horizontal scrollbar length (width) */ Position vx; Position hy; Cardinal i; if (sbw->composite.num_children != 3) XtAppError(XtWidgetToApplicationContext(w), "ScrollBox: must manage exactly three widgets."); for (i = 0; i < sbw->composite.num_children; i++) { child = sbw->composite.children[i]; if (!XtIsManaged(child)) XtAppError(XtWidgetToApplicationContext(w), "ScrollBox: all three widgets must be managed."); } /* Child one is the main window, two is the vertical scrollbar, and three is the horizontal scrollbar. */ wmain = sbw->composite.children[0]; vscroll = sbw->composite.children[1]; hscroll = sbw->composite.children[2]; /* Size all three widgets so that space is fully utilized. */ mw = sbw->core.width - (2 * sbw->scrollBox.h_space) - vscroll->core.width - (2 * vscroll->core.border_width) - (2 * wmain->core.border_width); mh = sbw->core.height - (2 * sbw->scrollBox.v_space) - hscroll->core.height - (2 * hscroll->core.border_width) - (2 * wmain->core.border_width); /* Force the main window to be sized to the appropriate increment. */ mw = (mw / sbw->scrollBox.increment_width) * sbw->scrollBox.increment_width; mh = ((mh / sbw->scrollBox.increment_height) * sbw->scrollBox.increment_height) + sbw->scrollBox.increment_height; vx = wmain->core.x + mw + sbw->scrollBox.h_space + wmain->core.border_width + vscroll->core.border_width; hy = wmain->core.y + mh + sbw->scrollBox.v_space + wmain->core.border_width + hscroll->core.border_width; vh = mh; /* scrollbars are always same length as main window */ hw = mw; if (doit) { XtResizeWidget(wmain, mw, mh, 1); XtResizeWidget(vscroll, vscroll->core.width, vh, 1); XtMoveWidget(vscroll, vx, vscroll->core.y); XtResizeWidget(hscroll, hw, hscroll->core.height, 1); XtMoveWidget(hscroll, hscroll->core.x, hy); } }
static void ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars) { ViewportWidget w = (ViewportWidget)widget; Widget child = w->viewport.child; Widget clip = w->viewport.clip; ViewportConstraints constraints = (ViewportConstraints)clip->core.constraints; Bool needshoriz, needsvert; int clip_width, clip_height; XtWidgetGeometry intended; if (child == NULL) return; clip_width = XtWidth(w); clip_height = XtHeight(w); intended.request_mode = CWBorderWidth; intended.border_width = 0; if (w->viewport.forcebars) { needsvert = w->viewport.allowvert; needshoriz = w->viewport.allowhoriz; ComputeWithForceBars(widget, query, &intended, &clip_width, &clip_height); } else { Dimension prev_width, prev_height; XtGeometryMask prev_mode; XtWidgetGeometry preferred; needshoriz = needsvert = False; /* * intended.{width,height} caches the eventual child dimensions, * but we don't set the mode bits until after we decide that the * child's preferences are not acceptable */ if (!w->viewport.allowhoriz) intended.request_mode |= CWWidth; if (XtWidth(child) < clip_width) intended.width = clip_width; else intended.width = XtWidth(child); if (XtHeight(child) < clip_height) intended.height = clip_height; else intended.height = XtHeight(child); if (!w->viewport.allowvert) intended.request_mode |= CWHeight; if (!query) { preferred.width = XtWidth(child); preferred.height = XtHeight(child); } do { /* while intended != prev */ if (query) { (void)XtQueryGeometry(child, &intended, &preferred); if (!(preferred.request_mode & CWWidth)) preferred.width = intended.width; if (!(preferred.request_mode & CWHeight)) preferred.height = intended.height; } prev_width = intended.width; prev_height = intended.height; prev_mode = intended.request_mode; /* * note that having once decided to turn on either bar * we'll not change our mind until we're next resized, * thus avoiding potential oscillations */ #define CheckHoriz() \ if (w->viewport.allowhoriz && \ preferred.width > clip_width) { \ if (!needshoriz) { \ Widget bar; \ \ needshoriz = True; \ if ((bar = w->viewport.horiz_bar) == NULL) \ bar = CreateScrollbar(w, True); \ clip_height -= XtHeight(bar) + XtBorderWidth(bar); \ if (clip_height < 1) \ clip_height = 1; \ } \ intended.width = preferred.width; \ } CheckHoriz(); if (w->viewport.allowvert && preferred.height > clip_height) { if (!needsvert) { Widget bar; needsvert = True; if ((bar = w->viewport.vert_bar) == NULL) bar = CreateScrollbar(w, False); clip_width -= XtWidth(bar) + XtBorderWidth(bar); if (clip_width < 1) clip_width = 1; CheckHoriz(); } intended.height = preferred.height; } if (!w->viewport.allowhoriz || preferred.width < clip_width) { intended.width = clip_width; intended.request_mode |= CWWidth; } if (!w->viewport.allowvert || preferred.height < clip_height) { intended.height = clip_height; intended.request_mode |= CWHeight; } } while (intended.request_mode != prev_mode || (intended.request_mode & CWWidth && intended.width != prev_width) || (intended.request_mode & CWHeight && intended.height != prev_height)); } if (XtIsRealized(clip)) XRaiseWindow(XtDisplay(clip), XtWindow(clip)); XtMoveWidget(clip, needsvert ? w->viewport.useright ? 0 : XtWidth(w->viewport.vert_bar) + XtBorderWidth(w->viewport.vert_bar) : 0, needshoriz ? w->viewport.usebottom ? 0 : XtHeight(w->viewport.horiz_bar) + XtBorderWidth(w->viewport.horiz_bar) : 0); XtResizeWidget(clip, clip_width, clip_height, 0); if (w->viewport.horiz_bar != NULL) { Widget bar = w->viewport.horiz_bar; if (!needshoriz) { constraints->form.vert_base = NULL; if (destroy_scrollbars) { XtDestroyWidget(bar); w->viewport.horiz_bar = NULL; } } else { int bw = XtBorderWidth(bar); XtResizeWidget(bar, clip_width, XtHeight(bar), bw); XtMoveWidget(bar, needsvert && !w->viewport.useright ? XtWidth(w->viewport.vert_bar) : -bw, w->viewport.usebottom ? XtHeight(w) - XtHeight(bar) - bw : -bw); XtSetMappedWhenManaged(bar, True); } } if (w->viewport.vert_bar != NULL) { Widget bar = w->viewport.vert_bar; if (!needsvert) { constraints->form.horiz_base = NULL; if (destroy_scrollbars) { XtDestroyWidget(bar); w->viewport.vert_bar = NULL; } } else { int bw = bar->core.border_width; XtResizeWidget(bar, XtWidth(bar), clip_height, bw); XtMoveWidget(bar, w->viewport.useright ? XtWidth(w) - XtWidth(bar) - bw : -bw, needshoriz && !w->viewport.usebottom ? XtHeight(w->viewport.horiz_bar) : -bw); XtSetMappedWhenManaged(bar, True); } } if (child != NULL) { XtResizeWidget(child, intended.width, intended.height, 0); MoveChild(w, needshoriz ? XtX(child) : 0, needsvert ? XtY(child) : 0); } SendReport (w, XawPRAll); }
/***** * Name: drawBalloonShaped * Return Type: void * Description: pops up the balloon widget as a shaped window * In: * w: XmBalloon Widget id; * x: absolute x popup position; * y: absolute y popup position; * width: desired widget width; * Returns: * nothing * Note: * This routine composes a *clipmask* for the widget to use when * it is displayed. The clipmask is initially empty and gets filled * according to the selected options. Once it is filled, the text * is rendered in the selected color. *****/ static void drawBalloonShaped(Widget w, Position x, Position y, int width) { BALLOON = (XmBalloonWidget)w; XGCValues xgc; int face_width, face_height, x_offset, y_offset; Dimension bwidth, bheight; Pixmap shape_mask; Display *dpy = XtDisplay(w); Window win = XtWindow(w); /* horizontal offset for text rendering */ x_offset = ATTR(margin_width) + ATTR(font_width); y_offset = 0.25 * ATTR(font_height); bwidth = 2*ATTR(margin_width) + width + 2*x_offset; bheight = 2*ATTR(margin_height) + ATTR(font_height) + 2*y_offset; /* resize to fit */ XtResizeWidget(w, bwidth, bheight, balloon->core.border_width); /* compute desired border size */ setTransform(&ATTR(maskt), 0, bwidth, bheight, 0, -1.0, 1.0, -1.0, 1.0); face_width = abs(Xwidth(BORDER_SIZE(balloon), BORDER_SIZE(balloon), &(ATTR(maskt)))); face_height = abs(Xheight(BORDER_SIZE(balloon), BORDER_SIZE(balloon), &(ATTR(maskt)))); setTransform(&ATTR(t), face_width, bwidth - face_width, bheight - face_height, face_height, -WINDOW_WIDTH(balloon)/2, WINDOW_WIDTH(balloon)/2, -WINDOW_HEIGHT(balloon)/2, WINDOW_HEIGHT(balloon)/2); /* Free up previous clipmask if the size differs */ if(ATTR(shape_mask) && ATTR(shape_width) != w->core.width && ATTR(shape_height) != w->core.height) { XFreePixmap(dpy, ATTR(shape_mask)); ATTR(shape_mask) = None; } /* allocate a clipmask (bitmap of depth one) */ if(!(ATTR(shape_mask))) { ATTR(shape_mask) = XCreatePixmap(dpy, win, bwidth, bheight, 1); ATTR(shape_width) = bwidth; ATTR(shape_height) = bheight; } shape_mask = ATTR(shape_mask); /* simple gc */ if(!(ATTR(shape_gc))) ATTR(shape_gc) = XCreateGC(dpy, shape_mask, 0, &xgc); /* make it fully transparent */ XSetForeground(dpy, ATTR(shape_gc), 0); XFillRectangle(dpy, shape_mask, ATTR(shape_gc), 0, 0, bwidth, bheight); XSetForeground(dpy, ATTR(shape_gc), 1); /***** * Fill in the border bits if we have a border. If we aren't transparent * a filled arc is created. *****/ if(ATTR(border_size) > 0.0 || !ATTR(transparent)) { FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(maskt)), -1.0, -1.0, 2.0, 2.0, 0, 360*64); } /***** * if we are being transparent, erase the inner part of the disk * and fill the bits for the text. If we aren't transparent we don't * have to do this 'cause the bits set for the disk already cover the * bits that cover the text. *****/ if(ATTR(transparent)) { if(ATTR(border_size) > 0.0) { XSetForeground(dpy, ATTR(shape_gc), 0); FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(maskt)), -WINDOW_WIDTH(balloon)/2, -WINDOW_HEIGHT(balloon)/2, WINDOW_WIDTH(balloon), WINDOW_HEIGHT(balloon), 0, 360*64); XSetForeground(dpy, ATTR(shape_gc), 1); } drawText(dpy, balloon, shape_mask, ATTR(shape_gc), x_offset, y_offset); } /* the highest enclosing widget is the widget itself */ XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, shape_mask, ShapeSet); /* erase clipmask */ XSetForeground(dpy, ATTR(shape_gc), 0); XFillRectangle(dpy, shape_mask, ATTR(shape_gc), 0, 0, bwidth, bheight); XSetForeground(dpy, ATTR(shape_gc), 1); /* draw clip shape */ if(ATTR(transparent)) { drawText(dpy, balloon, shape_mask, ATTR(shape_gc), x_offset, y_offset); } else { FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(t)), -WINDOW_WIDTH(balloon)/2, -WINDOW_HEIGHT(balloon)/2, WINDOW_WIDTH(balloon), WINDOW_HEIGHT(balloon), 0, 360*64); } /* compose final clipmask */ XShapeCombineMask(dpy, win, ShapeClip, 0, 0, shape_mask, ShapeSet); /* move to correct location */ XtMoveWidget((Widget)balloon, x + 4, y + 4); /***** * pop it up. * Note that the label can change when the widget is already popped. *****/ if(!ATTR(popped)) XtPopup((Widget)balloon, XtGrabNone); ATTR(popped) = True; /* draw the text */ drawText(dpy, balloon, win, ATTR(gc), x_offset, y_offset); /* if we have got a popdown timeout, add it */ if(ATTR(popdown_delay)) { ATTR(popdown_id) = XtAppAddTimeOut(ATTR(context), ATTR(popdown_delay), popdownBalloon, (XtPointer)balloon); } }
/*############################ resize_window() #########################*/ signed char resize_window(void) { static int old_long_window_height = -1, old_short_window_height = -1; int long_window_height, ret, short_window_height; Arg args[2]; Cardinal argcount; if (window_size(&window_width, &window_height) == YES) { #ifdef _AUTO_REPOSITION XWindowAttributes window_attrib; int display_width, display_height, new_x, new_y; Position root_x, root_y; #endif static int old_line_height = 0; #ifdef _AUTO_REPOSITION /* Get new window position. */ display_width = DisplayWidth(display, DefaultScreen(display)); display_height = DisplayHeight(display, DefaultScreen(display)); XGetWindowAttributes(display, XtWindow(appshell), &window_attrib); /* Translate coordinates relative to root window. */ XtTranslateCoords(appshell, window_attrib.x, window_attrib.y, &root_x, &root_y); /* Change x coordinate. */ if ((root_x + window_width) > display_width) { new_x = display_width - window_width; /* Is window wider then display? */ if (new_x < 0) { new_x = 0; } } else { new_x = root_x; } /* Change y coordinate. */ if ((root_y + window_height + 23) > display_height) { new_y = display_height - window_height; /* Is window wider then display? */ if (new_y < 23) { new_y = 23; } } else { new_y = root_y; } /* Resize window. */ XtVaSetValues(appshell, XmNminWidth, window_width, XmNmaxWidth, window_width, XmNminHeight, window_height + line_height + line_height + glyph_height + magic_value, XmNmaxHeight, window_height + line_height + line_height + glyph_height + magic_value, NULL); XMoveResizeWindow(display, XtWindow(appshell), new_x, new_y, window_width, window_height + line_height + line_height + glyph_height + magic_value); #else XtVaSetValues(appshell, XmNminWidth, window_width, XmNmaxWidth, window_width, XmNminHeight, window_height + line_height + line_height + glyph_height + magic_value, XmNmaxHeight, window_height + line_height + line_height + glyph_height + magic_value, NULL); XResizeWindow(display, XtWindow(appshell), window_width, window_height + line_height + line_height + glyph_height + magic_value); #endif /* If the line_height changed, don't forget to change the */ /* height of the label and button window! */ argcount = 0; XtSetArg(args[argcount], XmNwidth, (Dimension)window_width); argcount++; long_window_height = no_of_rows * line_height; if (long_window_height != old_long_window_height) { XtSetArg(args[argcount], XmNheight, (Dimension)long_window_height); argcount++; old_long_window_height = long_window_height; } XtSetValues(line_window_w, args, argcount); argcount = 0; XtSetArg(args[argcount], XmNwidth, (Dimension)window_width); argcount++; short_window_height = no_of_short_rows * line_height; if (short_window_height != old_short_window_height) { XtSetArg(args[argcount], XmNheight, (Dimension)(short_window_height)); argcount++; old_short_window_height = short_window_height; } XtSetValues(short_line_window_w, args, argcount); argcount = 0; XtSetArg(args[argcount], XmNwidth, (Dimension)window_width); argcount++; if (line_height != old_line_height) { XtSetArg(args[argcount], XmNheight, (Dimension)line_height); argcount++; old_line_height = line_height; } XtSetValues(label_window_w, args, argcount); XtSetValues(button_window_w, args, argcount); ret = YES; } else { long_window_height = no_of_rows * line_height; if (long_window_height != old_long_window_height) { argcount = 0; XtSetArg(args[argcount], XmNheight, (Dimension)long_window_height); argcount++; XtSetValues(line_window_w, args, argcount); XtResizeWidget(line_window_w, window_width, long_window_height, 0); } short_window_height = (no_of_short_rows * line_height) + 1; if (short_window_height != old_short_window_height) { argcount = 0; XtSetArg(args[argcount], XmNheight, (Dimension)(short_window_height)); argcount++; XtSetValues(short_line_window_w, args, argcount); XtResizeWidget(short_line_window_w, window_width, short_window_height, 0); } if ((old_long_window_height != -1) && (old_short_window_height != -1)) { if (short_line_window_w->core.y != (line_window_w->core.y + long_window_height)) { XtMoveWidget(short_line_window_w, short_line_window_w->core.x, line_window_w->core.y + long_window_height); } } old_long_window_height = long_window_height; old_short_window_height = short_window_height; ret = NO; } return(ret); }
void xaw_pop_instance (widget_instance *instance, Boolean up) { Widget widget = instance->widget; if (up) { #ifdef LWLIB_DIALOGS_ATHENA if (XtIsSubclass (widget, dialogWidgetClass)) { /* For dialogs, we need to call XtPopup on the parent instead of calling XtManageChild on the widget. Also we need to hack the shell's WM_PROTOCOLS to get it to understand what the close box is supposed to do!! */ Display *dpy = XtDisplay (widget); Widget shell = XtParent (widget); Atom props [2]; int i = 0; props [i++] = XInternAtom (dpy, "WM_DELETE_WINDOW", False); XChangeProperty (dpy, XtWindow (shell), XInternAtom (dpy, "WM_PROTOCOLS", False), XA_ATOM, 32, PropModeAppend, (unsigned char *) props, i); /* Center the widget in its parent. Why isn't this kind of crap done automatically? I thought toolkits were supposed to make life easier? */ { unsigned int x, y, w, h; Widget topmost = instance->parent; w = shell->core.width; h = shell->core.height; while (topmost->core.parent && XtIsRealized (topmost->core.parent) && /* HAVE_SESSION adds an unmapped parent widget that we should ignore here. */ topmost->core.parent->core.mapped_when_managed) topmost = topmost->core.parent; if (topmost->core.width < w) x = topmost->core.x; else x = topmost->core.x + ((topmost->core.width - w) / 2); if (topmost->core.height < h) y = topmost->core.y; else y = topmost->core.y + ((topmost->core.height - h) / 2); XtMoveWidget (shell, x, y); } /* Finally, pop it up. */ XtPopup (shell, XtGrabNonexclusive); } else #endif /* LWLIB_DIALOGS_ATHENA */ XtManageChild (widget); } else { #ifdef LWLIB_DIALOGS_ATHENA if (XtIsSubclass (widget, dialogWidgetClass)) XtUnmanageChild (XtParent (widget)); else #endif XtUnmanageChild (widget); } }