|
|
1.1 ! root 1: /* ! 2: * PAINT.C ! 3: * GizmoBar Version 1.00, March 1993 ! 4: * ! 5: * Contains any code related to GizmoBar visuals, primarily ! 6: * the WM_PAINT handler. ! 7: * ! 8: * Copyright (c)1992 Microsoft Corporation, All Rights Reserved ! 9: * ! 10: * Kraig Brockschmidt, Software Design Engineer ! 11: * Microsoft Systems Developer Relations ! 12: * ! 13: * Internet : [email protected] ! 14: * Compuserve: >INTERNET:[email protected] ! 15: */ ! 16: ! 17: #ifdef WIN32 ! 18: #define _INC_OLE ! 19: #define __RPC_H__ ! 20: #endif ! 21: ! 22: ! 23: #define STRICT ! 24: #include <windows.h> ! 25: #include "gizmoint.h" ! 26: ! 27: ! 28: //In GIZMO.C ! 29: extern TOOLDISPLAYDATA tdd; ! 30: ! 31: ! 32: /* ! 33: * GizmoBarPaint ! 34: * ! 35: * Purpose: ! 36: * Handles all WM_PAINT messages for the control and paints either the ! 37: * entire thing or just one GizmoBar button if pGB->pGizmoPaint is non-NULL. ! 38: * ! 39: * Parameters: ! 40: * hWnd HWND Handle to the control. ! 41: * pGB PGIZMOBAR control data pointer. ! 42: * ! 43: * Return Value: ! 44: * None ! 45: */ ! 46: ! 47: void GizmoBarPaint(HWND hWnd, PGIZMOBAR pGB) ! 48: { ! 49: PAINTSTRUCT ps; ! 50: RECT rc; ! 51: HDC hDC; ! 52: HBRUSH hBr=NULL; ! 53: HPEN hPen=NULL; ! 54: ! 55: ! 56: hDC=BeginPaint(hWnd, &ps); ! 57: GetClientRect(hWnd, &rc); ! 58: ! 59: /* ! 60: * The only part of the frame we need to draw is the bottom line, ! 61: * so we inflate the rectangle such that all other parts are outside ! 62: * the visible region. ! 63: */ ! 64: hBr =CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); ! 65: ! 66: if (NULL!=hBr) ! 67: SelectObject(hDC, hBr); ! 68: ! 69: hPen=CreatePen(PS_SOLID, 1, GetSysColor(COLOR_WINDOWFRAME)); ! 70: ! 71: if (NULL!=hPen) ! 72: SelectObject(hDC, hPen); ! 73: ! 74: Rectangle(hDC, rc.left-1, rc.top-1, rc.right+1, rc.bottom); ! 75: ! 76: ! 77: /* ! 78: * All that we have to do to draw the controls is start through the ! 79: * list, ignoring anything but buttons, and calling BTTNCUR's ! 80: * UIToolButtonDraw for buttons. Since we don't even have to track ! 81: * positions of things, we can just use an enum. ! 82: */ ! 83: GizmoPEnum(&pGB->pGizmos, FEnumPaintGizmos, (DWORD)(LPSTR)&ps); ! 84: ! 85: //Clean up ! 86: EndPaint(hWnd, &ps); ! 87: ! 88: if (NULL!=hBr) ! 89: DeleteObject(hBr); ! 90: ! 91: if (NULL!=hPen) ! 92: DeleteObject(hPen); ! 93: ! 94: return; ! 95: } ! 96: ! 97: ! 98: ! 99: ! 100: ! 101: /* ! 102: * FEnumPaintGizmos ! 103: * ! 104: * Purpose: ! 105: * Enumeration callback for all the gizmos we know about in order to ! 106: * draw them. ! 107: * ! 108: * Parameters: ! 109: * pGizmo PGIZMO to draw. ! 110: * iGizmo UINT index on the GizmoBar of this gizmo. ! 111: * dw DWORD extra data passed to GizmoPEnum, in our case ! 112: * a pointer to the PAINTSTRUCT. ! 113: * ! 114: * Return Value: ! 115: * BOOL TRUE to continue the enumeration, FALSE otherwise. ! 116: */ ! 117: ! 118: BOOL FAR PASCAL FEnumPaintGizmos(PGIZMO pGizmo, UINT iGizmo, DWORD dw) ! 119: { ! 120: LPPAINTSTRUCT pps=(LPPAINTSTRUCT)dw; ! 121: RECT rc, rcI; ! 122: ! 123: //Only draw those marked for repaint. ! 124: if ((GIZMOTYPE_DRAWN & pGizmo->iType)) ! 125: { ! 126: SetRect(&rc, pGizmo->x, pGizmo->y, pGizmo->x+pGizmo->dx, pGizmo->y+pGizmo->dy); ! 127: ! 128: //Only draw gizmos in the repaint area ! 129: if (IntersectRect(&rcI, &rc, &pps->rcPaint)) ! 130: { ! 131: UIToolButtonDrawTDD(pps->hdc, pGizmo->x, pGizmo->y ! 132: , pGizmo->dx, pGizmo->dy, pGizmo->hBmp, pGizmo->cxImage ! 133: , pGizmo->cyImage, pGizmo->iBmp, (UINT)pGizmo->uState, &tdd); ! 134: } ! 135: } ! 136: ! 137: return TRUE; ! 138: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.