MCPcopy Create free account
hub / github.com/SimHacker/micropolis / ComputeIntervalGeometry

Function ComputeIntervalGeometry

micropolis-activity/src/sim/w_inter.c:691–775  ·  view source on GitHub ↗
(intervalPtr)

Source from the content-addressed store, hash-verified

689 * Side effects:
690 * Display-related numbers get changed in *scrollPtr. The
691 * geometry manager gets told about the window's preferred size.
692 *
693 *----------------------------------------------------------------------
694 */
695
696static void
697ComputeIntervalGeometry(intervalPtr)
698 register Interval *intervalPtr; /* Information about widget. */
699{
700 XCharStruct bbox;
701 char valueString[30];
702 int dummy, lineHeight;
703
704 /*
705 * Horizontal intervals are simpler than vertical ones because
706 * all sizes are the same (the height of a line of text);
707 * handle them first and then quit.
708 */
709
710 if (!intervalPtr->vertical) {
711 lineHeight = intervalPtr->fontPtr->ascent + intervalPtr->fontPtr->descent;
712 if (intervalPtr->tickInterval != 0) {
713 intervalPtr->tickPixels = lineHeight;
714 } else {
715 intervalPtr->tickPixels = 0;
716 }
717 if (intervalPtr->showValue) {
718 intervalPtr->valuePixels = lineHeight + SPACING;
719 } else {
720 intervalPtr->valuePixels = 0;
721 }
722 if (intervalPtr->labelLength != 0) {
723 intervalPtr->labelPixels = lineHeight;
724 } else {
725 intervalPtr->labelPixels = 0;
726 }
727
728 Tk_GeometryRequest(intervalPtr->tkwin,
729 intervalPtr->length + 2*intervalPtr->offset,
730 intervalPtr->tickPixels + intervalPtr->valuePixels
731 + intervalPtr->width + 2*intervalPtr->borderWidth
732 + intervalPtr->labelPixels + 2*intervalPtr->offset);
733 Tk_SetInternalBorder(intervalPtr->tkwin, intervalPtr->borderWidth);
734 return;
735 }
736
737 /*
738 * Vertical interval: compute the amount of space needed for tick marks
739 * and current value by formatting strings for the two end points;
740 * use whichever length is longer.
741 */
742
743 sprintf(valueString, "%d", intervalPtr->fromValue);
744 XTextExtents(intervalPtr->fontPtr, valueString, strlen(valueString),
745 &dummy, &dummy, &dummy, &bbox);
746 intervalPtr->tickPixels = bbox.rbearing + bbox.lbearing;
747 sprintf(valueString, "%d", intervalPtr->toValue);
748 XTextExtents(intervalPtr->fontPtr, valueString, strlen(valueString),

Callers 2

ConfigureIntervalFunction · 0.85
IntervalEventProcFunction · 0.85

Calls 2

Tk_GeometryRequestFunction · 0.85
Tk_SetInternalBorderFunction · 0.85

Tested by

no test coverage detected