Fix multi-leg promotions
[xboard.git] / winboard / winboard.h
1 /*\r
2  * WinBoard.h -- Definitions for Windows NT front end to XBoard\r
3  *\r
4  * Copyright 1991 by Digital Equipment Corporation, Maynard,\r
5  * Massachusetts.\r
6  *\r
7  * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,\r
8  * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free\r
9  * Software Foundation, Inc.\r
10  *\r
11  * Enhancements Copyright 2005 Alessandro Scotti\r
12  *\r
13  * The following terms apply to Digital Equipment Corporation's copyright\r
14  * interest in XBoard:\r
15  * ------------------------------------------------------------------------\r
16  * All Rights Reserved\r
17  *\r
18  * Permission to use, copy, modify, and distribute this software and its\r
19  * documentation for any purpose and without fee is hereby granted,\r
20  * provided that the above copyright notice appear in all copies and that\r
21  * both that copyright notice and this permission notice appear in\r
22  * supporting documentation, and that the name of Digital not be\r
23  * used in advertising or publicity pertaining to distribution of the\r
24  * software without specific, written prior permission.\r
25  *\r
26  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\r
27  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\r
28  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\r
29  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\r
30  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\r
31  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\r
32  * SOFTWARE.\r
33  * ------------------------------------------------------------------------\r
34  *\r
35  * The following terms apply to the enhanced version of XBoard\r
36  * distributed by the Free Software Foundation:\r
37  * ------------------------------------------------------------------------\r
38  *\r
39  * GNU XBoard is free software: you can redistribute it and/or modify\r
40  * it under the terms of the GNU General Public License as published by\r
41  * the Free Software Foundation, either version 3 of the License, or (at\r
42  * your option) any later version.\r
43  *\r
44  * GNU XBoard is distributed in the hope that it will be useful, but\r
45  * WITHOUT ANY WARRANTY; without even the implied warranty of\r
46  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
47  * General Public License for more details.\r
48  *\r
49  * You should have received a copy of the GNU General Public License\r
50  * along with this program. If not, see http://www.gnu.org/licenses/.  *\r
51  *\r
52  *------------------------------------------------------------------------\r
53  ** See the file ChangeLog for a revision history.  */\r
54 \r
55 #include "resource.h"\r
56 #include <dlgs.h>\r
57 \r
58 /* Types */\r
59 typedef struct {\r
60   char faceName[LF_FACESIZE];\r
61   float pointSize;\r
62   BYTE bold, italic, underline, strikeout;\r
63   BYTE charset;\r
64 } MyFontParams;\r
65 \r
66 typedef struct {\r
67   char *def;\r
68   MyFontParams mfp;\r
69   LOGFONT lf;\r
70   HFONT hf;\r
71 } MyFont;\r
72 \r
73 typedef enum { \r
74   SizeTiny, SizeTeeny, SizeDinky, SizePetite, SizeSlim, SizeSmall,\r
75   SizeMediocre, SizeMiddling, SizeAverage, SizeModerate, SizeMedium,\r
76   SizeBulky, SizeLarge, SizeBig, SizeHuge, SizeGiant, SizeColossal,\r
77   SizeTitanic, NUM_SIZES \r
78 } BoardSize;\r
79 \r
80 typedef struct {\r
81     COLORREF color;\r
82     int effects;\r
83     char *name;\r
84 } MyColorizeAttribs;\r
85 \r
86 typedef struct {\r
87   char* name;\r
88   void* data;\r
89   int flag; // [HGM] needed to indicate if data was malloc'ed or not\r
90 } MySound;\r
91 \r
92 typedef struct {\r
93     COLORREF color;\r
94     int effects;\r
95     MySound sound;\r
96 } MyTextAttribs;\r
97 \r
98 /* Functions */\r
99 \r
100 BOOL InitApplication(HINSTANCE);\r
101 BOOL InitInstance(HINSTANCE, int, LPSTR);\r
102 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);\r
103 LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);\r
104 LRESULT CALLBACK BoardSizeDlg(HWND, UINT, WPARAM, LPARAM);\r
105 LRESULT CALLBACK ButtonProc(HWND, UINT, WPARAM, LPARAM);\r
106 VOID InitAppData(LPSTR);\r
107 VOID InitDrawingColors(VOID);\r
108 VOID InitDrawingSizes(BoardSize boardSize, int flags);\r
109 VOID InitMenuChecks(VOID);\r
110 int  ICSInitScript(VOID);\r
111 BOOL CenterWindow(HWND hwndChild, HWND hwndParent);\r
112 VOID ResizeEditPlusButtons(HWND hDlg, HWND hText, int sizeX, int sizeY, int newSizeX, int newSizeY);\r
113 VOID PromotionPopup(HWND hwnd);\r
114 FILE *OpenFileDialog(HWND hWnd, char *write, char *defName, char *defExt, \r
115                      char *nameFilt, char *dlgTitle, UINT *number,\r
116                      char fileTitle[MSG_SIZ], char fileName[MSG_SIZ]);\r
117 VOID InputEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
118 DWORD InputThread(LPVOID arg);\r
119 DWORD NonOvlInputThread(LPVOID arg);\r
120 DWORD SocketInputThread(LPVOID arg);\r
121 BOOL ChangeColor(HWND hwnd, COLORREF *which);\r
122 VOID ChangeBoardSize(BoardSize newSize);\r
123 BOOL APIENTRY MyCreateFont(HWND hwnd, MyFont *font);\r
124 VOID ErrorPopDown(VOID);\r
125 VOID EnsureOnScreen(int *x, int *y, int minX, int minY);\r
126 HBITMAP \r
127 DoLoadBitmap(HINSTANCE hinst, char *piece, int squareSize, char *suffix);\r
128 COLORREF ParseColorName(char *name);\r
129 void ParseAttribs(COLORREF *color, int *effects, char* argValue);\r
130 VOID CreateFontInMF(MyFont *mf);\r
131 VOID ChangedConsoleFont();\r
132 VOID ParseFontName(char *name, MyFontParams *mfp);\r
133 void InitComboStrings(HANDLE hwndCombo, char **cd);\r
134 BOOLEAN MyLoadSound(MySound *ms);\r
135 BOOLEAN MyPlaySound(MySound *ms);\r
136 VOID ExitArgError(char *msg, char *badArg, Boolean quit);\r
137 void SaveSettings(char* name);\r
138 BOOL BrowseForFolder( const char * title, char * path );\r
139 VOID TourneyPopup();\r
140 VOID LoadEnginePopUp();\r
141 VOID LoadOptionsPopup(HWND hDlg);\r
142 VOID InitTextures();\r
143 void ThemeOptionsPopup(HWND hwnd);\r
144 \r
145 /* Constants */\r
146 \r
147 #define CLOCK_FONT 0\r
148 #define MESSAGE_FONT 1\r
149 #define COORD_FONT 2\r
150 #define CONSOLE_FONT 3\r
151 #define COMMENT_FONT 4\r
152 #define EDITTAGS_FONT 5\r
153 #define MOVEHISTORY_FONT 6\r
154 #define GAMELIST_FONT 7\r
155 #define NUM_FONTS 8\r
156 \r
157 /* Positions of some menu items.  Origin is zero and separator lines count. */\r
158 /* It's gross that these are needed. */\r
159 #define ACTION_POS 4     /* Posn of "Action" on menu bar */\r
160 #define OPTIONS_POS 6    /* Posn of "Options" on menu bar */\r
161 /* end grossness */\r
162 \r
163 extern MyFont *font[NUM_SIZES][NUM_FONTS];\r
164 \r
165 #define WM_USER_Input                 (WM_USER + 4242)\r
166 #define WM_USER_Mouseleave            (WM_USER + 4243)\r
167 #define WM_USER_GetConsoleBackground  (WM_USER + 4244)\r
168 \r
169 #define CLOCK_TIMER_ID        51\r
170 #define LOAD_GAME_TIMER_ID    52\r
171 #define ANALYSIS_TIMER_ID     53\r
172 #define MOUSE_TIMER_ID        54\r
173 #define DELAYED_TIMER_ID      55\r
174 \r
175 #define SOLID_PIECE           0\r
176 #define OUTLINE_PIECE         1\r
177 #define WHITE_PIECE           2\r
178 \r
179 #define COPY_TMP "wbcopy.tmp"\r
180 #define PASTE_TMP "wbpaste.tmp"\r
181 \r
182 /* variables */\r
183 extern HINSTANCE hInst;\r
184 extern HWND hwndMain;\r
185 extern BoardSize boardSize;\r
186 \r
187 // [HGM] Some stuff to allo a platform-independent reference to windows\r
188 // This should be moved to frontend.h in due time\r
189 \r
190 typedef enum {\r
191   W_Main, W_Console, W_Comment, W_Tags, W_GameList, \r
192   W_MoveHist, W_EngineOut, NUM_WINDOWS\r
193 } WindowID;\r
194 \r
195 extern WindowPlacement placementTab[NUM_WINDOWS];\r
196 extern HWND hwndTab[NUM_WINDOWS]; // this remains pure front-end.\r
197 \r
198 void Translate( HWND hDlg, int id);\r
199 VOID InitWindowPlacement( WindowPlacement * wp );\r
200 VOID RestoreWindowPlacement( HWND hWnd, WindowPlacement * wp );\r
201 VOID ReattachAfterMove( LPRECT lprcOldPos, int new_x, int new_y, HWND hWndChild, WindowPlacement * pwpChild );\r
202 VOID ReattachAfterSize( LPRECT lprcOldPos, int new_w, int new_h, HWND hWndChild, WindowPlacement * pwpChild );\r
203 BOOL GetActualPlacement( HWND hWnd, WindowPlacement * wp );\r
204 \r
205 VOID MoveHistoryPopUp();\r
206 VOID MoveHistoryPopDown();\r
207 extern HWND moveHistoryDialog;\r
208 \r
209 VOID EvalGraphPopUp();\r
210 VOID EvalGraphPopDown();\r
211 extern HWND evalGraphDialog;\r
212 \r
213 extern HWND engineOutputDialog;\r
214 \r
215 struct GameListStats\r
216 {\r
217     int white_wins;\r
218     int black_wins;\r
219     int drawn;\r
220     int unfinished;\r
221 };\r
222 \r
223 int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos, BOOL narrow );\r
224 VOID ShowGameListProc(void);\r
225 extern HWND gameListDialog;\r
226 \r
227 VOID EditTagsProc(void);\r
228 extern HWND editTagsDialog;\r
229 extern int screenWidth, screenHeight;\r
230 extern RECT screenGeometry; // Top-left coordiate of the screen can be different from (0,0)\r
231 \r