1 #ifndef CARDBOARD_INCLUDED 2 #define CARDBOARD_INCLUDED 3 4 #define MAXBUTTONS 32 5 #define MAXCARDSTACKS 32 6 #define MAXDROPZONES 8 7 8 class CardRegion; 9 class CardButton; 10 11 LRESULT CALLBACK CardWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam); 12 13 class CardWindow 14 { 15 friend class CardRegion; 16 friend class CardButton; 17 18 friend void RegisterCardWindow(); 19 20 public: 21 22 CardWindow(); 23 ~CardWindow(); 24 25 // 26 // Basic windowing support 27 // 28 BOOL Create(HWND hwndParent, DWORD dwExStyle, DWORD dwStyle, int x, int y, int width, int height); 29 BOOL Destroy(); 30 31 operator HWND() { return m_hWnd; } 32 33 CardButton *CreateButton (int id, TCHAR *szText, UINT uStyle, bool fVisible, int x, int y, int width, int height); 34 CardRegion *CreateRegion (int id, bool fVisible, int x, int y, int xoffset, int yoffset); 35 36 CardButton *CardButtonFromId(int id); 37 CardRegion *CardRegionFromId(int id); 38 39 bool DeleteButton(CardButton *pButton); 40 bool DeleteRegion(CardRegion *pRegion); 41 bool DeleteAll(); 42 43 void SetBackColor(COLORREF cr); 44 COLORREF GetBackColor(); 45 void SetBackCardIdx(UINT uBackIdx); 46 UINT GetBackCardIdx(); 47 void SetBackImage(HBITMAP hBitmap); 48 49 void EmptyStacks(void); 50 void Redraw(void); 51 void Update(void); 52 53 bool DistributeStacks(int nIdFrom, int nNumStacks, UINT xJustify, int xSpacing, int nStartX); 54 void SetResizeProc(pResizeWndProc proc); 55 int GetWidth() { return nWidth; } 56 int GetHeight() { return nHeight; } 57 58 // 59 // Dropzone support 60 // 61 bool RegisterDropZone(int id, RECT *rect, pDropZoneProc proc); 62 bool DeleteDropZone(int id); 63 64 private: 65 66 int GetNumDropZones() { return nNumDropZones; } 67 DropZone* GetDropZoneFromRect(RECT *rect); 68 69 // 70 // Window procedure - don't call 71 // 72 LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam); 73 static LRESULT CALLBACK CardWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam); 74 75 // 76 // Private functions 77 // 78 void Paint(HDC hdc); 79 void PaintCardRgn(HDC hdc, int dx, int dy, int width, int height, int sx, int sy); 80 81 HPALETTE CreateCardPalette(); 82 83 CardButton *CardButtonFromPoint(int x, int y); 84 CardRegion *CardRegionFromPoint(int x, int y); 85 CardRegion *GetBestStack(int x, int y, int w, int h); 86 87 // 88 // Private members 89 // 90 91 HWND m_hWnd; //window handle! 92 int nWidth, nHeight; 93 94 UINT nBackCardIdx; //all stacks share this card index by default 95 96 HBITMAP hbmBackImage; 97 HDC hdcBackImage; 98 99 100 CardButton * Buttons[MAXBUTTONS]; 101 int nNumButtons; 102 103 CardRegion * Regions[MAXCARDSTACKS]; 104 int nNumCardRegions; 105 106 DropZone * dropzone[MAXDROPZONES]; 107 int nNumDropZones; 108 109 COLORREF crBackgnd; 110 111 pResizeWndProc ResizeWndCallback; 112 113 114 }; 115 116 #endif /* CARDBOARD_INCLUDED */ 117