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