mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Remove old Windows CE cruft.
The WinCE version of these puzzles hasn't been built for years, and the last vestiges of its build system vanished with the migration to CMake. So this seems like a good moment to lose the rest of it. So the supporting Perl script wceinf.pl is deleted, and so is all the unused code under '#ifdef _WIN32_WCE' in windows.c. (I removed that using unifdef, which did a more reliable job than I would have done by hand!)
This commit is contained in:
65
wceinf.pl
65
wceinf.pl
@ -1,65 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
# Perl script to generate a .INF file for building a Pocket PC .CAB
|
|
||||||
# archive of Puzzles. This has to be scripted so that it can read
|
|
||||||
# gamedesc.txt and automatically adjust to the current available
|
|
||||||
# set of puzzles.
|
|
||||||
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# $ ./wceinf.pl gamedesc.txt > puzzles.inf
|
|
||||||
|
|
||||||
$desc = shift @ARGV;
|
|
||||||
open DESC, "<", $desc;
|
|
||||||
while (<DESC>) {
|
|
||||||
chomp;
|
|
||||||
@_ = split /:/;
|
|
||||||
push @exes, $_[1];
|
|
||||||
$names{$_[1]} = $_[2];
|
|
||||||
}
|
|
||||||
close DESC;
|
|
||||||
|
|
||||||
print '[Version]'."\n";
|
|
||||||
print 'Signature = "$Windows NT$" ; required as-is'."\n";
|
|
||||||
print 'Provider = "Simon Tatham" ; full app name will be "<Provider> <AppName>"'."\n";
|
|
||||||
print 'CESignature = "$Windows CE$" ; required as-is'."\n";
|
|
||||||
print ''."\n";
|
|
||||||
print '[CEStrings]'."\n";
|
|
||||||
print 'AppName = "Puzzle Collection" ; full app name will be "<Provider> <AppName>"'."\n";
|
|
||||||
print 'InstallDir = %CE8%\%AppName% ; "\Program Files\Games\Puzzle Collection" (default install directory)'."\n";
|
|
||||||
print ''."\n";
|
|
||||||
print '[CEDevice.x86]'."\n";
|
|
||||||
print 'ProcessorType = 686'."\n";
|
|
||||||
print ''."\n";
|
|
||||||
print '[CEDevice.ARM]'."\n";
|
|
||||||
print 'ProcessorType = 2577'."\n";
|
|
||||||
print ''."\n";
|
|
||||||
print '[SourceDisksNames.x86] ; CPU-dependent files'."\n";
|
|
||||||
print '2 = ,"x86 Files",,.'."\n";
|
|
||||||
print ''."\n";
|
|
||||||
print '[SourceDisksNames.ARMV4] ; CPU-dependent files'."\n";
|
|
||||||
print '2 = ,"ARM Files",,.'."\n";
|
|
||||||
print ''."\n";
|
|
||||||
print '[SourceDisksFiles]'."\n";
|
|
||||||
for $exe (@exes) {
|
|
||||||
print $exe.' = 2'."\n";
|
|
||||||
}
|
|
||||||
print ''."\n";
|
|
||||||
print '[DefaultInstall]'."\n";
|
|
||||||
print 'CopyFiles = PuzzleFiles'."\n";
|
|
||||||
print 'CEShortcuts = Links'."\n";
|
|
||||||
print ''."\n";
|
|
||||||
print '[DestinationDirs]'."\n";
|
|
||||||
print 'PuzzleFiles = 0, %InstallDir%'."\n";
|
|
||||||
print 'Links = 0, %CE14%\Puzzles'."\n";
|
|
||||||
print ''."\n";
|
|
||||||
print ';File copy list.'."\n";
|
|
||||||
print '[PuzzleFiles]'."\n";
|
|
||||||
for $exe (@exes) {
|
|
||||||
print $exe."\n";
|
|
||||||
}
|
|
||||||
print ''."\n";
|
|
||||||
print '[Links]'."\n";
|
|
||||||
for $exe (@exes) {
|
|
||||||
print '"'.$names{$exe}.'",0,'.$exe."\n";
|
|
||||||
}
|
|
531
windows.c
531
windows.c
@ -8,11 +8,6 @@
|
|||||||
#include <htmlhelp.h>
|
#include <htmlhelp.h>
|
||||||
#endif /* NO_HTMLHELP */
|
#endif /* NO_HTMLHELP */
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
#include <commdlg.h>
|
|
||||||
#include <aygshell.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -23,10 +18,6 @@
|
|||||||
|
|
||||||
#include "puzzles.h"
|
#include "puzzles.h"
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
#include "resource.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IDM_NEW 0x0010
|
#define IDM_NEW 0x0010
|
||||||
#define IDM_RESTART 0x0020
|
#define IDM_RESTART 0x0020
|
||||||
#define IDM_UNDO 0x0030
|
#define IDM_UNDO 0x0030
|
||||||
@ -77,50 +68,6 @@ bool help_has_contents;
|
|||||||
#define CLASSNAME thegame.name
|
#define CLASSNAME thegame.name
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Wrapper implementations of functions not supplied by the
|
|
||||||
* PocketPC API.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SHGetSubMenu(hWndMB,ID_MENU) (HMENU)SendMessage((hWndMB), SHCMBM_GETSUBMENU, (WPARAM)0, (LPARAM)ID_MENU)
|
|
||||||
|
|
||||||
#undef MessageBox
|
|
||||||
|
|
||||||
int MessageBox(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
|
|
||||||
{
|
|
||||||
TCHAR wText[2048];
|
|
||||||
TCHAR wCaption[2048];
|
|
||||||
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, lpText, -1, wText, 2048);
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, lpCaption, -1, wCaption, 2048);
|
|
||||||
|
|
||||||
return MessageBoxW (hWnd, wText, wCaption, uType);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL SetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
|
|
||||||
{
|
|
||||||
TCHAR wText[256];
|
|
||||||
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, lpString, -1, wText, 256);
|
|
||||||
return SetDlgItemTextW(hDlg, nIDDlgItem, wText);
|
|
||||||
}
|
|
||||||
|
|
||||||
LPCSTR getenv(LPCSTR buf)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL GetKeyboardState(PBYTE pb)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TCHAR wClassName[256], wGameName[256];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUGGING
|
#ifdef DEBUGGING
|
||||||
static FILE *debug_fp = NULL;
|
static FILE *debug_fp = NULL;
|
||||||
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
|
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
|
||||||
@ -168,12 +115,8 @@ void debug_printf(const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
#define WINFLAGS (WS_OVERLAPPEDWINDOW &~ \
|
#define WINFLAGS (WS_OVERLAPPEDWINDOW &~ \
|
||||||
(WS_MAXIMIZEBOX | WS_OVERLAPPED))
|
(WS_MAXIMIZEBOX | WS_OVERLAPPED))
|
||||||
#else
|
|
||||||
#define WINFLAGS (WS_CAPTION | WS_SYSMENU)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void new_game_size(frontend *fe, float scale);
|
static void new_game_size(frontend *fe, float scale);
|
||||||
|
|
||||||
@ -204,9 +147,6 @@ struct frontend {
|
|||||||
const game *game;
|
const game *game;
|
||||||
midend *me;
|
midend *me;
|
||||||
HWND hwnd, statusbar, cfgbox;
|
HWND hwnd, statusbar, cfgbox;
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
HWND numpad; /* window handle for the numeric pad */
|
|
||||||
#endif
|
|
||||||
HINSTANCE inst;
|
HINSTANCE inst;
|
||||||
HBITMAP bitmap, prevbm;
|
HBITMAP bitmap, prevbm;
|
||||||
RECT bitmapPosition; /* game bitmap position within game window */
|
RECT bitmapPosition; /* game bitmap position within game window */
|
||||||
@ -308,19 +248,9 @@ void get_random_seed(void **randseed, int *randseedsize)
|
|||||||
|
|
||||||
static void win_status_bar(void *handle, const char *text)
|
static void win_status_bar(void *handle, const char *text)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
TCHAR wText[255];
|
|
||||||
#endif
|
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, text, -1, wText, 255);
|
|
||||||
SendMessage(fe->statusbar, SB_SETTEXT,
|
|
||||||
(WPARAM) 255 | SBT_NOBORDERS,
|
|
||||||
(LPARAM) wText);
|
|
||||||
#else
|
|
||||||
SetWindowText(fe->statusbar, text);
|
SetWindowText(fe->statusbar, text);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static blitter *win_blitter_new(void *handle, int w, int h)
|
static blitter *win_blitter_new(void *handle, int w, int h)
|
||||||
@ -464,13 +394,6 @@ static void win_set_brush(frontend *fe, int colour)
|
|||||||
if (hatch < 0) {
|
if (hatch < 0) {
|
||||||
br = CreateSolidBrush(RGB(r * 255, g * 255, b * 255));
|
br = CreateSolidBrush(RGB(r * 255, g * 255, b * 255));
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
/*
|
|
||||||
* This is only ever required during printing, and the
|
|
||||||
* PocketPC port doesn't support printing.
|
|
||||||
*/
|
|
||||||
fatal("CreateHatchBrush not supported");
|
|
||||||
#else
|
|
||||||
br = CreateHatchBrush(hatch == HATCH_BACKSLASH ? HS_FDIAGONAL :
|
br = CreateHatchBrush(hatch == HATCH_BACKSLASH ? HS_FDIAGONAL :
|
||||||
hatch == HATCH_SLASH ? HS_BDIAGONAL :
|
hatch == HATCH_SLASH ? HS_BDIAGONAL :
|
||||||
hatch == HATCH_HORIZ ? HS_HORIZONTAL :
|
hatch == HATCH_HORIZ ? HS_HORIZONTAL :
|
||||||
@ -478,7 +401,6 @@ static void win_set_brush(frontend *fe, int colour)
|
|||||||
hatch == HATCH_PLUS ? HS_CROSS :
|
hatch == HATCH_PLUS ? HS_CROSS :
|
||||||
/* hatch == HATCH_X ? */ HS_DIAGCROSS,
|
/* hatch == HATCH_X ? */ HS_DIAGCROSS,
|
||||||
RGB(0,0,0));
|
RGB(0,0,0));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
br = fe->brushes[colour];
|
br = fe->brushes[colour];
|
||||||
@ -602,9 +524,6 @@ static void win_draw_text(void *handle, int x, int y, int fonttype,
|
|||||||
lf.lfPitchAndFamily = (fonttype == FONT_FIXED ?
|
lf.lfPitchAndFamily = (fonttype == FONT_FIXED ?
|
||||||
FIXED_PITCH | FF_DONTCARE :
|
FIXED_PITCH | FF_DONTCARE :
|
||||||
VARIABLE_PITCH | FF_SWISS);
|
VARIABLE_PITCH | FF_SWISS);
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
wcscpy(lf.lfFaceName, TEXT("Tahoma"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fe->fonts[i].font = CreateFontIndirect(&lf);
|
fe->fonts[i].font = CreateFontIndirect(&lf);
|
||||||
}
|
}
|
||||||
@ -754,9 +673,7 @@ static void win_start_draw(void *handle)
|
|||||||
fe->prevbm = SelectObject(fe->hdc, fe->bitmap);
|
fe->prevbm = SelectObject(fe->hdc, fe->bitmap);
|
||||||
ReleaseDC(fe->hwnd, hdc_win);
|
ReleaseDC(fe->hwnd, hdc_win);
|
||||||
fe->clip = NULL;
|
fe->clip = NULL;
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
SetMapMode(fe->hdc, MM_TEXT);
|
SetMapMode(fe->hdc, MM_TEXT);
|
||||||
#endif
|
|
||||||
fe->drawstatus = DRAWING;
|
fe->drawstatus = DRAWING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -999,7 +916,6 @@ const struct drawing_api win_drawing = {
|
|||||||
|
|
||||||
void print(frontend *fe)
|
void print(frontend *fe)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
PRINTDLG pd;
|
PRINTDLG pd;
|
||||||
char doctitle[256];
|
char doctitle[256];
|
||||||
document *doc;
|
document *doc;
|
||||||
@ -1090,7 +1006,6 @@ void print(frontend *fe)
|
|||||||
|
|
||||||
DeleteDC(pd.hDC);
|
DeleteDC(pd.hDC);
|
||||||
document_free(doc);
|
document_free(doc);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void deactivate_timer(frontend *fe)
|
void deactivate_timer(frontend *fe)
|
||||||
@ -1168,7 +1083,6 @@ void write_clip(HWND hwnd, char *data)
|
|||||||
*/
|
*/
|
||||||
static void init_help(void)
|
static void init_help(void)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
char b[2048], *p, *q, *r;
|
char b[2048], *p, *q, *r;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
@ -1232,11 +1146,8 @@ static void init_help(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
help_type = NONE; /* didn't find any */
|
help_type = NONE; /* didn't find any */
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start Help.
|
* Start Help.
|
||||||
*/
|
*/
|
||||||
@ -1306,8 +1217,6 @@ static void stop_help(frontend *fe)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Terminate Help on process exit.
|
* Terminate Help on process exit.
|
||||||
*/
|
*/
|
||||||
@ -1338,10 +1247,8 @@ static void adjust_statusbar(frontend *fe, RECT *r)
|
|||||||
if (!fe->statusbar) return;
|
if (!fe->statusbar) return;
|
||||||
|
|
||||||
sy = get_statusbar_height(fe);
|
sy = get_statusbar_height(fe);
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
SetWindowPos(fe->statusbar, NULL, 0, r->bottom-r->top-sy, r->right-r->left,
|
SetWindowPos(fe->statusbar, NULL, 0, r->bottom-r->top-sy, r->right-r->left,
|
||||||
sy, SWP_NOZORDER);
|
sy, SWP_NOZORDER);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_menu_size(HWND wh, RECT *r)
|
static void get_menu_size(HWND wh, RECT *r)
|
||||||
@ -1416,13 +1323,7 @@ static void check_window_size(frontend *fe, int *px, int *py)
|
|||||||
cx = r.right - r.left;
|
cx = r.right - r.left;
|
||||||
cy = r.bottom - r.top;
|
cy = r.bottom - r.top;
|
||||||
|
|
||||||
if (check_window_resize(fe, cx, cy, px, py, &wx, &wy)) {
|
check_window_resize(fe, cx, cy, px, py, &wx, &wy);
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
SetWindowPos(fe->hwnd, NULL, 0, 0, wx, wy,
|
|
||||||
SWP_NOMOVE | SWP_NOZORDER);
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetClientRect(fe->hwnd, &r);
|
GetClientRect(fe->hwnd, &r);
|
||||||
adjust_statusbar(fe, &r);
|
adjust_statusbar(fe, &r);
|
||||||
@ -1452,23 +1353,6 @@ static void get_max_puzzle_size(frontend *fe, int *x, int *y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
/* Toolbar buttons on the numeric pad */
|
|
||||||
static TBBUTTON tbNumpadButtons[] =
|
|
||||||
{
|
|
||||||
{0, IDM_KEYEMUL + '1', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{1, IDM_KEYEMUL + '2', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{2, IDM_KEYEMUL + '3', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{3, IDM_KEYEMUL + '4', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{4, IDM_KEYEMUL + '5', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{5, IDM_KEYEMUL + '6', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{6, IDM_KEYEMUL + '7', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{7, IDM_KEYEMUL + '8', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{8, IDM_KEYEMUL + '9', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1},
|
|
||||||
{9, IDM_KEYEMUL + ' ', TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, -1}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a new frontend structure and create its main window.
|
* Allocate a new frontend structure and create its main window.
|
||||||
*/
|
*/
|
||||||
@ -1502,34 +1386,6 @@ static frontend *frontend_new(HINSTANCE inst)
|
|||||||
|
|
||||||
fe->puzz_scale = 1.0;
|
fe->puzz_scale = 1.0;
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, nogame, -1, wGameName, 256);
|
|
||||||
fe->hwnd = CreateWindowEx(0, wClassName, wGameName,
|
|
||||||
WS_VISIBLE,
|
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
||||||
NULL, NULL, inst, NULL);
|
|
||||||
|
|
||||||
{
|
|
||||||
SHMENUBARINFO mbi;
|
|
||||||
RECT rc, rcBar, rcTB, rcClient;
|
|
||||||
|
|
||||||
memset (&mbi, 0, sizeof(SHMENUBARINFO));
|
|
||||||
mbi.cbSize = sizeof(SHMENUBARINFO);
|
|
||||||
mbi.hwndParent = fe->hwnd;
|
|
||||||
mbi.nToolBarId = IDR_MENUBAR1;
|
|
||||||
mbi.hInstRes = inst;
|
|
||||||
|
|
||||||
SHCreateMenuBar(&mbi);
|
|
||||||
|
|
||||||
GetWindowRect(fe->hwnd, &rc);
|
|
||||||
GetWindowRect(mbi.hwndMB, &rcBar);
|
|
||||||
rc.bottom -= rcBar.bottom - rcBar.top;
|
|
||||||
MoveWindow(fe->hwnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, false);
|
|
||||||
|
|
||||||
fe->numpad = NULL;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
fe->hwnd = CreateWindowEx(0, CLASSNAME, nogame,
|
fe->hwnd = CreateWindowEx(0, CLASSNAME, nogame,
|
||||||
WS_OVERLAPPEDWINDOW &~
|
WS_OVERLAPPEDWINDOW &~
|
||||||
(WS_MAXIMIZEBOX),
|
(WS_MAXIMIZEBOX),
|
||||||
@ -1540,7 +1396,6 @@ static frontend *frontend_new(HINSTANCE inst)
|
|||||||
DWORD lerr = GetLastError();
|
DWORD lerr = GetLastError();
|
||||||
printf("no window: 0x%x\n", (unsigned)lerr);
|
printf("no window: 0x%x\n", (unsigned)lerr);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
fe->gamemenu = NULL;
|
fe->gamemenu = NULL;
|
||||||
fe->preset_menu = NULL;
|
fe->preset_menu = NULL;
|
||||||
@ -1694,15 +1549,7 @@ static void populate_preset_menu(frontend *fe,
|
|||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
AppendMenu(winmenu, flags, id_or_sub, entry->title);
|
AppendMenu(winmenu, flags, id_or_sub, entry->title);
|
||||||
#else
|
|
||||||
{
|
|
||||||
TCHAR wName[255];
|
|
||||||
MultiByteToWideChar(CP_ACP, 0, entry->title, -1, wName, 255);
|
|
||||||
AppendMenu(winmenu, flags, id_or_sub, wName);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1770,34 +1617,7 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
r.bottom = y;
|
r.bottom = y;
|
||||||
AdjustWindowRectEx(&r, WINFLAGS, true, 0);
|
AdjustWindowRectEx(&r, WINFLAGS, true, 0);
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
if (fe->numpad)
|
|
||||||
DestroyWindow(fe->numpad);
|
|
||||||
if (fe->game->flags & REQUIRE_NUMPAD)
|
|
||||||
{
|
|
||||||
fe->numpad = CreateToolbarEx (fe->hwnd,
|
|
||||||
WS_VISIBLE | WS_CHILD | CCS_NOPARENTALIGN | TBSTYLE_FLAT,
|
|
||||||
0, 10, fe->inst, IDR_PADTOOLBAR,
|
|
||||||
tbNumpadButtons, sizeof (tbNumpadButtons) / sizeof (TBBUTTON),
|
|
||||||
0, 0, 14, 15, sizeof (TBBUTTON));
|
|
||||||
GetWindowRect(fe->numpad, &rcTB);
|
|
||||||
GetClientRect(fe->hwnd, &rcClient);
|
|
||||||
MoveWindow(fe->numpad,
|
|
||||||
0,
|
|
||||||
rcClient.bottom - (rcTB.bottom - rcTB.top) - 1,
|
|
||||||
rcClient.right,
|
|
||||||
rcTB.bottom - rcTB.top,
|
|
||||||
false);
|
|
||||||
SendMessage(fe->numpad, TB_SETINDENT, (rcClient.right - (10 * 21)) / 2, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fe->numpad = NULL;
|
|
||||||
}
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, fe->game->name, -1, wGameName, 256);
|
|
||||||
SetWindowText(fe->hwnd, wGameName);
|
|
||||||
#else
|
|
||||||
SetWindowText(fe->hwnd, fe->game->name);
|
SetWindowText(fe->hwnd, fe->game->name);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fe->statusbar)
|
if (fe->statusbar)
|
||||||
DestroyWindow(fe->statusbar);
|
DestroyWindow(fe->statusbar);
|
||||||
@ -1807,24 +1627,15 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
WS_CHILD | WS_VISIBLE,
|
WS_CHILD | WS_VISIBLE,
|
||||||
0, 0, 0, 0, /* status bar does these */
|
0, 0, 0, 0, /* status bar does these */
|
||||||
fe->hwnd, NULL, fe->inst, NULL);
|
fe->hwnd, NULL, fe->inst, NULL);
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
/* Flat status bar looks better on the Pocket PC */
|
|
||||||
SendMessage(fe->statusbar, SB_SIMPLE, (WPARAM) true, 0);
|
|
||||||
SendMessage(fe->statusbar, SB_SETTEXT,
|
|
||||||
(WPARAM) 255 | SBT_NOBORDERS,
|
|
||||||
(LPARAM) L"");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now resize the window to take account of the status bar.
|
* Now resize the window to take account of the status bar.
|
||||||
*/
|
*/
|
||||||
GetWindowRect(fe->statusbar, &sr);
|
GetWindowRect(fe->statusbar, &sr);
|
||||||
GetWindowRect(fe->hwnd, &r);
|
GetWindowRect(fe->hwnd, &r);
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
SetWindowPos(fe->hwnd, NULL, 0, 0, r.right - r.left,
|
SetWindowPos(fe->hwnd, NULL, 0, 0, r.right - r.left,
|
||||||
r.bottom - r.top + sr.bottom - sr.top,
|
r.bottom - r.top + sr.bottom - sr.top,
|
||||||
SWP_NOMOVE | SWP_NOZORDER);
|
SWP_NOMOVE | SWP_NOZORDER);
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
fe->statusbar = NULL;
|
fe->statusbar = NULL;
|
||||||
}
|
}
|
||||||
@ -1832,24 +1643,17 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
{
|
{
|
||||||
HMENU oldmenu = GetMenu(fe->hwnd);
|
HMENU oldmenu = GetMenu(fe->hwnd);
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
HMENU bar = CreateMenu();
|
HMENU bar = CreateMenu();
|
||||||
HMENU menu = CreateMenu();
|
HMENU menu = CreateMenu();
|
||||||
RECT menusize;
|
RECT menusize;
|
||||||
|
|
||||||
AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)menu, "&Game");
|
AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)menu, "&Game");
|
||||||
#else
|
|
||||||
HMENU menu = SHGetSubMenu(SHFindMenuBar(fe->hwnd), ID_GAME);
|
|
||||||
DeleteMenu(menu, 0, MF_BYPOSITION);
|
|
||||||
#endif
|
|
||||||
fe->gamemenu = menu;
|
fe->gamemenu = menu;
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_NEW, TEXT("&New"));
|
AppendMenu(menu, MF_ENABLED, IDM_NEW, TEXT("&New"));
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_RESTART, TEXT("&Restart"));
|
AppendMenu(menu, MF_ENABLED, IDM_RESTART, TEXT("&Restart"));
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
/* ...here I run out of sensible accelerator characters. */
|
/* ...here I run out of sensible accelerator characters. */
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_DESC, TEXT("Speci&fic..."));
|
AppendMenu(menu, MF_ENABLED, IDM_DESC, TEXT("Speci&fic..."));
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_SEED, TEXT("Rando&m Seed..."));
|
AppendMenu(menu, MF_ENABLED, IDM_SEED, TEXT("Rando&m Seed..."));
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(!fe->preset_menu);
|
assert(!fe->preset_menu);
|
||||||
|
|
||||||
@ -1863,14 +1667,9 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
fe->preset_menuitems[i].which_menu = NULL;
|
fe->preset_menuitems[i].which_menu = NULL;
|
||||||
}
|
}
|
||||||
if (fe->preset_menu->n_entries > 0 || fe->game->can_configure) {
|
if (fe->preset_menu->n_entries > 0 || fe->game->can_configure) {
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
HMENU sub = CreateMenu();
|
HMENU sub = CreateMenu();
|
||||||
|
|
||||||
AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)sub, "&Type");
|
AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)sub, "&Type");
|
||||||
#else
|
|
||||||
HMENU sub = SHGetSubMenu(SHFindMenuBar(fe->hwnd), ID_TYPE);
|
|
||||||
DeleteMenu(sub, 0, MF_BYPOSITION);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
populate_preset_menu(fe, fe->preset_menu, sub);
|
populate_preset_menu(fe, fe->preset_menu, sub);
|
||||||
|
|
||||||
@ -1884,9 +1683,6 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COMBINED
|
#ifdef COMBINED
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
#error Windows CE does not support COMBINED build.
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
HMENU games = CreateMenu();
|
HMENU games = CreateMenu();
|
||||||
int i;
|
int i;
|
||||||
@ -1904,7 +1700,6 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_LOAD, TEXT("&Load..."));
|
AppendMenu(menu, MF_ENABLED, IDM_LOAD, TEXT("&Load..."));
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_SAVE, TEXT("&Save..."));
|
AppendMenu(menu, MF_ENABLED, IDM_SAVE, TEXT("&Save..."));
|
||||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||||
@ -1912,27 +1707,21 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
AppendMenu(menu, MF_ENABLED, IDM_PRINT, TEXT("&Print..."));
|
AppendMenu(menu, MF_ENABLED, IDM_PRINT, TEXT("&Print..."));
|
||||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_UNDO, TEXT("Undo"));
|
AppendMenu(menu, MF_ENABLED, IDM_UNDO, TEXT("Undo"));
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_REDO, TEXT("Redo"));
|
AppendMenu(menu, MF_ENABLED, IDM_REDO, TEXT("Redo"));
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
if (fe->game->can_format_as_text_ever) {
|
if (fe->game->can_format_as_text_ever) {
|
||||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_COPY, TEXT("&Copy"));
|
AppendMenu(menu, MF_ENABLED, IDM_COPY, TEXT("&Copy"));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (fe->game->can_solve) {
|
if (fe->game->can_solve) {
|
||||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_SOLVE, TEXT("Sol&ve"));
|
AppendMenu(menu, MF_ENABLED, IDM_SOLVE, TEXT("Sol&ve"));
|
||||||
}
|
}
|
||||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_QUIT, TEXT("E&xit"));
|
AppendMenu(menu, MF_ENABLED, IDM_QUIT, TEXT("E&xit"));
|
||||||
menu = CreateMenu();
|
menu = CreateMenu();
|
||||||
AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)menu, TEXT("&Help"));
|
AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)menu, TEXT("&Help"));
|
||||||
#endif
|
|
||||||
AppendMenu(menu, MF_ENABLED, IDM_ABOUT, TEXT("&About"));
|
AppendMenu(menu, MF_ENABLED, IDM_ABOUT, TEXT("&About"));
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
if (help_type != NONE) {
|
if (help_type != NONE) {
|
||||||
char *item;
|
char *item;
|
||||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||||
@ -1947,7 +1736,6 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
SetMenu(fe->hwnd, bar);
|
SetMenu(fe->hwnd, bar);
|
||||||
get_menu_size(fe->hwnd, &menusize);
|
get_menu_size(fe->hwnd, &menusize);
|
||||||
fe->xmin = (menusize.right - menusize.left) + 25;
|
fe->xmin = (menusize.right - menusize.left) + 25;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fe->bitmap) DeleteObject(fe->bitmap);
|
if (fe->bitmap) DeleteObject(fe->bitmap);
|
||||||
@ -1968,36 +1756,6 @@ static void show_window(frontend *fe)
|
|||||||
midend_redraw(fe->me);
|
midend_redraw(fe->me);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
static HFONT dialog_title_font()
|
|
||||||
{
|
|
||||||
static HFONT hf = NULL;
|
|
||||||
LOGFONT lf;
|
|
||||||
|
|
||||||
if (hf)
|
|
||||||
return hf;
|
|
||||||
|
|
||||||
memset (&lf, 0, sizeof(LOGFONT));
|
|
||||||
lf.lfHeight = -11; /* - ((8 * GetDeviceCaps(hdc, LOGPIXELSY)) / 72) */
|
|
||||||
lf.lfWeight = FW_BOLD;
|
|
||||||
wcscpy(lf.lfFaceName, TEXT("Tahoma"));
|
|
||||||
|
|
||||||
return hf = CreateFontIndirect(&lf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void make_dialog_full_screen(HWND hwnd)
|
|
||||||
{
|
|
||||||
SHINITDLGINFO shidi;
|
|
||||||
|
|
||||||
/* Make dialog full screen */
|
|
||||||
shidi.dwMask = SHIDIM_FLAGS;
|
|
||||||
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIZEDLGFULLSCREEN |
|
|
||||||
SHIDIF_EMPTYMENU;
|
|
||||||
shidi.hDlg = hwnd;
|
|
||||||
SHInitDialog(&shidi);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int CALLBACK AboutDlgProc(HWND hwnd, UINT msg,
|
static int CALLBACK AboutDlgProc(HWND hwnd, UINT msg,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@ -2005,39 +1763,15 @@ static int CALLBACK AboutDlgProc(HWND hwnd, UINT msg,
|
|||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
{
|
|
||||||
char title[256];
|
|
||||||
|
|
||||||
make_dialog_full_screen(hwnd);
|
|
||||||
|
|
||||||
sprintf(title, "About %.250s", fe->game->name);
|
|
||||||
SetDlgItemTextA(hwnd, IDC_ABOUT_CAPTION, title);
|
|
||||||
|
|
||||||
SendDlgItemMessage(hwnd, IDC_ABOUT_CAPTION, WM_SETFONT,
|
|
||||||
(WPARAM) dialog_title_font(), 0);
|
|
||||||
|
|
||||||
SetDlgItemTextA(hwnd, IDC_ABOUT_GAME, fe->game->name);
|
|
||||||
SetDlgItemTextA(hwnd, IDC_ABOUT_VERSION, ver);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if (LOWORD(wParam) == IDOK)
|
if (LOWORD(wParam) == IDOK)
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
EndDialog(hwnd, 1);
|
|
||||||
#else
|
|
||||||
fe->dlg_done = 1;
|
fe->dlg_done = 1;
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
EndDialog(hwnd, 1);
|
|
||||||
#else
|
|
||||||
fe->dlg_done = 1;
|
fe->dlg_done = 1;
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2137,119 +1871,6 @@ static const char *frontend_set_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
/* Separate version of mkctrl function for the Pocket PC. */
|
|
||||||
/* Control coordinates should be specified in dialog units. */
|
|
||||||
HWND mkctrl(frontend *fe, int x1, int x2, int y1, int y2,
|
|
||||||
LPCTSTR wclass, int wstyle,
|
|
||||||
int exstyle, const char *wtext, INT_PTR wid)
|
|
||||||
{
|
|
||||||
RECT rc;
|
|
||||||
TCHAR wwtext[256];
|
|
||||||
|
|
||||||
/* Convert dialog units into pixels */
|
|
||||||
rc.left = x1; rc.right = x2;
|
|
||||||
rc.top = y1; rc.bottom = y2;
|
|
||||||
MapDialogRect(fe->cfgbox, &rc);
|
|
||||||
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, wtext, -1, wwtext, 256);
|
|
||||||
|
|
||||||
return CreateWindowEx(exstyle, wclass, wwtext,
|
|
||||||
wstyle | WS_CHILD | WS_VISIBLE,
|
|
||||||
rc.left, rc.top,
|
|
||||||
rc.right - rc.left, rc.bottom - rc.top,
|
|
||||||
fe->cfgbox, (HMENU) wid, fe->inst, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void create_config_controls(frontend * fe)
|
|
||||||
{
|
|
||||||
int id, nctrls;
|
|
||||||
int col1l, col1r, col2l, col2r, y;
|
|
||||||
config_item *i;
|
|
||||||
struct cfg_aux *j;
|
|
||||||
HWND ctl;
|
|
||||||
|
|
||||||
/* Control placement done in dialog units */
|
|
||||||
col1l = 4; col1r = 96; /* Label column */
|
|
||||||
col2l = 100; col2r = 154; /* Input column (edit boxes and combo boxes) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Count the controls so we can allocate cfgaux.
|
|
||||||
*/
|
|
||||||
for (nctrls = 0, i = fe->cfg; i->type != C_END; i++)
|
|
||||||
nctrls++;
|
|
||||||
fe->cfgaux = snewn(nctrls, struct cfg_aux);
|
|
||||||
|
|
||||||
id = 1000;
|
|
||||||
y = 22; /* Leave some room for the dialog title */
|
|
||||||
for (i = fe->cfg, j = fe->cfgaux; i->type != C_END; i++, j++) {
|
|
||||||
switch (i->type) {
|
|
||||||
case C_STRING:
|
|
||||||
/*
|
|
||||||
* Edit box with a label beside it.
|
|
||||||
*/
|
|
||||||
mkctrl(fe, col1l, col1r, y + 1, y + 11,
|
|
||||||
TEXT("Static"), SS_LEFTNOWORDWRAP, 0, i->name, id++);
|
|
||||||
mkctrl(fe, col2l, col2r, y, y + 12,
|
|
||||||
TEXT("EDIT"), WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL,
|
|
||||||
0, "", (j->ctlid = id++));
|
|
||||||
SetDlgItemTextA(fe->cfgbox, j->ctlid, i->u.string.sval);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case C_BOOLEAN:
|
|
||||||
/*
|
|
||||||
* Simple checkbox.
|
|
||||||
*/
|
|
||||||
mkctrl(fe, col1l, col2r, y + 1, y + 11, TEXT("BUTTON"),
|
|
||||||
BS_NOTIFY | BS_AUTOCHECKBOX | WS_TABSTOP,
|
|
||||||
0, i->name, (j->ctlid = id++));
|
|
||||||
CheckDlgButton(fe->cfgbox, j->ctlid, (i->u.boolean.bval != 0));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case C_CHOICES:
|
|
||||||
/*
|
|
||||||
* Drop-down list with a label beside it.
|
|
||||||
*/
|
|
||||||
mkctrl(fe, col1l, col1r, y + 1, y + 11,
|
|
||||||
TEXT("STATIC"), SS_LEFTNOWORDWRAP, 0, i->name, id++);
|
|
||||||
ctl = mkctrl(fe, col2l, col2r, y, y + 48,
|
|
||||||
TEXT("COMBOBOX"), WS_BORDER | WS_TABSTOP |
|
|
||||||
CBS_DROPDOWNLIST | CBS_HASSTRINGS,
|
|
||||||
0, "", (j->ctlid = id++));
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
const char *p, *q;
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
p = i->u.choices.choicenames;
|
|
||||||
c = *p++;
|
|
||||||
while (*p) {
|
|
||||||
q = p;
|
|
||||||
while (*q && *q != c) q++;
|
|
||||||
str = snewn(q-p+1, char);
|
|
||||||
strncpy(str, p, q-p);
|
|
||||||
str[q-p] = '\0';
|
|
||||||
{
|
|
||||||
TCHAR ws[50];
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, str, -1, ws, 50);
|
|
||||||
SendMessage(ctl, CB_ADDSTRING, 0, (LPARAM)ws);
|
|
||||||
}
|
|
||||||
|
|
||||||
sfree(str);
|
|
||||||
if (*q) q++;
|
|
||||||
p = q;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SendMessage(ctl, CB_SETCURSEL, i->u.choices.selected, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
y += 15;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int CALLBACK ConfigDlgProc(HWND hwnd, UINT msg,
|
static int CALLBACK ConfigDlgProc(HWND hwnd, UINT msg,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@ -2259,25 +1880,6 @@ static int CALLBACK ConfigDlgProc(HWND hwnd, UINT msg,
|
|||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
{
|
|
||||||
char *title;
|
|
||||||
|
|
||||||
fe = (frontend *) lParam;
|
|
||||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
|
|
||||||
fe->cfgbox = hwnd;
|
|
||||||
|
|
||||||
fe->cfg = frontend_get_config(fe, fe->cfg_which, &title);
|
|
||||||
|
|
||||||
make_dialog_full_screen(hwnd);
|
|
||||||
|
|
||||||
SetDlgItemTextA(hwnd, IDC_CONFIG_CAPTION, title);
|
|
||||||
SendDlgItemMessage(hwnd, IDC_CONFIG_CAPTION, WM_SETFONT,
|
|
||||||
(WPARAM) dialog_title_font(), 0);
|
|
||||||
|
|
||||||
create_config_controls(fe);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
@ -2293,18 +1895,10 @@ static int CALLBACK ConfigDlgProc(HWND hwnd, UINT msg,
|
|||||||
MessageBox(hwnd, err, "Validation error",
|
MessageBox(hwnd, err, "Validation error",
|
||||||
MB_ICONERROR | MB_OK);
|
MB_ICONERROR | MB_OK);
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
EndDialog(hwnd, 2);
|
|
||||||
#else
|
|
||||||
fe->dlg_done = 2;
|
fe->dlg_done = 2;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
EndDialog(hwnd, 1);
|
|
||||||
#else
|
|
||||||
fe->dlg_done = 1;
|
fe->dlg_done = 1;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2321,13 +1915,7 @@ static int CALLBACK ConfigDlgProc(HWND hwnd, UINT msg,
|
|||||||
|
|
||||||
if (i->type == C_STRING && HIWORD(wParam) == EN_CHANGE) {
|
if (i->type == C_STRING && HIWORD(wParam) == EN_CHANGE) {
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
TCHAR wBuffer[4096];
|
|
||||||
GetDlgItemText(fe->cfgbox, j->ctlid, wBuffer, 4096);
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, wBuffer, -1, buffer, 4096, NULL, NULL);
|
|
||||||
#else
|
|
||||||
GetDlgItemText(fe->cfgbox, j->ctlid, buffer, lenof(buffer));
|
GetDlgItemText(fe->cfgbox, j->ctlid, buffer, lenof(buffer));
|
||||||
#endif
|
|
||||||
buffer[lenof(buffer)-1] = '\0';
|
buffer[lenof(buffer)-1] = '\0';
|
||||||
sfree(i->u.string.sval);
|
sfree(i->u.string.sval);
|
||||||
i->u.string.sval = dupstr(buffer);
|
i->u.string.sval = dupstr(buffer);
|
||||||
@ -2351,7 +1939,6 @@ static int CALLBACK ConfigDlgProc(HWND hwnd, UINT msg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
HWND mkctrl(frontend *fe, int x1, int x2, int y1, int y2,
|
HWND mkctrl(frontend *fe, int x1, int x2, int y1, int y2,
|
||||||
char *wclass, int wstyle,
|
char *wclass, int wstyle,
|
||||||
int exstyle, const char *wtext, INT_PTR wid)
|
int exstyle, const char *wtext, INT_PTR wid)
|
||||||
@ -2363,13 +1950,9 @@ HWND mkctrl(frontend *fe, int x1, int x2, int y1, int y2,
|
|||||||
SendMessage(ret, WM_SETFONT, (WPARAM)fe->cfgfont, MAKELPARAM(true, 0));
|
SendMessage(ret, WM_SETFONT, (WPARAM)fe->cfgfont, MAKELPARAM(true, 0));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void about(frontend *fe)
|
static void about(frontend *fe)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
DialogBox(fe->inst, MAKEINTRESOURCE(IDD_ABOUT), fe->hwnd, AboutDlgProc);
|
|
||||||
#else
|
|
||||||
int i;
|
int i;
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
@ -2518,19 +2101,10 @@ static void about(frontend *fe)
|
|||||||
SetForegroundWindow(fe->hwnd);
|
SetForegroundWindow(fe->hwnd);
|
||||||
DestroyWindow(fe->cfgbox);
|
DestroyWindow(fe->cfgbox);
|
||||||
DeleteObject(fe->cfgfont);
|
DeleteObject(fe->cfgfont);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool get_config(frontend *fe, int which)
|
static bool get_config(frontend *fe, int which)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
fe->cfg_which = which;
|
|
||||||
|
|
||||||
return DialogBoxParam(fe->inst,
|
|
||||||
MAKEINTRESOURCE(IDD_CONFIG),
|
|
||||||
fe->hwnd, ConfigDlgProc,
|
|
||||||
(LPARAM) fe) == 2;
|
|
||||||
#else
|
|
||||||
config_item *i;
|
config_item *i;
|
||||||
struct cfg_aux *j;
|
struct cfg_aux *j;
|
||||||
char *title;
|
char *title;
|
||||||
@ -2770,38 +2344,8 @@ static bool get_config(frontend *fe, int which)
|
|||||||
sfree(fe->cfgaux);
|
sfree(fe->cfgaux);
|
||||||
|
|
||||||
return (fe->dlg_done == 2);
|
return (fe->dlg_done == 2);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
static void calculate_bitmap_position(frontend *fe, int x, int y)
|
|
||||||
{
|
|
||||||
/* Pocket PC - center the game in the full screen window */
|
|
||||||
int yMargin;
|
|
||||||
RECT rcClient;
|
|
||||||
|
|
||||||
GetClientRect(fe->hwnd, &rcClient);
|
|
||||||
fe->bitmapPosition.left = (rcClient.right - x) / 2;
|
|
||||||
yMargin = rcClient.bottom - y;
|
|
||||||
|
|
||||||
if (fe->numpad != NULL) {
|
|
||||||
RECT rcPad;
|
|
||||||
GetWindowRect(fe->numpad, &rcPad);
|
|
||||||
yMargin -= rcPad.bottom - rcPad.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fe->statusbar != NULL) {
|
|
||||||
RECT rcStatus;
|
|
||||||
GetWindowRect(fe->statusbar, &rcStatus);
|
|
||||||
yMargin -= rcStatus.bottom - rcStatus.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
fe->bitmapPosition.top = yMargin / 2;
|
|
||||||
|
|
||||||
fe->bitmapPosition.right = fe->bitmapPosition.left + x;
|
|
||||||
fe->bitmapPosition.bottom = fe->bitmapPosition.top + y;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static void calculate_bitmap_position(frontend *fe, int x, int y)
|
static void calculate_bitmap_position(frontend *fe, int x, int y)
|
||||||
{
|
{
|
||||||
/* Plain Windows - position the game in the upper-left corner */
|
/* Plain Windows - position the game in the upper-left corner */
|
||||||
@ -2810,7 +2354,6 @@ static void calculate_bitmap_position(frontend *fe, int x, int y)
|
|||||||
fe->bitmapPosition.right = fe->bitmapPosition.left + x;
|
fe->bitmapPosition.right = fe->bitmapPosition.left + x;
|
||||||
fe->bitmapPosition.bottom = fe->bitmapPosition.top + y;
|
fe->bitmapPosition.bottom = fe->bitmapPosition.top + y;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void new_bitmap(frontend *fe, int x, int y)
|
static void new_bitmap(frontend *fe, int x, int y)
|
||||||
{
|
{
|
||||||
@ -2849,26 +2392,19 @@ static void new_game_size(frontend *fe, float scale)
|
|||||||
} else {
|
} else {
|
||||||
sr.left = sr.right = sr.top = sr.bottom = 0;
|
sr.left = sr.right = sr.top = sr.bottom = 0;
|
||||||
}
|
}
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
SetWindowPos(fe->hwnd, NULL, 0, 0,
|
SetWindowPos(fe->hwnd, NULL, 0, 0,
|
||||||
r.right - r.left,
|
r.right - r.left,
|
||||||
r.bottom - r.top + sr.bottom - sr.top,
|
r.bottom - r.top + sr.bottom - sr.top,
|
||||||
SWP_NOMOVE | SWP_NOZORDER);
|
SWP_NOMOVE | SWP_NOZORDER);
|
||||||
#endif
|
|
||||||
|
|
||||||
check_window_size(fe, &x, &y);
|
check_window_size(fe, &x, &y);
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
if (fe->statusbar != NULL)
|
if (fe->statusbar != NULL)
|
||||||
SetWindowPos(fe->statusbar, NULL, 0, y, x,
|
SetWindowPos(fe->statusbar, NULL, 0, y, x,
|
||||||
sr.bottom - sr.top, SWP_NOZORDER);
|
sr.bottom - sr.top, SWP_NOZORDER);
|
||||||
#endif
|
|
||||||
|
|
||||||
new_bitmap(fe, x, y);
|
new_bitmap(fe, x, y);
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
InvalidateRect(fe->hwnd, NULL, true);
|
|
||||||
#endif
|
|
||||||
midend_redraw(fe->me);
|
midend_redraw(fe->me);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2990,13 +2526,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
return 0;
|
return 0;
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
/* Numeric pad sends WM_COMMAND messages */
|
|
||||||
if ((wParam >= IDM_KEYEMUL) && (wParam < IDM_KEYEMUL + 256))
|
|
||||||
{
|
|
||||||
midend_process_key(fe->me, 0, 0, wParam - IDM_KEYEMUL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
cmd = wParam & ~0xF; /* low 4 bits reserved to Windows */
|
cmd = wParam & ~0xF; /* low 4 bits reserved to Windows */
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case IDM_NEW:
|
case IDM_NEW:
|
||||||
@ -3173,7 +2702,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
case IDM_HELPC:
|
case IDM_HELPC:
|
||||||
start_help(fe, NULL);
|
start_help(fe, NULL);
|
||||||
break;
|
break;
|
||||||
@ -3182,7 +2710,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
start_help(fe, help_type == CHM ?
|
start_help(fe, help_type == CHM ?
|
||||||
fe->game->htmlhelp_topic : fe->game->winhelp_topic);
|
fe->game->htmlhelp_topic : fe->game->winhelp_topic);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
#ifdef COMBINED
|
#ifdef COMBINED
|
||||||
if (wParam >= IDM_GAMES && wParam < (IDM_GAMES + (WPARAM)gamecount)) {
|
if (wParam >= IDM_GAMES && wParam < (IDM_GAMES + (WPARAM)gamecount)) {
|
||||||
@ -3207,9 +2734,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
stop_help(fe);
|
stop_help(fe);
|
||||||
#endif
|
|
||||||
frontend_free(fe);
|
frontend_free(fe);
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
return 0;
|
return 0;
|
||||||
@ -3223,9 +2748,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
hdc = BeginPaint(hwnd, &p);
|
hdc = BeginPaint(hwnd, &p);
|
||||||
hdc2 = CreateCompatibleDC(hdc);
|
hdc2 = CreateCompatibleDC(hdc);
|
||||||
prevbm = SelectObject(hdc2, fe->bitmap);
|
prevbm = SelectObject(hdc2, fe->bitmap);
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
FillRect(hdc, &(p.rcPaint), (HBRUSH) GetStockObject(WHITE_BRUSH));
|
|
||||||
#endif
|
|
||||||
IntersectRect(&rcDest, &(fe->bitmapPosition), &(p.rcPaint));
|
IntersectRect(&rcDest, &(fe->bitmapPosition), &(p.rcPaint));
|
||||||
BitBlt(hdc,
|
BitBlt(hdc,
|
||||||
rcDest.left, rcDest.top,
|
rcDest.left, rcDest.top,
|
||||||
@ -3338,27 +2860,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
else if (message == WM_RBUTTONDOWN || is_alt_pressed())
|
else if (message == WM_RBUTTONDOWN || is_alt_pressed())
|
||||||
button = RIGHT_BUTTON;
|
button = RIGHT_BUTTON;
|
||||||
else
|
else
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
button = LEFT_BUTTON;
|
button = LEFT_BUTTON;
|
||||||
#else
|
|
||||||
if ((fe->game->flags & REQUIRE_RBUTTON) == 0)
|
|
||||||
button = LEFT_BUTTON;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SHRGINFO shrgi;
|
|
||||||
|
|
||||||
shrgi.cbSize = sizeof(SHRGINFO);
|
|
||||||
shrgi.hwndClient = hwnd;
|
|
||||||
shrgi.ptDown.x = (signed short)LOWORD(lParam);
|
|
||||||
shrgi.ptDown.y = (signed short)HIWORD(lParam);
|
|
||||||
shrgi.dwFlags = SHRG_RETURNCMD;
|
|
||||||
|
|
||||||
if (GN_CONTEXTMENU == SHRecognizeGesture(&shrgi))
|
|
||||||
button = RIGHT_BUTTON;
|
|
||||||
else
|
|
||||||
button = LEFT_BUTTON;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!midend_process_key(fe->me,
|
if (!midend_process_key(fe->me,
|
||||||
(signed short)LOWORD(lParam) - fe->bitmapPosition.left,
|
(signed short)LOWORD(lParam) - fe->bitmapPosition.left,
|
||||||
@ -3436,7 +2938,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
fe->timer_last_tickcount = now;
|
fe->timer_last_tickcount = now;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
case WM_SIZING:
|
case WM_SIZING:
|
||||||
{
|
{
|
||||||
RECT *sr = (RECT *)lParam;
|
RECT *sr = (RECT *)lParam;
|
||||||
@ -3468,29 +2969,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
static int FindPreviousInstance()
|
|
||||||
{
|
|
||||||
/* Check if application is running. If it's running then focus on the window */
|
|
||||||
HWND hOtherWnd = NULL;
|
|
||||||
|
|
||||||
hOtherWnd = FindWindow (wGameName, wGameName);
|
|
||||||
if (hOtherWnd)
|
|
||||||
{
|
|
||||||
SetForegroundWindow (hOtherWnd);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Split a complete command line into argc/argv, attempting to do it
|
* Split a complete command line into argc/argv, attempting to do it
|
||||||
* exactly the same way the Visual Studio C library would do it (so
|
* exactly the same way the Visual Studio C library would do it (so
|
||||||
@ -3723,12 +3206,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
|
|
||||||
split_into_argv(cmdline, &argc, &argv, NULL);
|
split_into_argv(cmdline, &argc, &argv, NULL);
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
MultiByteToWideChar (CP_ACP, 0, CLASSNAME, -1, wClassName, 256);
|
|
||||||
if (FindPreviousInstance ())
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
@ -3740,18 +3217,12 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
wndclass.cbWndExtra = 0;
|
wndclass.cbWndExtra = 0;
|
||||||
wndclass.hInstance = inst;
|
wndclass.hInstance = inst;
|
||||||
wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(200));
|
wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(200));
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
if (!wndclass.hIcon) /* in case resource file is absent */
|
if (!wndclass.hIcon) /* in case resource file is absent */
|
||||||
wndclass.hIcon = LoadIcon(inst, IDI_APPLICATION);
|
wndclass.hIcon = LoadIcon(inst, IDI_APPLICATION);
|
||||||
#endif
|
|
||||||
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wndclass.hbrBackground = NULL;
|
wndclass.hbrBackground = NULL;
|
||||||
wndclass.lpszMenuName = NULL;
|
wndclass.lpszMenuName = NULL;
|
||||||
#ifdef _WIN32_WCE
|
|
||||||
wndclass.lpszClassName = wClassName;
|
|
||||||
#else
|
|
||||||
wndclass.lpszClassName = CLASSNAME;
|
wndclass.lpszClassName = CLASSNAME;
|
||||||
#endif
|
|
||||||
|
|
||||||
RegisterClass(&wndclass);
|
RegisterClass(&wndclass);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user