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

Function DisplayEntry

micropolis-activity/src/tk/tkentry.c:834–1002  ·  view source on GitHub ↗
(clientData)

Source from the content-addressed store, hash-verified

832 *
833 * Side effects:
834 * Information appears on the screen.
835 *
836 *--------------------------------------------------------------
837 */
838
839static void
840DisplayEntry(clientData)
841 ClientData clientData; /* Information about window. */
842{
843 register Entry *entryPtr = (Entry *) clientData;
844 register Tk_Window tkwin = entryPtr->tkwin;
845 int startX, baseY, selStartX, selEndX, index, cursorX;
846 int xBound, count;
847 Pixmap pixmap;
848
849 entryPtr->flags &= ~REDRAW_PENDING;
850 if ((entryPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
851 return;
852 }
853
854 /*
855 * In order to avoid screen flashes, this procedure redraws the
856 * textual area of the entry into off-screen memory, then copies
857 * it back on-screen in a single operation. This means there's
858 * no point in time where the on-screen image has been cleared.
859 */
860
861 pixmap = XCreatePixmap(Tk_Display(tkwin), Tk_WindowId(tkwin),
862 Tk_Width(tkwin), Tk_Height(tkwin),
863 Tk_DefaultDepth(Tk_Screen(tkwin)));
864
865 /*
866 * Compute x-coordinate of the "leftIndex" character, plus limit
867 * of visible x-coordinates (actually, pixel just after last visible
868 * one), plus vertical position of baseline of text.
869 */
870
871 startX = entryPtr->offset;
872 xBound = Tk_Width(tkwin) - entryPtr->offset;
873 baseY = (Tk_Height(tkwin) + entryPtr->fontPtr->ascent
874 - entryPtr->fontPtr->descent)/2;
875
876 /*
877 * Draw the background in three layers. From bottom to top the
878 * layers are: normal background, selection background, and
879 * insertion cursor background.
880 */
881
882 Tk_Fill3DRectangle(Tk_Display(tkwin), pixmap, entryPtr->normalBorder,
883 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
884
885 if (entryPtr->selectLast >= entryPtr->leftIndex) {
886 if (entryPtr->selectFirst <= entryPtr->leftIndex) {
887 selStartX = startX;
888 index = entryPtr->leftIndex;
889 } else {
890 (void) TkMeasureChars(entryPtr->fontPtr,
891 entryPtr->string+entryPtr->leftIndex,

Callers

nothing calls this directly

Calls 5

Tk_DefaultDepthFunction · 0.85
Tk_Fill3DRectangleFunction · 0.85
TkMeasureCharsFunction · 0.85
TkDisplayCharsFunction · 0.85
Tk_Draw3DRectangleFunction · 0.85

Tested by

no test coverage detected