/*++ Copyright (c) 1990 Microsoft Corporation Module Name: util.c Abstract: Drawing program utilities Author: Mark Enstrom (marke) Environment: C Revision History: 08-26-92 Initial version --*/ #include #include #include #include #include #include #include #include #include #include #include "wcall.h" #include "resource.h" #define NUM_BUTTONS 4 #define BUT_ZERO 0 #define BUT_SAMPLE 1 #define BUT_SAVE 2 #define BUT_REFR 3 HDC hChildDC; char EditTextInput[255]; ULONG RefrRate = 10; USHORT PosX = 0; USHORT PosY = 0; TEXTMETRIC TextMetric; LONG FAR PASCAL ToolWndProc( HWND hWnd, unsigned msg, UINT wParam, LONG lParam) /*++ Routine Description: Process messages. Arguments: hWnd - window hande msg - type of message wParam - additional information lParam - additional information Return Value: status of operation Revision History: 02-17-91 Initial code --*/ { static RECT ButtonPos[NUM_BUTTONS]; static BOOL ButtonState[NUM_BUTTONS]; static PUCHAR ButtonStr[NUM_BUTTONS] = { "Zero","Sample","Save","Repeat" }; switch (msg) { // // create window // case WM_CREATE: { hChildDC = GetDC(hWnd); GetTextMetrics(hChildDC,&TextMetric); // // set text modes // SetBkMode(hChildDC,TRANSPARENT); SetBkColor(hChildDC,RGB(0xc0,0xc0,0xc0)); SetTextAlign(hChildDC,TA_LEFT | TA_CENTER); // // get init info, set initial button state // if (wCxt.bTime) { ButtonState[BUT_REFR] = TRUE; } else { ButtonState[BUT_REFR] = FALSE; } ButtonState[BUT_SAMPLE] = FALSE; ButtonState[BUT_ZERO] = FALSE; // // calc button extents // { int ix,px; px = 8; for (ix=0;ixleft; int y = pRect->top; int w = pRect->right - x; int h = pRect->bottom - y; { // // draw button text // RECT rclClip; int cx; rclClip.left = pRect->left+2; rclClip.top = pRect->top+1; rclClip.right = pRect->right-1; rclClip.bottom = pRect->bottom-1; cx = rclClip.left + (rclClip.right - rclClip.left)/2; ExtTextOut(hDC,cx,rclClip.top-1,ETO_CLIPPED,&rclClip,pszBut,strlen(pszBut),0); } // // make room for borders // x -= 2; y -= 2; w += 4; h += 4; // // black outline // fill.left = x; fill.right = x+w; fill.top = y-1; fill.bottom = y; FillRect(hDC,&fill,GetStockObject(BLACK_BRUSH)); fill.left = x-1; fill.right = x; fill.top = y; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(BLACK_BRUSH)); fill.left = x; fill.right = x+w; fill.top = y+h; fill.bottom = y+h+1; FillRect(hDC,&fill,GetStockObject(BLACK_BRUSH)); fill.left = x+w; fill.right = x+w+1; fill.top = y; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(BLACK_BRUSH)); if (bDown) { // // cleartop and left // fill.left = x; fill.right = x+w; fill.top = y+1; fill.bottom = y+2; FillRect(hDC,&fill,GetStockObject(LTGRAY_BRUSH)); fill.left = x+1; fill.right = x+2; fill.top = y+1; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(LTGRAY_BRUSH)); // // sengle wide shadow on top and left // fill.left = x; fill.right = x+w; fill.top = y; fill.bottom = y+1; FillRect(hDC,&fill,GetStockObject(GRAY_BRUSH)); fill.left = x; fill.right = x+1; fill.top = y; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(GRAY_BRUSH)); // // bottom and right // fill.left = x+1; fill.right = x+w; fill.top = y+h-2; fill.bottom = y+h-1; FillRect(hDC,&fill,GetStockObject(LTGRAY_BRUSH)); fill.left = x; fill.right = x+w; fill.top = y+h-1; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(LTGRAY_BRUSH)); fill.left = x+w-2; fill.right = x+w-1; fill.top = y+2; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(LTGRAY_BRUSH)); fill.left = x+w-1; fill.right = x+w; fill.top = y+1; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(LTGRAY_BRUSH)); } else { // // top and left // fill.left = x; fill.right = x+w; fill.top = y; fill.bottom = y+2; FillRect(hDC,&fill,GetStockObject(WHITE_BRUSH)); fill.right = x+2; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(WHITE_BRUSH)); // // bottom and right // fill.left = x+1; fill.right = x+w; fill.top = y+h-2; fill.bottom = y+h-1; FillRect(hDC,&fill,GetStockObject(GRAY_BRUSH)); fill.left = x; fill.right = x+w; fill.top = y+h-1; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(GRAY_BRUSH)); fill.left = x+w-2; fill.right = x+w-1; fill.top = y+2; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(GRAY_BRUSH)); fill.left = x+w-1; fill.right = x+w; fill.top = y+1; fill.bottom = y+h; FillRect(hDC,&fill,GetStockObject(GRAY_BRUSH)); } } BOOL PointInRect( int x, int y, PRECT prcl ) { BOOL bRet = FALSE; if ( (x >= prcl->left) && (x < prcl->right) && (y >= prcl->top) && (y < prcl->bottom) ) { bRet = TRUE; } return(bRet); } int HitCheck( int x, int y, PRECT prcl ) { // // search list of rects for inside // int i; for (i=0;i