📄 multibox.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
multibox.h
--*/
#ifndef __INCLUDE_MULTIBOX__
#define __INCLUDE_MULTIBOX__
#include <windows.h>
#include <tchar.h>
//#include <types.h>
#include "intface.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
// Alt list for a recognixed character;
#define HWXPAD_NUM_CANDIDATES 10
typedef struct tagHWXRESULTPRI
{
struct tagHWXRESULTPRI *pNext;
struct tagHWXRESULTPRI *pPrev;
int cbCount;
int iSelection;
wchar_t awchAlts[HWXPAD_NUM_CANDIDATES];
DWORD anScore[HWXPAD_NUM_CANDIDATES];
} HWXRESULTPRI;
// Externals
extern HINSTANCE v_hModDll;
extern DWORD v_rThreadID;
extern UINT v_timeoutValue;
extern HWND g_hwndMain;
extern HWND g_hwndWPad;
extern HWND g_hwndEdit;
extern WNDPROC g_origEditProc;
extern HANDLE g_hFontFix;
//
// Debug zones
//
#define DBGPERF DEBUGZONE(0)
#define DBGMOUSE DEBUGZONE(1)
#define DBGERROR DEBUGZONE(2)
#define DBGCONTEXT DEBUGZONE(3)
//
// Function prototypes
//
LRESULT CALLBACK WPadWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK HWXPadWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM);
DWORD WINAPI RecogThreadFn(LPVOID);
void InitGlobals(void);
//
// Structures
//
#pragma warning (disable : 4200)
typedef struct tagSTROKE
{
struct tagSTROKE *pNext; // Pointer to the next stroke.
int xLeft; // Left edge of the box this stroke
// is drawn in.
int iBox; // Logical box number the stroke was written in
int cpt; // number of points within the stroke
POINT apt[0];
} STROKE, *PSTROKE;
#pragma warning (default : 4200)
#define SMOOTHING_BUFFER_LIMIT 3
typedef struct tagHWXGLOBAL
{
STROKE *pstrk; // Strokes of the current character
POINT aptRaw[SMOOTHING_BUFFER_LIMIT];
WORD cptRaw; // Count of points in the raw buffer
POINT *pptOut; // Processed points from digitizer
WORD cptOut; // Count of points in the processed buffer
WORD maxOut; // Space available in the processed buffer
RECT rcClip; // Current clipping rectangle.
POINT ptClient; // Client windows origin.
DWORD mask; // The mask to use.
BOOL bHiPri; // TRUE if the ink thread is at high priority.
BOOL bDown; // Is the mouse down?
BOOL bNoInk; // Is there is no ink sent to the recognizer?
BOOL bInked; // Has the user inked since we've been shown?
int iLogBox; // Logical box index we are currently working on.
int iPrevBox; // Index of the box of the previous stroke.
int iCurrBox; // Index of the box of the current stroke.
int bNumeric; // User wants to force a numeric (Excel style) return
} HWXGLOBAL;
// More globals
extern HWXGLOBAL glob;
// hwx utility functions
void NewStroke(int);
void Terminate(void);
void EraseStroke(void);
void DrawBackground(HDC hdc);
void EraseRecogInk(HDC hdc, int iBox);
void ChangeLayout(void);
void EraseStroke(void);
// Xmit functions
void SendProperSpace();
void SendVKCode(WPARAM wParam);
void SendCharEvent(UINT, UINT, UINT, UINT);
void SendString(LPTSTR psz, DWORD cch);
void SendAltList(HWXRESULTPRI *phr);
//
// Some constants
//
// Size of the display (Currently, should be dynamic!!!)
#define DisplayWidth 240
#define DisplayHeight 80
// Position and size of input pads
#define BOX_SIZE 80
#define BOX_OFFSET 2
#define BOX_WRITING_AREA (BOX_SIZE - 2 * (BOX_OFFSET))
#define BOX_COUNT 2
#define PadWindX 0
#define PadWindY 0
#define PadWindWidth DisplayWidth
#define PadWindHeight BOX_SIZE
// Position and size values for the buttons.
#define QUERY_BUTTON_WIDTH 18
#define ESCAP_BUTTON_WIDTH 24
#define BCKSP_BUTTON_WIDTH 30
#define LARGE_BUTTON_WIDTH 36
#define SMALL_BUTTON_HEIGHT 18
#define LARGE_BUTTON_HEIGHT 19
#define WRITE_BUTTON_HEIGHT 36
#define BUTTON_COL_00 (BOX_SIZE * BOX_COUNT + 2)
#define BUTTON_COL_01 (BUTTON_COL_00 + BCKSP_BUTTON_WIDTH + 1)
#define BUTTON_COL_02 (BUTTON_COL_01 + ESCAP_BUTTON_WIDTH + 1)
#define BUTTON_COL_03 (BUTTON_COL_00 + LARGE_BUTTON_WIDTH + 2)
#define BUTTON_ROW_00 1
#define BUTTON_ROW_01 (BUTTON_ROW_00 + SMALL_BUTTON_HEIGHT + 1)
#define BUTTON_ROW_02 (BUTTON_ROW_01 + LARGE_BUTTON_HEIGHT + 1)
#define BUTTON_ROW_03 (BUTTON_ROW_02 + LARGE_BUTTON_HEIGHT + 1)
#define BMP_ROW_BACKSP 0
#define BMP_ROW_ESCAPE (SMALL_BUTTON_HEIGHT)
#define BMP_ROW_HELP (BMP_ROW_ESCAPE + SMALL_BUTTON_HEIGHT)
#define BMP_ROW_ZENKAKU (BMP_ROW_HELP + SMALL_BUTTON_HEIGHT)
#define BMP_ROW_SUJI (BMP_ROW_ZENKAKU + LARGE_BUTTON_HEIGHT)
#define BMP_ROW_RECOG (BMP_ROW_SUJI + LARGE_BUTTON_HEIGHT)
#define BMP_ROW_ENTER (BMP_ROW_RECOG + LARGE_BUTTON_HEIGHT)
#define BMP_ROW_SPACE (BMP_ROW_ENTER + LARGE_BUTTON_HEIGHT)
#define BMP_ROW_CONVERT (BMP_ROW_SPACE + LARGE_BUTTON_HEIGHT)
#define BMP_ROW_PAD (BMP_ROW_CONVERT + LARGE_BUTTON_HEIGHT)
// multibox specific messages
#define THRDMSG_ADDINK WM_USER + 500
#define THRDMSG_RECOGNIZE WM_USER + 501
#define THRDMSG_CHAR WM_USER + 502
#define THRDMSG_SETMASK WM_USER + 503
#define THRDMSG_SETCONTEXT WM_USER + 504
#define THRDMSG_EXIT WM_USER + 505
#define THRDMSG_CLEAR WM_USER + 506
#define THRDMSG_SEND WM_USER + 507
#define THRDMSG_SET_ALC WM_USER + 508
#define THRDMSG_WM_MOUSEMOVE WM_USER + 509
#define THRDMSG_WM_LBUTTONDOWN WM_USER + 510
#define THRDMSG_WM_LBUTTONUP WM_USER + 511
#define THRDMSG_IM_SCROLLLEFT WM_USER + 512
#define THRDMSG_IM_SCROLLRIGHT WM_USER + 513
#define THRDMSG_EM_SETSEL WM_USER + 514
#define PAD_WM_ERASE WM_USER + 1000
#define PAD_WM_DETERMINE WM_USER + 1001
#define PAD_WM_HWXCHAR WM_USER + 1002
#define PAD_WM_COMCHAR WM_USER + 1003
#define PAD_WM_CLEAR WM_USER + 1004
#define PAD_WM_SEND WM_USER + 1005
#define IM_WM_SEND WM_USER + 2000
#define IM_WM_CHAR WM_USER + 2001
#define IM_WM_ALTS WM_USER + 2002
#define HELP_WM_START WM_USER + 3000
#define HELP_WM_QUIT WM_USER + 3001
#define HELP_WM_COMMAND WM_USER + 3002
//
// HWXPad specific globals
//
extern DWORD recog_Mask; // What rthread uses for the mask.
extern TCHAR v_prevChar; // What rthread uses for the context.
#define INVALID_CHAR 0xffff
// Space bar has to be drawn in a different window from all of the other buttons, so this
// has to be global.
// Timer IDs
#define TIMER_ID_WPAD 100
#define TIMER_ID_HELP 101
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // __HWXPAD_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -