00001 /* -*- mode: C; c-file-style: "bsd"; tab-width: 4 -*- */ 00002 /* jstroke.h - System-independent functions/defines 00003 * JStroke 1.x - Japanese Kanji handwriting recognition technology demo. 00004 * Copyright (C) 1997 Robert E. Wells 00005 * http://wellscs.com/pilot 00006 * mailto:robert@wellscs.com 00007 * 00008 * This program is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License 00010 * as published by the Free Software Foundation; either version 2 00011 * of the License, or (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program (gpl.html); if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00021 * 00022 * Derived from prior work by Todd David Rudick on JavaDict and StrokeDic. 00023 * Makes use of KANJIDIC data from Jim Breen of Monash University. 00024 * Further credit details available at http://wellscs.com/pilot 00025 * See readme.txt, ChangeLog, and gpl.html for more information. 00026 * 00027 * CONDITIONAL COMPILATION FLAGS: 00028 * -DFOR_PILOT_GCC -- Robert Wells uses this for code that is specific to the 00029 * US Robotics/3COM Pilot GCC development environment. 00030 * Contact robert@wellscs.com, http://wellscs.com/pilot. 00031 * 00032 * -DFOR_PILOT_COMPAT -- Owen Taylor uses this for his perl front-ended 00033 * application. He puts this code in a subdirectory under the 00034 * rest of his code. Contact owt1@cornell.edu for more 00035 * information, or visit his web site at 00036 * http://www.msc.cornell.edu/~otaylor/. 9/1997. 00037 * 00038 * -------------------------------------------------------------------------*/ 00039 #ifndef __JSTROKE_H__ 00040 #define __JSTROKE_H__ 00041 00042 #include "pilotcompat.h" 00043 00044 /* Limit list to what we can afford (5), or what will fit on screen at most. 00045 * #define diMaxListCount (diScreenHeight/diFontLineHeight) 00046 */ 00047 #define diMaxListCount 5 00048 #define diMaxXyPairs 256 /* Max pairs in stroke... */ 00049 00050 /* ----- List Memory --------------------------------------------------------- 00051 * The idea here is to have a single nonmovable chunk of memory which contains 00052 * all the structures and cross-pointers needed to support the item list for 00053 * passing to LstSetListChoices, and related List control functions. We 00054 * allocate and free it as a single chunk of application memory. 00055 */ 00056 00057 typedef struct { 00058 UInt m_argc; 00059 char** m_argv; 00060 } ListMem; 00061 00062 /* ----- RawStroke ---------------------------------------------------------*/ 00063 00064 typedef struct { 00065 UInt m_len; 00066 Byte m_x[diMaxXyPairs]; 00067 Byte m_y[diMaxXyPairs]; 00068 } RawStroke; 00069 00070 /* ----- ScoreItem ---------------------------------------------------------*/ 00071 00072 typedef struct ScoreItemStruct *ScoreItemPtr; 00073 00074 typedef struct ScoreItemStruct { 00075 ULong m_iScore; 00076 CharPtr m_cp; 00077 } ScoreItem; 00078 00079 /* ----- StrokeScorer------------------------------------------------------ */ 00080 00081 typedef struct StrokeScorerStruct *StrokeScorerPtr; 00082 00083 typedef struct StrokeScorerStruct { 00084 CharPtr m_cpStrokeDic; 00085 RawStroke* m_pRawStrokes; 00086 UInt m_iStrokeCnt; 00087 ScoreItem* m_pScores; 00088 UInt m_iScoreLen; 00089 CharPtr m_cpPath; 00090 } StrokeScorer; 00091 00092 #ifdef __cplusplus 00093 extern "C" { 00094 #endif 00095 00096 ListMem* AppEmptyList(); 00097 Long Angle32(Long xdif, Long ydif); 00098 void ErrBox(CharPtr msg); 00099 void ErrBox2(CharPtr msg1, CharPtr msg2); 00100 00101 /* Create a StrokeScorer object. (Returns NULL if can't get memory) */ 00102 StrokeScorer *StrokeScorerCreate (CharPtr cpStrokeDic, RawStroke *rsp, 00103 UInt iStrokeCnt); 00104 00105 /* Destroy a StrokeScorer object */ 00106 void StrokeScorerDestroy (StrokeScorer *pScorer); 00107 00108 /* Process some database entries (maximum iMaxCnt, -1 for all). 00109 * Returns 0 when none remaining (should eventually return count remaining 00110 * to facilitate a progressbar. 00111 */ 00112 Long StrokeScorerProcess (StrokeScorer *pScorer, Long iMaxCnt); 00113 00114 /* Return best diMaxListCount candidates processed so far */ 00115 ListMem* StrokeScorerTopPicks (StrokeScorer *pScorer); 00116 00117 #ifdef __cplusplus 00118 } 00119 #endif 00120 00121 #endif /*__JSTROKE_H__*/ 00122 /* ----- End of jstroke.h ------------------------------------------------- */