/****************************************************************************** Source File: setdrw.c This file contains the code to draw the test bitmap Copyright (c) 1997-1998 by Microsoft Corporation Change History: Original version - ChrisW 12-01-97 AndreVa - Created It ******************************************************************************/ #include "deskadp.h" /**************************************************************************** FUNCTION: MakeRect PURPOSE: Fill in RECT structure given contents. ****************************************************************************/ VOID MakeRect( PRECT pRect, INT xmin, INT ymin, INT xmax, INT ymax ) { pRect->left= xmin; pRect->right= xmax; pRect->bottom= ymin; pRect->top= ymax; } // type constants for DrawArrow #define AW_TOP 1 // top #define AW_BOTTOM 2 // bottom #define AW_LEFT 3 // left #define AW_RIGHT 4 // right /**************************************************************************** FUNCTION: DrawArrow PURPOSE: Draw one arrow in a given color. ****************************************************************************/ static VOID DrawArrow( HDC hDC, INT type, INT xPos, INT yPos, COLORREF crPenColor ) { INT shaftlen=30; // length of arrow shaft INT headlen=15; // height or width of arrow head (not length) HGDIOBJ hPen, hPrevPen = NULL; // pens INT x,y; INT xdir, ydir; // directions of x and y (1,-1) hPen= CreatePen( PS_SOLID, 1, crPenColor ); if( hPen ) hPrevPen= SelectObject( hDC, hPen ); MoveToEx( hDC, xPos, yPos, NULL ); xdir= ydir= 1; // defaults switch( type ) { case AW_BOTTOM: ydir= -1; case AW_TOP: LineTo(hDC, xPos, yPos+ydir*shaftlen); for( x=0; x<3; x++ ) { MoveToEx( hDC, xPos, yPos+ydir*x, NULL ); LineTo( hDC, xPos-(headlen-x), yPos+ydir*headlen ); MoveToEx( hDC, xPos, yPos+ydir*x, NULL ); LineTo( hDC, xPos+(headlen-x), yPos+ydir*headlen ); } break; case AW_RIGHT: xdir= -1; case AW_LEFT: LineTo( hDC, xPos + xdir*shaftlen, yPos ); for( y=0; y<3; y++ ) { MoveToEx( hDC, xPos + xdir*y, yPos, NULL ); LineTo( hDC, xPos + xdir*headlen, yPos+(headlen-y)); MoveToEx( hDC, xPos + xdir*y, yPos, NULL ); LineTo( hDC, xPos + xdir*headlen, yPos-(headlen-y)); } break; } if( hPrevPen ) SelectObject( hDC, hPrevPen ); if (hPen) DeleteObject(hPen); } /**************************************************************************** FUNCTION: LabelRect PURPOSE: Label a rectangle with centered text given resource ID. ****************************************************************************/ static VOID LabelRect(HDC hDC, PRECT pRect, UINT idString ) { UINT iStatus; INT xStart, yStart; SIZE Size; // for size of string TCHAR szMsg[256]; if( idString == 0 ) // make it easy to ignore call return; SetBkMode( hDC, OPAQUE ); SetBkColor( hDC, RGB(0,0,0) ); SetTextColor( hDC, RGB(255,255,255) ); // center xStart= (pRect->left+pRect->right) /2; yStart= (pRect->top+pRect->bottom) /2; iStatus= LoadString( g_hInst, idString, szMsg, ARRAYSIZE(szMsg) ); if( !iStatus ) { return; // can't find string - print nothing } GetTextExtentPoint32( hDC, szMsg, lstrlen(szMsg), &Size ); TextOut( hDC, xStart-Size.cx/2, yStart-Size.cy/2, szMsg, lstrlen(szMsg) ); } /**************************************************************************** FUNCTION: PaintRect PURPOSE: Color in a rectangle and label it. ****************************************************************************/ static VOID PaintRect( HDC hDC, // DC to paint INT lowx, // coordinates describing rectangle to fill INT lowy, // INT highx, // INT highy, // COLORREF rgb, // color to fill in rectangle with UINT idString ) // resource ID to use to label or 0 is none { RECT rct; HBRUSH hBrush; MakeRect( &rct, lowx, lowy, highx, highy ); hBrush = CreateSolidBrush( rgb ); if (hBrush) { FillRect( hDC, &rct, hBrush ); DeleteObject( hBrush ); } LabelRect( hDC, &rct, idString ); } /**************************************************************************** FUNCTION: DrawArrows PURPOSE: Draw all the arrows showing edges of resolution. ****************************************************************************/ VOID DrawArrows( HDC hDC, INT xRes, INT yRes ) { INT dx,dy; INT x,y; COLORREF color= RGB(0,0,0); // color of arrow dx= xRes/8; dy= yRes/8; for( x=0; x=ResTab[i].xRes ) | ( nHeight>=ResTab[i].yRes ) ) { PaintRect(hDC,0,0,ResTab[i].xRes,ResTab[i].yRes,ResTab[i].crColor,0); LabelResolution( hDC, 0, 0, ResTab[i].xRes, ResTab[i].yRes); } } // color bars - only in standard vga area xUsed= min( nWidth, 640 ); // only use vga width yUsed= min( nHeight, 480 ); // could be 400 on some boards dx= xUsed/2; dy= yUsed/6; PaintRect( hDC, 0, 0, dx, dy*1, RGB(255,0,0), IDS_COLOR_RED ); PaintRect( hDC, 0,dy*1, dx, dy*2, RGB(0,255,0), IDS_COLOR_GREEN ); PaintRect( hDC, 0,dy*2, dx, dy*3, RGB(0,0,255), IDS_COLOR_BLUE ); PaintRect( hDC, 0,dy*3, dx, dy*4, RGB(255,255,0 ),IDS_COLOR_YELLOW ); PaintRect( hDC, 0,dy*4, dx, dy*5, RGB(255,0,255), IDS_COLOR_MAGENTA ); PaintRect( hDC, 0,dy*5, dx, yUsed, RGB(0,255,255), IDS_COLOR_CYAN ); // gradations of colors for true color detection for( x=dx; x