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