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

Function ComputeMenuButtonGeometry

micropolis-activity/src/tk/tkmnbut.c:972–1013  ·  view source on GitHub ↗
(mbPtr)

Source from the content-addressed store, hash-verified

970 * Results:
971 * None.
972 *
973 * Side effects:
974 * The menu button's window may change size.
975 *
976 *----------------------------------------------------------------------
977 */
978
979static void
980ComputeMenuButtonGeometry(mbPtr)
981 register MenuButton *mbPtr; /* Widget record for menu button. */
982{
983 XCharStruct bbox;
984 int dummy;
985 unsigned int width, height;
986
987 if (mbPtr->bitmap != None) {
988#if defined(USE_XPM3)
989 Tk_SizeOfPixmap(mbPtr->bitmap, &width, &height);
990#else
991 Tk_SizeOfBitmap(mbPtr->bitmap, &width, &height);
992#endif
993 if (mbPtr->width > 0) {
994 width = mbPtr->width;
995 }
996 if (mbPtr->height > 0) {
997 height = mbPtr->height;
998 }
999 } else {
1000 mbPtr->textLength = strlen(mbPtr->text);
1001 XTextExtents(mbPtr->fontPtr, mbPtr->text, mbPtr->textLength,
1002 &dummy, &dummy, &dummy, &bbox);
1003 mbPtr->leftBearing = bbox.lbearing;
1004 mbPtr->rightBearing = bbox.rbearing;
1005 width = bbox.lbearing + bbox.rbearing;
1006 height = mbPtr->fontPtr->ascent + mbPtr->fontPtr->descent;
1007 if (mbPtr->width > 0) {
1008 width = mbPtr->width * XTextWidth(mbPtr->fontPtr, "0", 1);
1009 }
1010 if (mbPtr->height > 0) {
1011 height *= mbPtr->height;
1012 }
1013 }
1014
1015 width += 2*mbPtr->padX;
1016 height += 2*mbPtr->padY;

Callers 2

ConfigureMenuButtonFunction · 0.85
tkmnbut.cFile · 0.85

Calls 4

Tk_SizeOfPixmapFunction · 0.85
Tk_SizeOfBitmapFunction · 0.85
Tk_GeometryRequestFunction · 0.85
Tk_SetInternalBorderFunction · 0.85

Tested by

no test coverage detected