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