#include <htmlhelp.h>
#endif /* NO_HTMLHELP */
-#ifdef _WIN32_WCE
-#include <commdlg.h>
-#include <aygshell.h>
-#endif
-
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include "puzzles.h"
-#ifdef _WIN32_WCE
-#include "resource.h"
-#endif
-
#define IDM_NEW 0x0010
#define IDM_RESTART 0x0020
#define IDM_UNDO 0x0030
#define CLASSNAME thegame.name
#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
static FILE *debug_fp = NULL;
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
}
#endif
-#ifndef _WIN32_WCE
#define WINFLAGS (WS_OVERLAPPEDWINDOW &~ \
(WS_MAXIMIZEBOX | WS_OVERLAPPED))
-#else
-#define WINFLAGS (WS_CAPTION | WS_SYSMENU)
-#endif
static void new_game_size(frontend *fe, float scale);
const game *game;
midend *me;
HWND hwnd, statusbar, cfgbox;
-#ifdef _WIN32_WCE
- HWND numpad; /* window handle for the numeric pad */
-#endif
HINSTANCE inst;
HBITMAP bitmap, prevbm;
RECT bitmapPosition; /* game bitmap position within game window */
static void win_status_bar(void *handle, const char *text)
{
-#ifdef _WIN32_WCE
- TCHAR wText[255];
-#endif
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);
-#endif
}
static blitter *win_blitter_new(void *handle, int w, int h)
if (hatch < 0) {
br = CreateSolidBrush(RGB(r * 255, g * 255, b * 255));
} 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 :
hatch == HATCH_SLASH ? HS_BDIAGONAL :
hatch == HATCH_HORIZ ? HS_HORIZONTAL :
hatch == HATCH_PLUS ? HS_CROSS :
/* hatch == HATCH_X ? */ HS_DIAGCROSS,
RGB(0,0,0));
-#endif
}
} else {
br = fe->brushes[colour];
lf.lfPitchAndFamily = (fonttype == FONT_FIXED ?
FIXED_PITCH | FF_DONTCARE :
VARIABLE_PITCH | FF_SWISS);
-#ifdef _WIN32_WCE
- wcscpy(lf.lfFaceName, TEXT("Tahoma"));
-#endif
fe->fonts[i].font = CreateFontIndirect(&lf);
}
fe->prevbm = SelectObject(fe->hdc, fe->bitmap);
ReleaseDC(fe->hwnd, hdc_win);
fe->clip = NULL;
-#ifndef _WIN32_WCE
SetMapMode(fe->hdc, MM_TEXT);
-#endif
fe->drawstatus = DRAWING;
}
void print(frontend *fe)
{
-#ifndef _WIN32_WCE
PRINTDLG pd;
char doctitle[256];
document *doc;
DeleteDC(pd.hDC);
document_free(doc);
-#endif
}
void deactivate_timer(frontend *fe)
*/
static void init_help(void)
{
-#ifndef _WIN32_WCE
char b[2048], *p, *q, *r;
FILE *fp;
}
help_type = NONE; /* didn't find any */
-#endif
}
-#ifndef _WIN32_WCE
-
/*
* Start Help.
*/
}
}
-#endif
-
/*
* Terminate Help on process exit.
*/
if (!fe->statusbar) return;
sy = get_statusbar_height(fe);
-#ifndef _WIN32_WCE
SetWindowPos(fe->statusbar, NULL, 0, r->bottom-r->top-sy, r->right-r->left,
sy, SWP_NOZORDER);
-#endif
}
static void get_menu_size(HWND wh, RECT *r)
cx = r.right - r.left;
cy = r.bottom - r.top;
- if (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
- ;
- }
+ check_window_resize(fe, cx, cy, px, py, &wx, &wy);
GetClientRect(fe->hwnd, &r);
adjust_statusbar(fe, &r);
}
}
-#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.
*/
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,
WS_OVERLAPPEDWINDOW &~
(WS_MAXIMIZEBOX),
DWORD lerr = GetLastError();
printf("no window: 0x%x\n", (unsigned)lerr);
}
-#endif
fe->gamemenu = NULL;
fe->preset_menu = NULL;
* here.
*/
-#ifndef _WIN32_WCE
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
}
}
r.bottom = y;
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);
-#endif
if (fe->statusbar)
DestroyWindow(fe->statusbar);
WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, /* status bar does these */
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.
*/
GetWindowRect(fe->statusbar, &sr);
GetWindowRect(fe->hwnd, &r);
-#ifndef _WIN32_WCE
SetWindowPos(fe->hwnd, NULL, 0, 0, r.right - r.left,
r.bottom - r.top + sr.bottom - sr.top,
SWP_NOMOVE | SWP_NOZORDER);
-#endif
} else {
fe->statusbar = NULL;
}
{
HMENU oldmenu = GetMenu(fe->hwnd);
-#ifndef _WIN32_WCE
HMENU bar = CreateMenu();
HMENU menu = CreateMenu();
RECT menusize;
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;
AppendMenu(menu, MF_ENABLED, IDM_NEW, TEXT("&New"));
AppendMenu(menu, MF_ENABLED, IDM_RESTART, TEXT("&Restart"));
-#ifndef _WIN32_WCE
/* ...here I run out of sensible accelerator characters. */
AppendMenu(menu, MF_ENABLED, IDM_DESC, TEXT("Speci&fic..."));
AppendMenu(menu, MF_ENABLED, IDM_SEED, TEXT("Rando&m Seed..."));
-#endif
assert(!fe->preset_menu);
fe->preset_menuitems[i].which_menu = NULL;
}
if (fe->preset_menu->n_entries > 0 || fe->game->can_configure) {
-#ifndef _WIN32_WCE
HMENU sub = CreateMenu();
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);
}
#ifdef COMBINED
-#ifdef _WIN32_WCE
-#error Windows CE does not support COMBINED build.
-#endif
{
HMENU games = CreateMenu();
int i;
#endif
AppendMenu(menu, MF_SEPARATOR, 0, 0);
-#ifndef _WIN32_WCE
AppendMenu(menu, MF_ENABLED, IDM_LOAD, TEXT("&Load..."));
AppendMenu(menu, MF_ENABLED, IDM_SAVE, TEXT("&Save..."));
AppendMenu(menu, MF_SEPARATOR, 0, 0);
AppendMenu(menu, MF_ENABLED, IDM_PRINT, TEXT("&Print..."));
AppendMenu(menu, MF_SEPARATOR, 0, 0);
}
-#endif
AppendMenu(menu, MF_ENABLED, IDM_UNDO, TEXT("Undo"));
AppendMenu(menu, MF_ENABLED, IDM_REDO, TEXT("Redo"));
-#ifndef _WIN32_WCE
if (fe->game->can_format_as_text_ever) {
AppendMenu(menu, MF_SEPARATOR, 0, 0);
AppendMenu(menu, MF_ENABLED, IDM_COPY, TEXT("&Copy"));
}
-#endif
if (fe->game->can_solve) {
AppendMenu(menu, MF_SEPARATOR, 0, 0);
AppendMenu(menu, MF_ENABLED, IDM_SOLVE, TEXT("Sol&ve"));
}
AppendMenu(menu, MF_SEPARATOR, 0, 0);
-#ifndef _WIN32_WCE
AppendMenu(menu, MF_ENABLED, IDM_QUIT, TEXT("E&xit"));
menu = CreateMenu();
AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)menu, TEXT("&Help"));
-#endif
AppendMenu(menu, MF_ENABLED, IDM_ABOUT, TEXT("&About"));
-#ifndef _WIN32_WCE
if (help_type != NONE) {
char *item;
AppendMenu(menu, MF_SEPARATOR, 0, 0);
SetMenu(fe->hwnd, bar);
get_menu_size(fe->hwnd, &menusize);
fe->xmin = (menusize.right - menusize.left) + 25;
-#endif
}
if (fe->bitmap) DeleteObject(fe->bitmap);
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,
WPARAM wParam, LPARAM lParam)
{
switch (msg) {
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;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
-#ifdef _WIN32_WCE
- EndDialog(hwnd, 1);
-#else
fe->dlg_done = 1;
-#endif
return 0;
case WM_CLOSE:
-#ifdef _WIN32_WCE
- EndDialog(hwnd, 1);
-#else
fe->dlg_done = 1;
-#endif
return 0;
}
}
}
-#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,
WPARAM wParam, LPARAM lParam)
{
switch (msg) {
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;
case WM_COMMAND:
MessageBox(hwnd, err, "Validation error",
MB_ICONERROR | MB_OK);
} else {
-#ifdef _WIN32_WCE
- EndDialog(hwnd, 2);
-#else
fe->dlg_done = 2;
-#endif
}
} else {
-#ifdef _WIN32_WCE
- EndDialog(hwnd, 1);
-#else
fe->dlg_done = 1;
-#endif
}
return 0;
}
if (i->type == C_STRING && HIWORD(wParam) == EN_CHANGE) {
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));
-#endif
buffer[lenof(buffer)-1] = '\0';
sfree(i->u.string.sval);
i->u.string.sval = dupstr(buffer);
return 0;
}
-#ifndef _WIN32_WCE
HWND mkctrl(frontend *fe, int x1, int x2, int y1, int y2,
char *wclass, int wstyle,
int exstyle, const char *wtext, INT_PTR wid)
SendMessage(ret, WM_SETFONT, (WPARAM)fe->cfgfont, MAKELPARAM(true, 0));
return ret;
}
-#endif
static void about(frontend *fe)
{
-#ifdef _WIN32_WCE
- DialogBox(fe->inst, MAKEINTRESOURCE(IDD_ABOUT), fe->hwnd, AboutDlgProc);
-#else
int i;
WNDCLASS wc;
MSG msg;
SetForegroundWindow(fe->hwnd);
DestroyWindow(fe->cfgbox);
DeleteObject(fe->cfgfont);
-#endif
}
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;
struct cfg_aux *j;
char *title;
sfree(fe->cfgaux);
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)
{
/* Plain Windows - position the game in the upper-left corner */
fe->bitmapPosition.right = fe->bitmapPosition.left + x;
fe->bitmapPosition.bottom = fe->bitmapPosition.top + y;
}
-#endif
static void new_bitmap(frontend *fe, int x, int y)
{
} else {
sr.left = sr.right = sr.top = sr.bottom = 0;
}
-#ifndef _WIN32_WCE
SetWindowPos(fe->hwnd, NULL, 0, 0,
r.right - r.left,
r.bottom - r.top + sr.bottom - sr.top,
SWP_NOMOVE | SWP_NOZORDER);
-#endif
check_window_size(fe, &x, &y);
-#ifndef _WIN32_WCE
if (fe->statusbar != NULL)
SetWindowPos(fe->statusbar, NULL, 0, y, x,
sr.bottom - sr.top, SWP_NOZORDER);
-#endif
new_bitmap(fe, x, y);
-#ifdef _WIN32_WCE
- InvalidateRect(fe->hwnd, NULL, true);
-#endif
midend_redraw(fe->me);
}
DestroyWindow(hwnd);
return 0;
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 */
switch (cmd) {
case IDM_NEW:
}
break;
-#ifndef _WIN32_WCE
case IDM_HELPC:
start_help(fe, NULL);
break;
start_help(fe, help_type == CHM ?
fe->game->htmlhelp_topic : fe->game->winhelp_topic);
break;
-#endif
default:
#ifdef COMBINED
if (wParam >= IDM_GAMES && wParam < (IDM_GAMES + (WPARAM)gamecount)) {
}
break;
case WM_DESTROY:
-#ifndef _WIN32_WCE
stop_help(fe);
-#endif
frontend_free(fe);
PostQuitMessage(0);
return 0;
hdc = BeginPaint(hwnd, &p);
hdc2 = CreateCompatibleDC(hdc);
prevbm = SelectObject(hdc2, fe->bitmap);
-#ifdef _WIN32_WCE
- FillRect(hdc, &(p.rcPaint), (HBRUSH) GetStockObject(WHITE_BRUSH));
-#endif
IntersectRect(&rcDest, &(fe->bitmapPosition), &(p.rcPaint));
BitBlt(hdc,
rcDest.left, rcDest.top,
else if (message == WM_RBUTTONDOWN || is_alt_pressed())
button = RIGHT_BUTTON;
else
-#ifndef _WIN32_WCE
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,
(signed short)LOWORD(lParam) - fe->bitmapPosition.left,
fe->timer_last_tickcount = now;
}
return 0;
-#ifndef _WIN32_WCE
case WM_SIZING:
{
RECT *sr = (RECT *)lParam;
return true;
}
break;
-#endif
}
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
* exactly the same way the Visual Studio C library would do it (so
split_into_argv(cmdline, &argc, &argv, NULL);
-#ifdef _WIN32_WCE
- MultiByteToWideChar (CP_ACP, 0, CLASSNAME, -1, wClassName, 256);
- if (FindPreviousInstance ())
- return 0;
-#endif
-
InitCommonControls();
if (!prev) {
wndclass.cbWndExtra = 0;
wndclass.hInstance = inst;
wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(200));
-#ifndef _WIN32_WCE
if (!wndclass.hIcon) /* in case resource file is absent */
wndclass.hIcon = LoadIcon(inst, IDI_APPLICATION);
-#endif
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
-#ifdef _WIN32_WCE
- wndclass.lpszClassName = wClassName;
-#else
wndclass.lpszClassName = CLASSNAME;
-#endif
RegisterClass(&wndclass);
}