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

Function DisplayMenuButton

micropolis-activity/src/tk/tkmnbut.c:751–904  ·  view source on GitHub ↗
(clientData)

Source from the content-addressed store, hash-verified

749 * Side effects:
750 * Commands are output to X to display the menubutton in its
751 * current mode.
752 *
753 *----------------------------------------------------------------------
754 */
755
756static void
757DisplayMenuButton(clientData)
758 ClientData clientData; /* Information about widget. */
759{
760 register MenuButton *mbPtr = (MenuButton *) clientData;
761 GC gc;
762 Tk_3DBorder border;
763 Pixmap pixmap;
764 int x = 0; /* Initialization needed only to stop
765 * compiler warning. */
766 int y;
767 register Tk_Window tkwin = mbPtr->tkwin;
768
769 mbPtr->flags &= ~REDRAW_PENDING;
770 if ((mbPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
771 return;
772 }
773
774 if ((mbPtr->state == tkDisabledUid) && (mbPtr->disabledFg != NULL)) {
775 gc = mbPtr->disabledGC;
776 border = mbPtr->normalBorder;
777 } else if (mbPtr->state == tkActiveUid) {
778 gc = mbPtr->activeTextGC;
779 border = mbPtr->activeBorder;
780 } else {
781 gc = mbPtr->normalTextGC;
782 border = mbPtr->normalBorder;
783 }
784
785 /*
786 * In order to avoid screen flashes, this procedure redraws
787 * the menu button in a pixmap, then copies the pixmap to the
788 * screen in a single operation. This means that there's no
789 * point in time where the on-sreen image has been cleared.
790 */
791
792 pixmap = XCreatePixmap(Tk_Display(tkwin), Tk_WindowId(tkwin),
793 Tk_Width(tkwin), Tk_Height(tkwin),
794 Tk_DefaultDepth(Tk_Screen(tkwin)));
795 Tk_Fill3DRectangle(Tk_Display(tkwin), pixmap, border,
796 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
797
798 /*
799 * Display bitmap or text for button.
800 */
801
802 if (mbPtr->bitmap != None) {
803 unsigned int width, height;
804
805#if defined(USE_XPM3)
806 Tk_SizeOfPixmap(mbPtr->bitmap, &width, &height);
807#else
808 Tk_SizeOfBitmap(mbPtr->bitmap, &width, &height);

Callers

nothing calls this directly

Calls 6

Tk_DefaultDepthFunction · 0.85
Tk_Fill3DRectangleFunction · 0.85
Tk_SizeOfPixmapFunction · 0.85
Tk_SizeOfBitmapFunction · 0.85
TkUnderlineCharsFunction · 0.85
Tk_Draw3DRectangleFunction · 0.85

Tested by

no test coverage detected