Added integrated KanjiPad, accessible via Kanji->Find menu.
[jben.git] / kanjidic.h
blob84be21c71a7f401de985006e8639e0ff284fd27f
1 /*
2 Project: J-Ben
3 Author: Paul Goins
4 License: GNU General Public License (GPL) version 2
5 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt)
7 File: kanjidic.h
9 This file is part of J-Ben.
11 J-Ben is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License version 2
13 as published by the Free Software Foundation.
15 J-Ben is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>
24 #ifndef kanjidic_h
25 #define kanjidic_h
27 /* Stock wxWidgets includes */
28 #include "wx/wxprec.h"
29 #ifdef __BORLANDC__
30 #pragma hdrstop
31 #endif
32 #ifndef WX_PRECOMP
33 #include "wx/wx.h"
34 #endif
35 #include "boosthm.h"
37 #define KD_SUCCESS 0x0
38 #define KD_FAILURE 0x80000000
40 /* Onyomi/kunyomi/nanori/radical readings */
41 #define KDO_READINGS 0x1
42 /* English meanings */
43 #define KDO_MEANINGS 0x2
44 /* Grade, frequency, stroke count(s) */
45 #define KDO_HIGHIMPORTANCE 0x4
46 /* Enable dictionary display */
47 #define KDO_DICTIONARIES 0x8
48 /* Less important miscellanea, plus radical #'s */
49 #define KDO_LOWIMPORTANCE 0x10
50 /* Enable cross-referencing with vocab study list */
51 #define KDO_VOCABCROSSREF 0x20
52 /* KanjiCafe.com Stroke Order Diagrams (if present) */
53 #define KDO_SOD_STATIC 0x40
54 #define KDO_SOD_ANIM 0x80
55 /* All options (except UNHANDLED) */
56 #define KDO_ALL 0xFF
57 /* All unhandled dictionary stuff */
58 #define KDO_UNHANDLED 0x8000
60 /* Hn...: "New Japanese-English Character Dictionary" by Jack Halpern. "Halpern" field 1 in JWPce. */
61 #define KDD_NJECD 0x1
62 /* Nn...: "Modern Reader's Japanese-English Character Dictionary" by Andrew Nelson. "Nelson" field 1 in JWPce. */
63 #define KDD_MRJECD 0x2
64 /* Vn...: "The New Nelson Japanese-English Character Dictionary" by John Haig. "Nelson" field 2 in JWPce. */
65 #define KDD_NNJECD 0x4
66 /* More "D" codes... add as needed */
67 /* DBnnn: Japanese for Busy People, AJLT */
68 #define KDD_JBP 0x8
69 /* DCnnnn: The Kanji Way to Japanese Language Power, Dale Crowley */
70 #define KDD_KWJLP 0x10
71 /* DGnnn: Kodansha Compact Kanji Guide */
72 #define KDD_KCKG 0x20
73 /* DHnnnn: A Guide To Reading and Writing Japanese, Ken Hensall et al. */
74 #define KDD_GTRWJH 0x40
75 /* DJnnnn: Kanji in Context, Nishiguchi and Kono */
76 #define KDD_KIC 0x80
77 /* DKnnnn: Kanji Learners Dictionary, Jack Halpern */
78 #define KDD_KLD 0x100
79 /* DOnnnn: Essential Kanji, P.G. O'Neill */
80 #define KDD_EK 0x200
81 /* DRnnnn: 2001 Kanji, Father Joseph De Roo */
82 #define KDD_DR 0x400
83 /* DSnnnn: A Guide To Reading and Writing Japanese, Florence Sakade */
84 #define KDD_GTRWJS 0x800
85 /* DTnnn: Tuttle Kanji Cards, Alexander Kask */
86 #define KDD_TKC 0x1000
87 /* DFnnnn: Japanese Kanji Flashcards, White Rabbit Press */
88 #define KDD_JKF 0x2000
89 /* "Pn...-n...-n..." - SKIP codes used by Halpern dictionaries */
90 #define KDD_SKIP 0x4000
91 /* Inxnn.n: Kanji Dictionary, Spahn & Hadamitzky */
92 #define KDD_KD 0x8000
93 /* INnnnn: Kanji & Kana, Spahn & Hadamitzky */
94 #define KDD_KK 0x10000
95 /* Qnnnn.n: Four Corner code, used by various dictionaries in China and Japan */
96 #define KDD_FC 0x20000
97 /* MNnnnnnnn: Morohashi Daikanwajiten, index number */
98 #define KDD_MOROI 0x40000
99 /* MPnn.nnnn: Morohashi Daikanwajiten, volume.page number */
100 #define KDD_MOROVP 0x80000
101 /* Morohashi Daikanwajiten (Both indexing options) */
102 #define KDD_MORO KDD_MOROI | KDD_MOROVP;
103 /* Ennnn: A Guide to Remembering Japanese Characters, Kenneth G. Henshal */
104 #define KDD_GRJC 0x100000
105 /* Knnnn: Gakken Kanji Dictionary ("A New Dictionary of Kanji Usage") */
106 #define KDD_GKD 0x200000
107 /* Lnnnn: Remembering The Kanji, James Heisig */
108 #define KDD_RTK 0x400000
109 /* Onnnn[A]: Japanese Names, P.G. O'Neill */
110 #define KDD_JN 0x800000
111 /* Show EVERYTHING!
112 This is a lot of output, so it's probably for debug purposes only. */
113 #define KDD_ALL 0xFFFFFFFF
115 class KanjiDic {
116 public:
117 static KanjiDic *LoadKanjiDic(const char *filename, int& returnCode);
118 ~KanjiDic();
120 wxString GetKanjidicStr(wxChar c);
121 static wxString KanjidicToHtml(const wxString& kanjidicStr);
122 static wxString KanjidicToHtml(const wxString& kanjidicStr, long options, long dictionaries);
123 int GetIntField(wxChar kanji, const wxString& marker);
124 const BoostHM<wxChar, string> *GetHashTable();
125 wxString GetOnyomiStr(wxChar c);
126 wxString GetKunyomiStr(wxChar c);
127 wxString GetEnglishStr(wxChar c);
128 private:
129 KanjiDic(char *kanjidicRawData);
130 static wxString ConvertKanjidicEntry(const wxString& s);
131 wxString GetKanjidicReading(wxChar c, int readingType);
133 BoostHM<wxChar, string> kanjiHash;
136 #endif