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

Function DisplayMessage

micropolis-activity/src/tk/tkmsg.c:585–681  ·  view source on GitHub ↗
(clientData)

Source from the content-addressed store, hash-verified

583 * None.
584 *
585 * Side effects:
586 * Information appears on the screen.
587 *
588 *--------------------------------------------------------------
589 */
590
591static void
592DisplayMessage(clientData)
593 ClientData clientData; /* Information about window. */
594{
595 register Message *msgPtr = (Message *) clientData;
596 register Tk_Window tkwin = msgPtr->tkwin;
597 char *p;
598 int x, y, lineLength, numChars, charsLeft;
599
600 msgPtr->flags &= ~REDRAW_PENDING;
601 if ((msgPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
602 return;
603 }
604 if (msgPtr->flags & CLEAR_NEEDED) {
605 XClearWindow(Tk_Display(tkwin), Tk_WindowId(tkwin));
606 msgPtr->flags &= ~CLEAR_NEEDED;
607 }
608
609 /*
610 * Compute starting y-location for message based on message size
611 * and anchor option.
612 */
613
614 switch (msgPtr->anchor) {
615 case TK_ANCHOR_NW: case TK_ANCHOR_N: case TK_ANCHOR_NE:
616 y = msgPtr->borderWidth + msgPtr->padY;
617 break;
618 case TK_ANCHOR_W: case TK_ANCHOR_CENTER: case TK_ANCHOR_E:
619 y = (Tk_Height(tkwin) - msgPtr->msgHeight)/2;
620 break;
621 default:
622 y = Tk_Height(tkwin) - msgPtr->borderWidth - msgPtr->padY
623 - msgPtr->msgHeight;
624 break;
625 }
626 y += msgPtr->fontPtr->ascent;
627
628 /*
629 * Work through the string to display one line at a time.
630 * Display each line in three steps. First compute the
631 * line's width, then figure out where to display the
632 * line to justify it properly, then display the line.
633 */
634
635 for (p = msgPtr->string, charsLeft = msgPtr->numChars; *p != 0;
636 y += msgPtr->fontPtr->ascent + msgPtr->fontPtr->descent) {
637 if (*p == '\n') {
638 p++;
639 charsLeft--;
640 continue;
641 }
642 numChars = TkMeasureChars(msgPtr->fontPtr, p, charsLeft, 0,

Callers

nothing calls this directly

Calls 3

TkMeasureCharsFunction · 0.85
TkDisplayCharsFunction · 0.85
Tk_Draw3DRectangleFunction · 0.85

Tested by

no test coverage detected