/*----------------------------------------------------------------------*/ static void AccentBottom(Widget w, GC top_gc, GC bottom_gc, Dimension offset_left, Dimension offset_right, Dimension shadow_thickness, Dimension accent_thickness, int code) { Widget pw = _XfeParent(w); int position_index = XfeMenuItemPositionIndex(w); Cardinal num_children = _XfemNumChildren(pw); Position x; Position y; Dimension width; Dimension height = 2 * shadow_thickness + accent_thickness; assert( code == ACCENT_DRAW || code == ACCENT_ERASE ); /* Last item */ if (position_index == (num_children - 1)) { x = _XfeX(w) + offset_left; y = _XfeY(w) + _XfeHeight(w) - height; width = _XfeWidth(w) - offset_left - offset_right; } /* Any other item */ else { x = _XfeX(w) + offset_left; y = _XfeY(w) + _XfeHeight(w) - height / 2; width = _XfeWidth(w) - offset_left - offset_right; } if (code == ACCENT_DRAW) { /* Draw accent */ _XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc, x,y,width,height,shadow_thickness,XmSHADOW_IN); } else { /* Erase accent */ XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc, x,y,width,height,shadow_thickness); } }
/*----------------------------------------------------------------------*/ static Position GetPointerY(Widget w) { Window root; Window child; int rx; int ry; int cx; int cy; unsigned int mask; if (XQueryPointer(XtDisplay(w),_XfeWindow(w),&root,&child, &rx,&ry,&cx,&cy,&mask)) { cy -= _XfeY(w); if (cy < 0) { cy = 0; } if (cy > _XfeHeight(w)) { cy = _XfeHeight(w); } return cy; } return 0; }
/*----------------------------------------------------------------------*/ /* extern */ void _XfeResizeWidget(Widget w,int width,int height) { assert( _XfeIsAlive(w) ); #if 0 printf("_XfeResizeWidget(%s,%d,%d)\n",XtName(w),width,height); #endif #if 0 assert( width > 0 ); assert( height > 0 ); #endif /* Ignore this request if width or height are 0 */ if (!width || !height) { return; } /* Make sure the dimension are different */ if ((_XfeWidth(w) == width) && (_XfeHeight(w) == height)) { return; } _XfeConfigureWidget(w,_XfeX(w),_XfeY(w),width,height); }
/*----------------------------------------------------------------------*/ /* 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); } }
/*----------------------------------------------------------------------*/ /* extern */ void _XfeConfigureOrHideWidget(Widget w,int x,int y,int width,int height) { assert( _XfeIsAlive(w) ); /* Make sure the widget is alive */ if (!_XfeIsAlive(w)) { return; } /* Make sure the positions and dimensions are different */ if ((_XfeX(w) == x) && (_XfeY(w) == y) && (_XfeWidth(w) == width) && (_XfeHeight(w) == height)) { return; } /* Hide the widget if its dimensions are less thanb zero */ if (!width || !height) { _XfeSetMappedWhenManaged(w,False); return; } _XfeConfigureWidget(w,x,y,width,height); /* Show the widget */ _XfeSetMappedWhenManaged(w,True); }
/*----------------------------------------------------------------------*/ /* extern */ void XfeDrawShadowsAroundWidget(Widget parent, Widget child, GC top_gc, GC bottom_gc, Dimension offset, Dimension shadow_thickness, unsigned char shadow_type) { assert( _XfeIsAlive(parent) ); assert( _XfeIsAlive(child) ); assert( shadow_thickness > 0 ); assert( XmIsManager(parent) ); _XmDrawShadows(XtDisplay(parent), _XfeWindow(parent), _XfemTopShadowGC(parent), _XfemBottomShadowGC(parent), _XfeX(child) - shadow_thickness - offset, _XfeY(child) - shadow_thickness - offset, _XfeWidth(child) + 2 * shadow_thickness + 2 * offset, _XfeHeight(child) + 2 * shadow_thickness + 2 * offset, shadow_thickness, shadow_type); }
/*----------------------------------------------------------------------*/ /* extern */ Position XfeY(Widget w) { assert( _XfeIsAlive(w) ); if (!_XfeIsAlive(w)) { return 0; } return _XfeY(w); }
/*----------------------------------------------------------------------*/ static void DrawTitleShadow(Widget w,XEvent * event,Region region,XRectangle * clip_rect) { XfeFancyBoxPart * fp = _XfeFancyBoxPart(w); XfeComboBoxPart * cp = _XfeComboBoxPart(w); /* Make sure the shadow is needed */ if (!cp->title_shadow_thickness) { return; } if (_XfeIsAlive(fp->icon)) { Dimension icon_x1 = _XfeX(fp->icon) - cp->spacing; Dimension title_x2 = _XfeX(cp->title) + _XfeWidth(cp->title); /* Draw the shadow around the icon and text */ _XmDrawShadows(XtDisplay(w), _XfeWindow(w), _XfemTopShadowGC(w),_XfemBottomShadowGC(w), CB_OFFSET_LEFT(w,cp), _XfeY(cp->title) - cp->title_shadow_thickness, (title_x2 - icon_x1) + 2 * cp->title_shadow_thickness, _XfeHeight(cp->title) + 2 * cp->title_shadow_thickness, cp->title_shadow_thickness, cp->title_shadow_type); } else { /* Draw the shadow around the text only */ XfeDrawShadowsAroundWidget(w, cp->title, _XfemTopShadowGC(w), _XfemBottomShadowGC(w), 0, cp->title_shadow_thickness, cp->title_shadow_type); } }
/*----------------------------------------------------------------------*/ static void AccentAll(Widget w, GC top_gc, GC bottom_gc, Dimension offset_left, Dimension offset_right, Dimension shadow_thickness, Dimension accent_thickness, int code) { #if 1 if (code == ACCENT_DRAW) { /* Draw accent */ _XmDrawShadows(XtDisplay(w),_XfeWindow(w), top_gc,bottom_gc, _XfeHighlightThickness(w), _XfeHighlightThickness(w), _XfeWidth(w) - 2 * _XfeHighlightThickness(w), _XfeHeight(w) - 2 * _XfeHighlightThickness(w), _XfeShadowThickness(w), XmSHADOW_OUT); } else { /* Erase accent */ XfeDrawRectangle(XtDisplay(w),_XfeWindow(w),top_gc, _XfeHighlightThickness(w), _XfeHighlightThickness(w), _XfeWidth(w) - 2 * _XfeHighlightThickness(w), _XfeHeight(w) - 2 * _XfeHighlightThickness(w), _XfeShadowThickness(w)); } #else Widget pw = _XfeParent(w); int position_index = XfeMenuItemPositionIndex(w); Cardinal num_children = _XfemNumChildren(pw); Position x; Position y; Dimension width; Dimension height; Dimension total_thickness = shadow_thickness + accent_thickness; assert( code == ACCENT_DRAW || code == ACCENT_ERASE ); /* One and only */ if (num_children == 1) { x = _XfeX(w) + offset_left; y = _XfeY(w); width = _XfeWidth(w) - offset_left - offset_right; height = _XfeHeight(w); } else { Dimension overlap = (2 * shadow_thickness + accent_thickness) / 2; /* First item */ if (position_index == 0) { x = _XfeX(w) + offset_left; y = _XfeY(w); width = _XfeWidth(w) - offset_left - offset_right; height = _XfeHeight(w) + overlap; } /* Last item */ else if (position_index == (num_children - 1)) { x = _XfeX(w) + offset_left; y = _XfeY(w) - overlap; width = _XfeWidth(w) - offset_left - offset_right; height = _XfeHeight(w) + overlap; } /* In between two others */ else { x = _XfeX(w) + offset_left; y = _XfeY(w) - overlap; width = _XfeWidth(w) - offset_left - offset_right; height = _XfeHeight(w) + 2 * total_thickness; } } if (code == ACCENT_DRAW) { /* Draw accent */ _XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc, x,y,width,height,shadow_thickness,XmSHADOW_IN); x += total_thickness; y += total_thickness; width -= (2 * total_thickness); height -= (2 * total_thickness); _XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc, x,y,width,height,shadow_thickness,XmSHADOW_OUT); } else { /* Erase accent */ XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc, x,y,width,height,shadow_thickness); x += total_thickness; y += total_thickness; width -= (2 * total_thickness); height -= (2 * total_thickness); XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc, x,y,width,height,shadow_thickness); } #endif }
/*----------------------------------------------------------------------*/ /* extern */ void _XfeConfigureWidget(Widget w,int x,int y,int width,int height) { assert( _XfeIsAlive(w) ); #if 0 printf("_XfeConfigureWidget(%s,%d,%d,%d,%d)\n",XtName(w),x,y,width,height); #endif #if 0 assert( x >= 0 ); assert( y >= 0 ); assert( width > 0 ); assert( height > 0 ); #endif /* Ignore this request if width or height are 0 */ if (!width || !height) { return; } /* Make sure the positions and dimensions are different */ if ((_XfeX(w) == x) && (_XfeY(w) == y) && (_XfeWidth(w) == width) && (_XfeHeight(w) == height)) { return; } /* Configure XfePrimitive class */ if (XfeIsPrimitive(w)) { Boolean use_preferred_height; Boolean use_preferred_width; use_preferred_width = _XfeUsePreferredWidth(w); use_preferred_height = _XfeUsePreferredHeight(w); _XfeUsePreferredWidth(w) = False; _XfeUsePreferredHeight(w) = False; XtConfigureWidget(w,x,y,width,height,_XfeBorderWidth(w)); _XfeUsePreferredWidth(w) = use_preferred_width; _XfeUsePreferredHeight(w) = use_preferred_height; } /* Configure XfeManager class */ else if (XfeIsManager(w)) { Boolean use_preferred_height; Boolean use_preferred_width; _XfemOldWidth(w) = _XfeWidth(w); _XfemOldHeight(w) = _XfeHeight(w); use_preferred_width = _XfemUsePreferredWidth(w); use_preferred_height = _XfemUsePreferredHeight(w); _XfemUsePreferredWidth(w) = False; _XfemUsePreferredHeight(w) = False; XtConfigureWidget(w,x,y,width,height,_XfeBorderWidth(w)); _XfemUsePreferredWidth(w) = use_preferred_width; _XfemUsePreferredHeight(w) = use_preferred_height; } /* Configure any other class */ else { _XmConfigureObject(w,x,y,width,height,_XfeBorderWidth(w)); } }