1 #pragma once 2 #include "Cell.h" 3 4 #define MAX_GLYPHS 0xFFFF 5 6 struct CurrentFont 7 { 8 CAtlStringW FontName; 9 LOGFONTW Font; 10 HFONT hFont; 11 USHORT ValidGlyphs[MAX_GLYPHS]; 12 USHORT NumValidGlyphs; 13 }; 14 15 16 class CGridView 17 { 18 private: 19 CAtlStringW m_szMapWndClass; 20 21 HWND m_hwnd; 22 HWND m_hParent; 23 24 int m_xNumCells; 25 int m_yNumCells; 26 27 RECT m_ClientCoordinates; 28 SIZE m_CellSize; 29 CCell*** m_Cells; // *m_Cells[][]; 30 CCell *m_ActiveCell; 31 32 INT m_ScrollPosition; 33 int m_NumRows; 34 35 CurrentFont m_CurrentFont; 36 37 public: 38 CGridView(); 39 ~CGridView(); 40 41 bool Create( 42 _In_ HWND hParent 43 ); 44 45 bool SetFont( 46 _In_ CAtlString& FontName 47 ); 48 49 HWND GetHwnd() { return m_hwnd; } 50 51 private: 52 static LRESULT 53 CALLBACK 54 MapWndProc(HWND hwnd, 55 UINT uMsg, 56 WPARAM wParam, 57 LPARAM lParam); 58 59 LRESULT OnCreate( 60 _In_ HWND hwnd, 61 _In_ HWND hParent 62 ); 63 64 65 LRESULT OnSize( 66 _In_ INT Width, 67 _In_ INT Height 68 ); 69 70 VOID OnVScroll( 71 _In_ INT Value, 72 _In_ INT Pos 73 ); 74 75 LRESULT OnPaint( 76 _In_opt_ HDC hdc 77 ); 78 79 bool UpdateCellCoordinates( 80 ); 81 82 void DrawGrid( 83 _In_ LPPAINTSTRUCT PaintStruct 84 ); 85 86 void DeleteCells(); 87 88 void SetCellFocus( 89 _In_ CCell* NewActiveCell 90 ); 91 }; 92 93