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

Function DisplayButton

micropolis-activity/src/tk/tkbutton.c:978–1202  ·  view source on GitHub ↗
(clientData)

Source from the content-addressed store, hash-verified

976 * Side effects:
977 * Commands are output to X to display the button in its
978 * current mode.
979 *
980 *----------------------------------------------------------------------
981 */
982
983static void
984DisplayButton(clientData)
985 ClientData clientData; /* Information about widget. */
986{
987 register Button *butPtr = (Button *) clientData;
988 GC gc;
989 Tk_3DBorder border;
990 Pixmap pixmap;
991 int x = 0; /* Initialization only needed to stop
992 * compiler warning. */
993 int y;
994 register Tk_Window tkwin = butPtr->tkwin;
995
996//fprintf(stderr, "DisplayButton Handled Timer %s %s was %d now 0\n", Tk_Class(butPtr->tkwin), Tk_PathName(butPtr->tkwin), butPtr->updateTimerToken);
997
998 assert(butPtr->updateTimerToken != 0);
999 butPtr->updateTimerToken = 0;
1000
1001 butPtr->flags &= ~REDRAW_PENDING;
1002 if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
1003 return;
1004 }
1005
1006 if ((butPtr->state == tkDisabledUid) && (butPtr->disabledFg != NULL)) {
1007 gc = butPtr->disabledGC;
1008 border = butPtr->normalBorder;
1009 } else if (butPtr->state == tkActiveUid) {
1010 gc = butPtr->activeTextGC;
1011 border = butPtr->activeBorder;
1012 } else {
1013 gc = butPtr->normalTextGC;
1014 border = butPtr->normalBorder;
1015 }
1016
1017 /*
1018 * In order to avoid screen flashes, this procedure redraws
1019 * the button in a pixmap, then copies the pixmap to the
1020 * screen in a single operation. This means that there's no
1021 * point in time where the on-sreen image has been cleared.
1022 */
1023
1024 pixmap = XCreatePixmap(Tk_Display(tkwin), Tk_WindowId(tkwin),
1025 Tk_Width(tkwin), Tk_Height(tkwin),
1026 Tk_DefaultDepth(Tk_Screen(tkwin)));
1027 Tk_Fill3DRectangle(Tk_Display(tkwin), pixmap, border,
1028 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
1029
1030 /*
1031 * Display bitmap or text for button.
1032 */
1033
1034 if (butPtr->bitmap != None) {
1035 unsigned int width, height;

Callers 1

ButtonWidgetCmdFunction · 0.85

Calls 7

Tk_DefaultDepthFunction · 0.85
Tk_Fill3DRectangleFunction · 0.85
Tk_SizeOfPixmapFunction · 0.85
Tk_SizeOfBitmapFunction · 0.85
Tk_Draw3DRectangleFunction · 0.85
Tk_Fill3DPolygonFunction · 0.85
Tk_Draw3DPolygonFunction · 0.85

Tested by

no test coverage detected