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