|
|
1.1 ! root 1: /*==============================================================*\ ! 2: * Vmm_pnt.c - routines for the painting of the main window * ! 3: * Created 1990, Microsoft, IBM Corp. * ! 4: *--------------------------------------------------------------* ! 5: * * ! 6: * This module contains the code for the main client window * ! 7: * painting * ! 8: * * ! 9: *--------------------------------------------------------------* ! 10: * * ! 11: * This source file contains the following functions: * ! 12: * * ! 13: * MainPaint(hwnd) - main WM_PAINT processing routine * ! 14: * * ! 15: \*==============================================================*/ ! 16: ! 17: /*--------------------------------------------------------------*\ ! 18: * Include files, macros, defined constants, and externs * ! 19: \*--------------------------------------------------------------*/ ! 20: ! 21: #define LINT_ARGS ! 22: ! 23: #define INCL_WIN ! 24: #define INCL_GPI ! 25: #define INCL_DOSPROCESS ! 26: #include <os2.h> ! 27: #include "stdio.h" ! 28: #include "stdlib.h" ! 29: #include "string.h" ! 30: #include "vmm_main.h" ! 31: #include "vmm_xtrn.h" ! 32: ! 33: /* size and positioning of boxes in 0.1 millimeters (PU_LOMETRIC) */ ! 34: ! 35: #define BOX_WIDTH 450 ! 36: #define BOX_HEIGHT 180 ! 37: ! 38: #define VERT_INDENT 30 ! 39: #define HORZ_INDENT 30 ! 40: ! 41: #define SMALL_BOX_HEIGHT 90 ! 42: ! 43: #define HORZ_SPACING 50 ! 44: #define VERT_SPACING 50 ! 45: ! 46: #define VERT_TEXT_POS 90 /* distance from top of window to display text info */ ! 47: #define TOP_MARGIN 110 ! 48: ! 49: /*--------------------------------------------------------------*\ ! 50: * Global variables * ! 51: \*--------------------------------------------------------------*/ ! 52: ULONG clrForeground = CLR_NEUTRAL; /* color for window text */ ! 53: ULONG clrBackground = CLR_BACKGROUND; /* color for window background */ ! 54: CHAR szWindowText[MAXTEXTLEN] = "Sample"; /* text drawn in window */ ! 55: ! 56: extern ULONG ulFreePage; /* First free page entry in array */ ! 57: ! 58: extern PAGEENTRY apgentry[]; /* Application page table */ ! 59: ! 60: /*--------------------------------------------------------------*\ ! 61: * Entry point declarations * ! 62: \*--------------------------------------------------------------*/ ! 63: ! 64: VOID DisplayPage(HPS hps, PPOINTL pptl, ULONG ulPageIndex) ! 65: { ! 66: POINTL ptl; ! 67: MATRIXLF matrix; ! 68: ULONG ulAccess; ! 69: ULONG ulRegionSize; ! 70: PVOID pMem; ! 71: char szBuffer[BUFF_SIZE]; ! 72: ! 73: pMem = apgentry[ulPageIndex].pvAddress; ! 74: ! 75: /* We don't check the return code here since we assume that the array ! 76: contains good addresses since we verified them when we put them in ! 77: the array. */ ! 78: DosQueryMem(pMem, &ulRegionSize, &ulAccess); ! 79: ! 80: matrix.fxM11 = MAKEFIXED(1,0); ! 81: matrix.fxM12 = 0L; ! 82: matrix.lM13 = 0L; ! 83: matrix.fxM21 = 0L; ! 84: matrix.fxM22 = MAKEFIXED(1,0); ! 85: matrix.lM23 = 0L; ! 86: matrix.lM31 = pptl->x; /* x translation */ ! 87: matrix.lM32 = pptl->y; /* y translation */ ! 88: matrix.lM33 = 1L; ! 89: ! 90: if (GpiSetDefaultViewMatrix(hps, 9L, &matrix,TRANSFORM_REPLACE) == GPI_ERROR) ! 91: { ! 92: /* We're in trouble here ??????????????????? */ ! 93: } ! 94: ! 95: ptl.x = 0L; ! 96: ptl.y = 0L; ! 97: GpiMove(hps, &ptl); ! 98: ! 99: ptl.x = BOX_WIDTH; ! 100: ptl.y = BOX_HEIGHT; ! 101: ! 102: /* set outline color to CLR_RED for uncommitted, CLR_GREEN for ! 103: committed */ ! 104: ! 105: if (ulAccess & PAG_COMMIT) ! 106: { ! 107: GpiSetColor(hps, CLR_GREEN); ! 108: } ! 109: else ! 110: { ! 111: GpiSetColor(hps, CLR_RED); ! 112: } ! 113: ! 114: GpiBox(hps, DRO_OUTLINE, &ptl, 0L, 0L); ! 115: ! 116: ! 117: /* should query sys values in case the default is not black ? */ ! 118: ! 119: GpiSetColor(hps, CLR_BLACK); ! 120: ! 121: szBuffer[0]='\000'; ! 122: ! 123: if (ulAccess & PAG_READ) ! 124: { ! 125: strcat(szBuffer, "R"); ! 126: } ! 127: ! 128: if (ulAccess & PAG_WRITE) ! 129: { ! 130: strcat(szBuffer, "W"); ! 131: } ! 132: ! 133: if (ulAccess & PAG_EXECUTE) ! 134: { ! 135: strcat(szBuffer, "E"); ! 136: } ! 137: ! 138: if (ulAccess & PAG_GUARD) ! 139: { ! 140: strcat(szBuffer, "G"); ! 141: } ! 142: ! 143: if (ulAccess & PAG_DEFAULT) ! 144: { ! 145: strcat(szBuffer, "Def"); ! 146: } ! 147: ! 148: if (ulAccess & PAG_BASE) ! 149: { ! 150: strcat(szBuffer, "Base"); ! 151: } ! 152: ! 153: ptl.x = HORZ_INDENT; ! 154: ptl.y = VERT_INDENT; ! 155: GpiCharStringAt(hps, &ptl, (LONG) strlen(szBuffer), szBuffer); ! 156: ! 157: ptl.x = 0; ! 158: ptl.y = SMALL_BOX_HEIGHT; ! 159: ! 160: GpiMove(hps, &ptl); ! 161: ! 162: ptl.x = BOX_WIDTH; ! 163: ptl.y = SMALL_BOX_HEIGHT; ! 164: GpiLine(hps, &ptl); ! 165: ! 166: /* Get base address of current page */ ! 167: sprintf(szBuffer, "0x%p", pMem); ! 168: ! 169: ptl.x = HORZ_INDENT; ! 170: ptl.y = SMALL_BOX_HEIGHT+VERT_INDENT; ! 171: GpiCharStringAt(hps, &ptl, (LONG) strlen(szBuffer), szBuffer); ! 172: ! 173: } ! 174: ! 175: ! 176: /****************************************************************\ ! 177: * Main client painting routine * ! 178: *--------------------------------------------------------------* ! 179: * * ! 180: * Name: MainPaint(hwnd) * ! 181: * * ! 182: * Purpose: Paints the main client window. * ! 183: * * ! 184: * Usage: Routine is called whenver the client window * ! 185: * procedure receives a WM_PAINT message * ! 186: * * ! 187: * Method: * ! 188: * - begins painting by calling WinBeginPaint * ! 189: * and retriving the HPS for the window * ! 190: * * ! 191: * - paint page info boxes * ! 192: * * ! 193: * - ends painting by calling WinEndPaint * ! 194: * * ! 195: * Returns: * ! 196: * * ! 197: \****************************************************************/ ! 198: ! 199: VOID MainPaint(hwnd) ! 200: HWND hwnd; /* handle of the window to be painted */ ! 201: { ! 202: HPS hps; ! 203: USHORT i; ! 204: POINTL ptl; ! 205: RECTL rect; ! 206: SIZEL sizl; ! 207: char szBuffer[BUFF_SIZE]; ! 208: ! 209: sizl.cx = 0L; ! 210: sizl.cy = 0L; ! 211: ! 212: ! 213: hps = WinBeginPaint(hwnd, NULL, NULL); ! 214: ! 215: GpiSetPS(hps, &sizl, PU_LOMETRIC); /* set PS to a device ! 216: independent mapping mode */ ! 217: ! 218: WinQueryWindowRect(hwnd, &rect); ! 219: ! 220: /* ?????????????????????????????????????????? */ ! 221: WinFillRect(hps, &rect, CLR_BACKGROUND); /* This should be done by ! 222: properly handling the ! 223: WM_ERASEBACKGROUND message */ ! 224: ! 225: /* convert the coords of the window to world coords */ ! 226: GpiConvert(hps, CVTC_DEVICE, CVTC_WORLD, 2L, (PPOINTL) &rect); ! 227: ! 228: ptl.x = HORZ_INDENT; ! 229: ptl.y = rect.yTop-VERT_TEXT_POS; ! 230: ! 231: strcpy(szBuffer,"Border color: Green=Committed page," ! 232: " Red=Non-committed page"); ! 233: ! 234: GpiCharStringAt(hps, &ptl, strlen(szBuffer), szBuffer); ! 235: ! 236: ptl.x = HORZ_INDENT; ! 237: ptl.y = rect.yTop-BOX_HEIGHT-TOP_MARGIN; ! 238: ! 239: for (i=0; i<ulFreePage; i++) ! 240: { ! 241: DisplayPage(hps, &ptl, i); ! 242: ptl.x += BOX_WIDTH+HORZ_SPACING; ! 243: ! 244: /* If the next page is a base page, display it on a new line ! 245: for clarity */ ! 246: ! 247: if (apgentry[i+1].fBaseAddr) ! 248: { ! 249: ptl.x = HORZ_INDENT; ! 250: ptl.y -= (BOX_HEIGHT+VERT_SPACING); ! 251: } ! 252: } ! 253: ! 254: WinEndPaint(hps); ! 255: ! 256: } /* MainPaint() */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.