static Dimension GetWidth(Widget w) { Dimension min_width; Dimension width; /* Compute the min possible width */ min_width = 2 * _XfeHighlightThickness(w) + 2 * _XfeShadowThickness(w); /* A reasonable preferred width is needed */ assert( _XfePreferredWidth(w) > 0 ); assert( _XfePreferredWidth(w) >= min_width ); /* Force the preferred width if needed */ if (_XfeUsePreferredWidth(w) || (_XfeWidth(w) == XfeDEFAULT_PREFERRED_WIDTH) || (_XfeWidth(w) <= min_width)) { width = _XfePreferredWidth(w); } else { width = _XfeWidth(w); } return width; }
/*----------------------------------------------------------------------*/ static void Resize(Widget w) { /*printf("%s: Resize to (%d,%d)\n",XtName(w),_XfeWidth(w),_XfeHeight(w));*/ /* Obtain the Prefered Geometry */ _XfePrimitivePreferredGeometry(w, &_XfePreferredWidth(w), &_XfePreferredHeight(w)); /* Force the preferred dimensions if required */ if (_XfeUsePreferredWidth(w)) { _XfeWidth(w) = _XfePreferredWidth(w); } if (_XfeUsePreferredHeight(w)) { _XfeHeight(w) = _XfePreferredHeight(w); } /* Update the widget rect */ _XfePrimitiveUpdateRect(w); /* Layout the components */ _XfePrimitiveLayoutComponents(w); switch(_XfeBufferType(w)) { /* No buffer: nothing */ case XmBUFFER_NONE: break; /* Single buffer: update the buffer size and contents */ case XmBUFFER_PRIVATE: BufferUpdate(w); _XfePrimitiveDrawEverything(w,NULL,NULL); break; /* Multiple buffer: update the buffer size only */ case XmBUFFER_SHARED: BufferUpdate(w); break; } /* Invoke Resize Callbacks */ _XfeInvokeCallbacks(w,_XfeResizeCallbacks(w),XmCR_RESIZE,NULL,True); }
/*----------------------------------------------------------------------*/ /* extern */ void _XfePreferredGeometry(Widget w,Dimension *width_out,Dimension *height_out) { Dimension width; Dimension height; assert( _XfeIsAlive(w) ); if (XfeIsPrimitive(w)) { width = _XfePreferredWidth(w); height = _XfePreferredHeight(w); } else if (XfeIsManager(w)) { width = _XfemPreferredWidth(w); height = _XfemPreferredHeight(w); } else { XtWidgetGeometry reply; XtQueryGeometry(w,NULL,&reply); if (reply.request_mode & CWWidth) { width = reply.width; } else { width = _XfeWidth(w); } if (reply.request_mode & CWHeight) { height = reply.height; } else { height = _XfeHeight(w); } } if (width_out) { *width_out = width; } if (height_out) { *height_out = height; } }
/*----------------------------------------------------------------------*/ static void InitializePostHook(Widget rw,Widget nw) { /* Set preparation flag so that all components get prepared */ _XfePrepareFlags(nw) = XfePrepareAll; /* Prepare the Widget */ _XfePrimitivePrepareComponents(nw,_XfePrepareFlags(nw)); /* Obtain the preferred dimensions for the first time. */ _XfePrimitivePreferredGeometry(nw, &_XfePreferredWidth(nw), &_XfePreferredHeight(nw)); /* Set the new dimensions */ _XfeWidth(nw) = GetWidth(nw); _XfeHeight(nw) = GetHeight(nw); /* Update the widget rect */ _XfePrimitiveUpdateRect(nw); /* Layout the Widget */ _XfePrimitiveLayoutComponents(nw); switch(_XfeBufferType(nw)) { /* No buffer: nothing */ case XmBUFFER_NONE: break; /* Single buffer: update the buffer size and contents */ case XmBUFFER_PRIVATE: BufferUpdate(nw); _XfePrimitiveDrawEverything(nw,NULL,NULL); break; /* Multiple buffer: update the buffer size only */ case XmBUFFER_SHARED: BufferUpdate(nw); break; } /* Dont need to prepare components any more */ _XfePrepareFlags(nw) = XfePrepareNone; }
/*----------------------------------------------------------------------*/ static Boolean SetValuesPostHook(Widget ow,Widget rw,Widget nw) { Boolean result = False; /* Prepare the widget components if needed */ if (_XfePrepareFlags(nw)) { _XfePrimitivePrepareComponents(nw,_XfePrepareFlags(nw)); } /* Update the widget's geometry if needed */ if (_XfeConfigFlags(nw) & XfeConfigGeometry) { /* Obtain the preferred dimensions */ _XfePrimitivePreferredGeometry(nw, &_XfePreferredWidth(nw), &_XfePreferredHeight(nw)); /* Set the new dimensions */ _XfeWidth(nw) = GetWidth(nw); _XfeHeight(nw) = GetHeight(nw); } /* Update the widget rect */ _XfePrimitiveUpdateRect(nw); /* Layout the Widget if needed */ if (_XfeConfigFlags(nw) & XfeConfigLayout) { _XfePrimitiveLayoutComponents(nw); switch(_XfeBufferType(nw)) { /* No buffer: nothing */ case XmBUFFER_NONE: break; /* Single buffer: update the buffer size and contents */ case XmBUFFER_PRIVATE: BufferUpdate(nw); _XfePrimitiveDrawEverything(nw,NULL,NULL); break; /* Multiple buffer: update the buffer size only */ case XmBUFFER_SHARED: BufferUpdate(nw); break; } } /* Draw everything (into the buffer) */ if (_XfeBufferType(nw) != XmBUFFER_NONE) { if ((_XfeConfigFlags(nw) & XfeConfigLayout) || (_XfeConfigFlags(nw) & XfeConfigExpose)) { /* Redraw the buffer */ _XfePrimitiveDrawEverything(nw,NULL,NULL); /* Draw the buffer onto the window */ XfeExpose(nw,NULL,NULL); } } else { result = (_XfeConfigFlags(nw) & XfeConfigExpose); } return result; }
/*----------------------------------------------------------------------*/ static Boolean SetValues(Widget ow,Widget rw,Widget nw,ArgList args,Cardinal *nargs) { /* Reset the configuration Flags */ _XfeConfigFlags(nw) = XfeConfigNone; /* Reset the preparation Flags */ _XfePrepareFlags(nw) = XfePrepareNone; /* buffer_type */ if (_XfeBufferType(nw) != _XfeBufferType(ow)) { _XfeBufferType(nw) = _XfeBufferType(ow); _XfeWarning(nw,MESSAGE7); } /* preferred_height */ if (_XfePreferredHeight(nw) != _XfePreferredHeight(ow)) { _XfePreferredHeight(nw) = _XfePreferredHeight(ow); _XfeWarning(nw,MESSAGE2); } /* preferred_width */ if (_XfePreferredWidth(nw) != _XfePreferredWidth(ow)) { _XfePreferredWidth(nw) = _XfePreferredWidth(ow); _XfeWarning(nw,MESSAGE3); } /* pointer_inside */ if (_XfePointerInside(nw) != _XfePointerInside(ow)) { _XfePointerInside(nw) = _XfePointerInside(ow); _XfeWarning(nw,MESSAGE4); } /* num_popups */ if (_XfeNumPopups(nw) != _XfeNumPopups(ow)) { _XfeNumPopups(nw) = _XfeNumPopups(ow); _XfeWarning(nw,MESSAGE5); } /* popup_list */ if (_XfePopupList(nw) != _XfePopupList(ow)) { _XfePopupList(nw) = _XfePopupList(ow); _XfeWarning(nw,MESSAGE6); } /* resize_width */ if (_XfeUsePreferredWidth(nw) != _XfeUsePreferredWidth(ow)) { if(_XfeUsePreferredWidth(nw)) { _XfeConfigFlags(nw) |= (XfeConfigLayout| XfeConfigGeometry| XfeConfigExpose); } } /* resize_height */ if (_XfeUsePreferredHeight(nw) != _XfeUsePreferredHeight(ow)) { if(_XfeUsePreferredHeight(nw)) { _XfeConfigFlags(nw) |= (XfeConfigLayout| XfeConfigGeometry| XfeConfigExpose); } } /* height */ if (_XfeHeight(nw) != _XfeHeight(ow)) { /* if resize_heigh is True, we dont allow width changes */ if (_XfeUsePreferredHeight(nw)) { _XfeHeight(nw) = _XfeHeight(ow); } else { _XfeConfigFlags(nw) |= (XfeConfigLayout|XfeConfigExpose); } } /* width */ if (_XfeWidth(nw) != _XfeWidth(ow)) { /* if resize_width is True, we dont allow width changes */ if (_XfeUsePreferredWidth(nw)) { _XfeWidth(nw) = _XfeWidth(ow); } else { _XfeConfigFlags(nw) |= (XfeConfigLayout|XfeConfigExpose); } } /* cursor */ if (_XfeCursor(nw) != _XfeCursor(ow)) { /* If the new cursor is good, define it */ if (_XfeCursorGood(_XfeCursor(nw))) { XfeCursorDefine(nw,_XfeCursor(nw)); } else { XfeCursorUndefine(nw); } } /* Changes that affect the layout and geometry */ if ((_XfeHighlightThickness(nw) != _XfeHighlightThickness(ow)) || (_XfeMarginTop(nw) != _XfeMarginTop(ow)) || (_XfeMarginBottom(nw) != _XfeMarginBottom(ow)) || (_XfeMarginLeft(nw) != _XfeMarginLeft(ow)) || (_XfeMarginRight(nw) != _XfeMarginRight(ow)) || (_XfeShadowThickness(nw) != _XfeShadowThickness(ow)) || (_XfeUnitType(nw) != _XfeUnitType(ow))) { _XfeConfigFlags(nw) |= (XfeConfigLayout|XfeConfigGeometry|XfeConfigExpose); } /* shadow_type */ if (_XfeShadowType(nw) != _XfeShadowType(ow)) { /* Make sure the new shadow type is ok */ XfeRepTypeCheck(nw,XmRShadowType,&_XfeShadowType(nw),XfeDEFAULT_SHADOW_TYPE); _XfeConfigFlags(nw) |= XfeConfigExpose; } /* sensitive */ if (_XfeSensitive(nw) != _XfeSensitive(ow)) { _XfeConfigFlags(nw) |= XfeConfigExpose; } /* pretend_sensitive */ if (_XfeIsSensitive(nw) != _XfeIsSensitive(ow)) { _XfeConfigFlags(nw) |= XfeConfigExpose; } /* background_pixel or background_pixmap */ if (((_XfeBackgroundPixel(nw) != _XfeBackgroundPixel(ow)) || (_XfeBackgroundPixmap(nw) != _XfeBackgroundPixmap(ow))) && (_XfeBufferType(nw) != XmBUFFER_NONE)) { /* Release the old background GC */ _XfePrimitiveReleaseBackgroundGC(nw); /* Allocate the new background GC */ _XfePrimitiveAllocateBackgroundGC(nw); } return _XfePrimitiveChainSetValues(ow,rw,nw,xfePrimitiveWidgetClass); }