b5cd602ad06908fd8ce762214e0af2c368355652
[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.  Enhancements Copyright\r
6  * 1992-2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software\r
7  * Foundation, Inc.\r
8  *\r
9  * The following terms apply to Digital Equipment Corporation's copyright\r
10  * interest in XBoard:\r
11  * ------------------------------------------------------------------------\r
12  * All Rights Reserved\r
13  *\r
14  * Permission to use, copy, modify, and distribute this software and its\r
15  * documentation for any purpose and without fee is hereby granted,\r
16  * provided that the above copyright notice appear in all copies and that\r
17  * both that copyright notice and this permission notice appear in\r
18  * supporting documentation, and that the name of Digital not be\r
19  * used in advertising or publicity pertaining to distribution of the\r
20  * software without specific, written prior permission.\r
21  *\r
22  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\r
23  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\r
24  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\r
25  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\r
26  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\r
27  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\r
28  * SOFTWARE.\r
29  * ------------------------------------------------------------------------\r
30  *\r
31  * The following terms apply to the enhanced version of XBoard\r
32  * distributed by the Free Software Foundation:\r
33  * ------------------------------------------------------------------------\r
34  *\r
35  * GNU XBoard is free software: you can redistribute it and/or modify\r
36  * it under the terms of the GNU General Public License as published by\r
37  * the Free Software Foundation, either version 3 of the License, or (at\r
38  * your option) any later version.\r
39  *\r
40  * GNU XBoard is distributed in the hope that it will be useful, but\r
41  * WITHOUT ANY WARRANTY; without even the implied warranty of\r
42  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
43  * General Public License for more details.\r
44  *\r
45  * You should have received a copy of the GNU General Public License\r
46  * along with this program. If not, see http://www.gnu.org/licenses/.  *\r
47  *\r
48  *------------------------------------------------------------------------\r
49  ** See the file ChangeLog for a revision history.  */\r
50 \r
51 #include "resource.h"\r
52 #include <dlgs.h>\r
53 \r
54 /* Types */\r
55 typedef struct {\r
56   char faceName[LF_FACESIZE];\r
57   float pointSize;\r
58   BYTE bold, italic, underline, strikeout;\r
59 } MyFontParams;\r
60 \r
61 typedef struct {\r
62   char *def;\r
63   MyFontParams mfp;\r
64   LOGFONT lf;\r
65   HFONT hf;\r
66 } MyFont;\r
67 \r
68 typedef enum { \r
69   SizeTiny, SizeTeeny, SizeDinky, SizePetite, SizeSlim, SizeSmall,\r
70   SizeMediocre, SizeMiddling, SizeAverage, SizeModerate, SizeMedium,\r
71   SizeBulky, SizeLarge, SizeBig, SizeHuge, SizeGiant, SizeColossal,\r
72   SizeTitanic, NUM_SIZES \r
73 } BoardSize;\r
74 \r
75 typedef struct {\r
76     COLORREF color;\r
77     int effects;\r
78     char *name;\r
79 } MyColorizeAttribs;\r
80 \r
81 typedef struct {\r
82   char* name;\r
83   void* data;\r
84 } MySound;\r
85 \r
86 typedef struct {\r
87     COLORREF color;\r
88     int effects;\r
89     MySound sound;\r
90 } MyTextAttribs;\r
91 \r
92 /* Functions */\r
93 \r
94 BOOL InitApplication(HINSTANCE);\r
95 BOOL InitInstance(HINSTANCE, int, LPSTR);\r
96 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);\r
97 LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);\r
98 LRESULT CALLBACK BoardSizeDlg(HWND, UINT, WPARAM, LPARAM);\r
99 LRESULT CALLBACK ButtonProc(HWND, UINT, WPARAM, LPARAM);\r
100 VOID InitAppData(LPSTR);\r
101 VOID InitDrawingColors(VOID);\r
102 VOID InitDrawingSizes(BoardSize boardSize, int flags);\r
103 VOID InitMenuChecks(VOID);\r
104 VOID ICSInitScript(VOID);\r
105 BOOL CenterWindow(HWND hwndChild, HWND hwndParent);\r
106 VOID ResizeEditPlusButtons(HWND hDlg, HWND hText, int sizeX, int sizeY, int newSizeX, int newSizeY);\r
107 VOID PromotionPopup(HWND hwnd);\r
108 FILE *OpenFileDialog(HWND hWnd, char *write, char *defName, char *defExt, \r
109                      char *nameFilt, char *dlgTitle, UINT *number,\r
110                      char fileTitle[MSG_SIZ], char fileName[MSG_SIZ]);\r
111 VOID InputEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
112 DWORD InputThread(LPVOID arg);\r
113 DWORD NonOvlInputThread(LPVOID arg);\r
114 DWORD SocketInputThread(LPVOID arg);\r
115 BOOL ChangeColor(HWND hwnd, COLORREF *which);\r
116 VOID ChangeBoardSize(BoardSize newSize);\r
117 BOOL APIENTRY MyCreateFont(HWND hwnd, MyFont *font);\r
118 VOID ErrorPopDown(VOID);\r
119 VOID EnsureOnScreen(int *x, int *y, int minX, int minY);\r
120 typedef char GetFunc(void *getClosure);\r
121 VOID ParseArgs(GetFunc get, void *cl);\r
122 HBITMAP \r
123 DoLoadBitmap(HINSTANCE hinst, char *piece, int squareSize, char *suffix);\r
124 COLORREF ParseColorName(char *name);\r
125 void ParseAttribs(COLORREF *color, int *effects, char* argValue);\r
126 VOID CreateFontInMF(MyFont *mf);\r
127 VOID ChangedConsoleFont();\r
128 VOID ParseFontName(char *name, MyFontParams *mfp);\r
129 void InitComboStrings(HANDLE hwndCombo, char **cd);\r
130 BOOLEAN MyLoadSound(MySound *ms);\r
131 BOOLEAN MyPlaySound(MySound *ms);\r
132 VOID ExitArgError(char *msg, char *badArg);\r
133 \r
134 /* Constants */\r
135 \r
136 #define CLOCK_FONT 0\r
137 #define MESSAGE_FONT 1\r
138 #define COORD_FONT 2\r
139 #define CONSOLE_FONT 3\r
140 #define COMMENT_FONT 4\r
141 #define EDITTAGS_FONT 5\r
142 #define MOVEHISTORY_FONT 6\r
143 #define NUM_FONTS 7\r
144 \r
145 /* Positions of some menu items.  Origin is zero and separator lines count. */\r
146 /* It's gross that these are needed. */\r
147 #define ACTION_POS 2     /* Posn of "Action" on menu bar */\r
148 #define OPTIONS_POS 4    /* Posn of "Options" on menu bar */\r
149 #define ICS_POS 4        /* Posn of "ICS " on Options menu */\r
150 #define SOUNDS_POS 6     /* Posn of "Sounds" on Options menu */\r
151 /* end grossness */\r
152 \r
153 extern MyFont *font[NUM_SIZES][NUM_FONTS];\r
154 \r
155 #define WM_USER_Input                 (WM_USER + 4242)\r
156 #define WM_USER_Mouseleave            (WM_USER + 4243)\r
157 #define WM_USER_GetConsoleBackground  (WM_USER + 4244)\r
158 \r
159 #define CLOCK_TIMER_ID        51\r
160 #define LOAD_GAME_TIMER_ID    52\r
161 #define ANALYSIS_TIMER_ID     53\r
162 #define MOUSE_TIMER_ID        54\r
163 #define DELAYED_TIMER_ID      55\r
164 \r
165 #define SOLID_PIECE           0\r
166 #define OUTLINE_PIECE         1\r
167 #define WHITE_PIECE           2\r
168 \r
169 #define COPY_TMP "wbcopy.tmp"\r
170 #define PASTE_TMP "wbpaste.tmp"\r
171 \r
172 /* [AS] Layout management */\r
173 typedef struct {\r
174     Boolean visible;\r
175     int x;\r
176     int y;\r
177     int width;\r
178     int height;\r
179 } WindowPlacement;\r
180 \r
181 VOID InitWindowPlacement( WindowPlacement * wp );\r
182 \r
183 VOID RestoreWindowPlacement( HWND hWnd, WindowPlacement * wp );\r
184 \r
185 VOID ReattachAfterMove( LPRECT lprcOldPos, int new_x, int new_y, HWND hWndChild, WindowPlacement * pwpChild );\r
186 \r
187 VOID ReattachAfterSize( LPRECT lprcOldPos, int new_w, int new_h, HWND hWndChild, WindowPlacement * pwpChild );\r