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

Function ComputeButtonGeometry

micropolis-activity/src/tk/tkbutton.c:1278–1346  ·  view source on GitHub ↗
(butPtr)

Source from the content-addressed store, hash-verified

1276 * Results:
1277 * None.
1278 *
1279 * Side effects:
1280 * The button's window may change size.
1281 *
1282 *----------------------------------------------------------------------
1283 */
1284
1285static void
1286ComputeButtonGeometry(butPtr)
1287 register Button *butPtr; /* Button whose geometry may have changed. */
1288{
1289 XCharStruct bbox;
1290 int dummy;
1291 unsigned int width, height;
1292
1293 butPtr->selectorSpace = 0;
1294 if (butPtr->bitmap != None) {
1295#if defined(USE_XPM3)
1296 Tk_SizeOfPixmap(butPtr->bitmap, &width, &height);
1297#else
1298 Tk_SizeOfBitmap(butPtr->bitmap, &width, &height);
1299#endif
1300 if (butPtr->width > 0) {
1301 width = butPtr->width;
1302 }
1303 if (butPtr->height > 0) {
1304 height = butPtr->height;
1305 }
1306 if ((butPtr->type >= TYPE_CHECK_BUTTON)
1307 && (butPtr->selectorGC != None)) {
1308 butPtr->selectorSpace = (14*height)/10;
1309 if (butPtr->type == TYPE_CHECK_BUTTON) {
1310 butPtr->selectorDiameter = (65*height)/100;
1311 } else {
1312 butPtr->selectorDiameter = (75*height)/100;
1313 }
1314 }
1315 } else {
1316 butPtr->textLength = strlen(butPtr->text);
1317 XTextExtents(butPtr->fontPtr, butPtr->text, butPtr->textLength,
1318 &dummy, &dummy, &dummy, &bbox);
1319 butPtr->leftBearing = bbox.lbearing;
1320 butPtr->rightBearing = bbox.rbearing;
1321 width = bbox.lbearing + bbox.rbearing;
1322 height = butPtr->fontPtr->ascent + butPtr->fontPtr->descent;
1323 if (butPtr->width > 0) {
1324 width = butPtr->width * XTextWidth(butPtr->fontPtr, "0", 1);
1325 }
1326 if (butPtr->height > 0) {
1327 height *= butPtr->height;
1328 }
1329 if ((butPtr->type >= TYPE_CHECK_BUTTON)
1330 && (butPtr->selectorGC != None)) {
1331 butPtr->selectorDiameter = butPtr->fontPtr->ascent
1332 + butPtr->fontPtr->descent;
1333 if (butPtr->type == TYPE_CHECK_BUTTON) {
1334 butPtr->selectorDiameter = (80*butPtr->selectorDiameter)/100;
1335 }

Callers 2

ConfigureButtonFunction · 0.85
tkbutton.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