1 /* 2 * PROJECT: ReactOS Character Map 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/applications/charmap/cell.cpp 5 * PURPOSE: Class for each individual cell 6 * COPYRIGHT: Copyright 2015 Ged Murphy <gedmurphy@reactos.org> 7 */ 8 9 10 #include "precomp.h" 11 #include "Cell.h" 12 13 14 /* DATA *****************************************************/ 15 16 17 /* PUBLIC METHODS **********************************************/ 18 19 CCell::CCell( 20 _In_ HWND hParent 21 ) : 22 CCell(hParent, RECT{0}) 23 { 24 } 25 26 CCell::CCell( 27 _In_ HWND hParent, 28 _In_ RECT& CellCoordinates 29 ) : 30 m_hParent(hParent), 31 m_CellCoordinates(CellCoordinates), 32 m_Char(L'*'), 33 m_bHasFocus(false), 34 m_bIsLarge(false) 35 { 36 } 37 38 CCell::~CCell() 39 { 40 } 41 42 bool 43 CCell::OnPaint(_In_ PAINTSTRUCT &PaintStruct) 44 { 45 // Check if this cell is in our paint region 46 BOOL NeedsPaint; RECT rect; 47 NeedsPaint = IntersectRect(&rect, 48 &PaintStruct.rcPaint, 49 &m_CellCoordinates); 50 if (NeedsPaint == FALSE) 51 return false; 52 53 54 55 // Draw the cell border 56 BOOL b = Rectangle(PaintStruct.hdc, 57 m_CellCoordinates.left, 58 m_CellCoordinates.top, 59 m_CellCoordinates.right, 60 m_CellCoordinates.bottom); 61 62 // Calculate an internal drawing canvas for the cell 63 RECT Internal; 64 CopyRect(&Internal, &m_CellCoordinates); 65 InflateRect(&Internal, -1, -1); 66 67 // Check if this cell has focus 68 if (m_bHasFocus) 69 { 70 // Draw the smaller cell to make it look selected 71 Rectangle(PaintStruct.hdc, 72 Internal.left, 73 Internal.top, 74 Internal.right, 75 Internal.bottom); 76 } 77 78 int Success; 79 Success = DrawTextW(PaintStruct.hdc, 80 &m_Char, 81 1, 82 &Internal, 83 DT_CENTER | DT_VCENTER | DT_SINGLELINE); 84 85 return (Success != 0); 86 } 87 88 void 89 CCell::SetCellCoordinates( 90 _In_ RECT& Coordinates 91 ) 92 { 93 m_CellCoordinates = Coordinates; 94 } 95