xwords/xwords4/wince/cemain.h

242 lines
5.7 KiB
C
Raw Normal View History

2003-11-20 17:26:35 +01:00
/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */
/*
* Copyright 2000-2007 by Eric House (xwords@eehouse.org). All rights reserved.
2003-11-20 17:26:35 +01:00
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _CEMAIN_H_
#define _CEMAIN_H_
#ifdef _WIN32_WCE
# include <aygshell.h>
#endif
2003-11-20 17:26:35 +01:00
#include "draw.h"
#include "game.h"
#include "util.h"
#include "mempool.h"
#include "cesockwr.h"
2004-03-28 03:14:34 +02:00
#ifdef _WIN32_WCE
typedef enum {
WINCE_UNKNOWN
, WINCE_PPC_V1
, WINCE_PPC_2003
, WINCE_PPC_2005
, _LAST_PPC /* so can test for PPC */
, WINCE_SMARTPHONE_V1
, WINCE_SMARTPHONE_2003
, WINCE_SMARTPHONE_2005
} XW_WinceVersion;
# define IS_SMARTPHONE(g) ((g)->winceVersion > _LAST_PPC)
#else
# define IS_SMARTPHONE(g) XP_FALSE
#endif
enum { CE_BONUS1_COLOR,
CE_BONUS2_COLOR,
CE_BONUS3_COLOR,
CE_BONUS4_COLOR,
2004-03-28 03:14:34 +02:00
CE_BKG_COLOR,
CE_TILEBACK_COLOR,
2004-03-28 03:14:34 +02:00
CE_FOCUS_COLOR,
CE_USER_COLOR1,
CE_USER_COLOR2,
CE_USER_COLOR3,
CE_USER_COLOR4,
2004-03-28 03:14:34 +02:00
CE_BLACK_COLOR, /* not editable by users */
CE_WHITE_COLOR,
2004-03-28 03:14:34 +02:00
CE_NUM_COLORS /* last */
2004-03-28 03:14:34 +02:00
};
#define CUR_CE_PREFS_FLAGS 0x0003 /* adds CE_FOCUS_COLOR */
/* This is what CEAppPrefs looked like for CUR_CE_PREFS_FLAGS == 0x0002 */
typedef struct CEAppPrefs0002 {
XP_U16 versionFlags;
CommonPrefs cp;
COLORREF colors[12]; /* CE_FOCUS_COLOR wasn't there */
XP_Bool showColors;
} CEAppPrefs0002;
2003-11-20 17:26:35 +01:00
typedef struct CEAppPrefs {
XP_U16 versionFlags;
CommonPrefs cp;
COLORREF colors[CE_NUM_COLORS];
2003-11-20 17:26:35 +01:00
XP_Bool showColors;
XP_Bool fullScreen;
2003-11-20 17:26:35 +01:00
} CEAppPrefs;
#define NUM_BUTTONS 4
typedef struct CEAppGlobals {
HINSTANCE hInst;
HDC hdc; /* to pass drawing ctxt to draw code */
HWND hWnd;
#if defined TARGET_OS_WINCE
2003-11-20 17:26:35 +01:00
HWND hwndCB;
#endif
2003-11-20 17:26:35 +01:00
HWND buttons[NUM_BUTTONS];
#ifdef _WIN32_WCE
SHACTIVATEINFO sai;
XW_WinceVersion winceVersion;
#else
/* Store location of dummy button */
HMENU dummyMenu;
XP_U16 dummyPos;
#endif
struct {
HMENU oldMenu; /* menu whose item is now on left button */
XP_U16 oldId; /* id of item now on left button */
XP_U16 oldPos; /* position of prev item within oldMenu */
wchar_t oldName[32]; /* name of previous item */
} softkey;
2003-11-20 17:26:35 +01:00
DrawCtx* draw;
XWGame game;
CurGameInfo gameInfo;
XP_UCHAR* curGameName; /* path to storage for current game */
XW_UtilCtxt util;
VTableMgr* vtMgr;
2004-01-29 05:45:53 +01:00
XP_U16* bonusInfo;
2003-11-20 17:26:35 +01:00
2005-08-21 16:05:29 +02:00
XP_U32 timerIDs[NUM_TIMERS_PLUS_ONE];
2007-05-26 16:14:01 +02:00
XWTimerProc timerProcs[NUM_TIMERS_PLUS_ONE];
2005-08-21 16:05:29 +02:00
void* timerClosures[NUM_TIMERS_PLUS_ONE];
XP_U32 timerWhens[NUM_TIMERS_PLUS_ONE];
2004-06-16 06:16:22 +02:00
XP_U16 flags; /* bits defined below */
2005-02-05 22:38:04 +01:00
#ifdef CEFEATURE_CANSCROLL
HWND scrollHandle;
#endif
CeSocketWrapper* socketWrap;
2003-11-20 17:26:35 +01:00
CEAppPrefs appPrefs;
XP_Bool isNewGame;
XP_Bool penDown;
XP_Bool hintPending;
XP_Bool doGlobalPrefs;
#if defined DEBUG && !defined _WIN32_WCE
int dbWidth, dbHeight;
#endif
2003-11-20 17:26:35 +01:00
2004-07-10 19:43:15 +02:00
#ifdef XWFEATURE_SEARCHLIMIT
XP_Bool askTrayLimits;
#endif
2003-11-20 17:26:35 +01:00
MPSLOT
} CEAppGlobals;
/* No longer used, but may need to keep set for backwards compatibility */
# define FLAGS_BIT_SHOWN_NEWDICTLOC 0x0001
2003-11-20 17:26:35 +01:00
#define GAME_IN_PROGRESS(g) ((g)->gameInfo.dictName != 0)
enum {
XWWM_TIME_RQST = WM_APP
,XWWM_PACKET_ARRIVED
2003-11-20 17:26:35 +01:00
};
#define CE_NUM_EDITABLE_COLORS CE_BLACK_COLOR
2003-11-20 17:26:35 +01:00
typedef enum {
RFONTS_TRAY
,RFONTS_TRAYVAL
,RFONTS_CELL
,RFONTS_PTS
,N_RESIZE_FONTS
} RFIndex;
typedef struct _PenColorPair {
COLORREF ref;
HGDIOBJ pen;
} PenColorPair;
2003-11-20 17:26:35 +01:00
typedef struct CEDrawCtx {
DrawCtxVTable* vtable;
HWND mainWin;
CEAppGlobals* globals;
COLORREF prevBkColor;
HBRUSH brushes[CE_NUM_COLORS];
PenColorPair pens[CE_NUM_COLORS];
2003-11-20 17:26:35 +01:00
HFONT selPlayerFont;
HFONT playerFont;
HFONT setFont[N_RESIZE_FONTS];
XP_U16 setFontHt[N_RESIZE_FONTS];
2003-11-20 17:26:35 +01:00
HBITMAP rightArrow;
HBITMAP downArrow;
HBITMAP origin;
XP_U16 trayOwner;
2004-03-02 04:26:35 +01:00
XP_U16 miniLineHt;
XP_Bool scoreIsVertical;
XP_Bool topFocus;
2003-11-20 17:26:35 +01:00
MPSLOT
} CEDrawCtx;
DrawCtx* ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals );
void ce_drawctxt_update( DrawCtx* dctx );
2004-03-28 03:14:34 +02:00
int messageBoxChar( CEAppGlobals* globals, XP_UCHAR* str, wchar_t* title,
XP_U16 buttons );
XP_Bool queryBoxChar( CEAppGlobals* globals, const XP_UCHAR* msg );
2003-11-20 17:26:35 +01:00
#ifdef DEBUG
2006-01-31 15:40:49 +01:00
void logLastError( const char* comment );
void messageToBuf( UINT message, char* buf, int bufSize );
#else
# define logLastError(c)
#endif
/* These allow LISTBOX and COMBOBOX to be used by the same code */
#ifdef _WIN32_WCE
# define SETCURSEL LB_SETCURSEL
# define GETCURSEL LB_GETCURSEL
# define ADDSTRING LB_ADDSTRING
2008-07-28 07:02:39 +02:00
# define INSERTSTRING LB_INSERTSTRING
# define GETLBTEXTLEN LB_GETTEXTLEN
# define GETLBTEXT LB_GETTEXT
#else
# define SETCURSEL CB_SETCURSEL
# define GETCURSEL CB_GETCURSEL
# define ADDSTRING CB_ADDSTRING
2008-07-28 07:02:39 +02:00
# define INSERTSTRING CB_INSERTSTRING
# define GETLBTEXTLEN CB_GETLBTEXTLEN
# define GETLBTEXT CB_GETLBTEXT
#endif
2003-11-20 17:26:35 +01:00
#endif /* _CEMAIN_H_ */