moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kvoctrain / kvoctrain / entry-dialogs / PhoneticEntryPage.cpp
blob8bd10712b1704e6713deaccf1a550fec2c2097ed
1 /***************************************************************************
3 dialog page for characters from the phonetic alphabet
5 -----------------------------------------------------------------------
7 begin : Sun Dec 9 2001
9 copyright : (C) 2001-2002 Ewald Arnold <kvoctrain@ewald-arnold.de>
10 (C) 2001-2002 The KDE-EDU team
11 (C) 2005 Peter Hedlund <peter@peterandlinda.com>
13 -----------------------------------------------------------------------
15 ***************************************************************************/
17 /***************************************************************************
18 * *
19 * This program is free software; you can redistribute it and/or modify *
20 * it under the terms of the GNU General Public License as published by *
21 * the Free Software Foundation; either version 2 of the License, or *
22 * (at your option) any later version. *
23 * *
24 ***************************************************************************/
27 #include "PhoneticEntryPage.h"
29 #include <qlayout.h>
30 #include <qframe.h>
31 #include <qgroupbox.h>
32 #include <qtooltip.h>
34 #include <kdebug.h>
35 #include <klocale.h>
37 #define KV_MAX_HORIZ 20
38 #define KV_FONTSIZE 14
40 #define I18N_NOOP_maybe(x) x
42 // provide Unicode chars U0250 - U02AF
44 struct KV_Unicode_Ref {
45 wchar_t code;
46 const char *unicodename;
47 const char *audible;
50 KV_Unicode_Ref kv_unicode_ref[] = {
52 {0x00E6, "LATIN SMALL LETTER AE", I18N_NOOP_maybe("")},
53 {0x00E7, "LATIN SMALL LETTER C WITH CEDILLA", I18N_NOOP_maybe("")},
54 {0x00F0, "LATIN SMALL LETTER ETH", I18N_NOOP_maybe("")},
55 {0x00F8, "LATIN SMALL LETTER O WITH STROKE", I18N_NOOP_maybe("")},
56 {0x0127, "LATIN SMALL LETTER H WITH STROKE", I18N_NOOP_maybe("")},
57 {0x014B, "LATIN SMALL LETTER ENG", I18N_NOOP_maybe("")},
58 {0x0153, "LATIN SMALL LIGATURE OE", I18N_NOOP_maybe("")},
59 {0x01F0, "LATIN SMALL LETTER J WITH CARON", I18N_NOOP_maybe("")},
61 {0x03B2, "GREEK SMALL LETTER BETA", I18N_NOOP_maybe("")},
62 {0x03B8, "GREEK SMALL LETTER THETA", I18N_NOOP_maybe("")},
63 {0x03BB, "GREEK SMALL LETTER LAMDA", I18N_NOOP_maybe("")},
64 {0x03C7, "GREEK SMALL LETTER CHI", I18N_NOOP_maybe("")},
66 {0x0250, "LATIN SMALL LETTER TURNED A", I18N_NOOP_maybe("low central unrounded vowel")},
67 {0x0251, "LATIN SMALL LETTER ALPHA", I18N_NOOP_maybe("low back unrounded vowel")},
68 {0x0252, "LATIN SMALL LETTER TURNED ALPHA", I18N_NOOP_maybe("low back rounded vowel")},
69 {0x0253, "LATIN SMALL LETTER B WITH HOOK", I18N_NOOP_maybe("implosive bilabial stop")},
70 {0x0254, "LATIN SMALL LETTER OPEN O", I18N_NOOP_maybe("lower-mid back rounded vowel")},
71 {0x0255, "LATIN SMALL LETTER C WITH CURL", I18N_NOOP_maybe("voiceless alveolo-palatal laminal fricative")},
72 {0x0256, "LATIN SMALL LETTER D WITH TAIL", I18N_NOOP_maybe("voiced retroflex stop")},
73 {0x0257, "LATIN SMALL LETTER D WITH HOOK", I18N_NOOP_maybe("implosive dental or alveolar stop")},
74 {0x0258, "LATIN SMALL LETTER REVERSED E", I18N_NOOP_maybe("upper-mid central unrounded vowel")},
75 {0x0259, "LATIN SMALL LETTER SCHWA", I18N_NOOP_maybe("mid-central unrounded vowel")},
76 {0x025A, "LATIN SMALL LETTER SCHWA WITH HOOK", I18N_NOOP_maybe("rhotacized schwa")},
77 {0x025B, "LATIN SMALL LETTER OPEN E", I18N_NOOP_maybe("lower-mid front unrounded vowel")},
78 {0x025C, "LATIN SMALL LETTER REVERSED OPEN E", I18N_NOOP_maybe("lower-mid central unrounded vowel")},
79 {0x025D, "LATIN SMALL LETTER REVERSED OPEN E WITH HOOK", I18N_NOOP_maybe("rhotacized lower-mid central vowel")},
80 {0x025E, "LATIN SMALL LETTER CLOSED REVERSED OPEN E", I18N_NOOP_maybe("lower-mid central rounded vowel")},
81 {0x025F, "LATIN SMALL LETTER DOTLESS J WITH STROKE", I18N_NOOP_maybe("voiced palatal stop")},
82 {0x0260, "LATIN SMALL LETTER G WITH HOOK", I18N_NOOP_maybe("implosive velar stop")},
83 {0x0261, "LATIN SMALL LETTER SCRIPT G", I18N_NOOP_maybe("voiced velar stop")},
84 {0x0262, "LATIN LETTER SMALL CAPITAL G", I18N_NOOP_maybe("voiced uvular stop")},
85 {0x0263, "LATIN SMALL LETTER GAMMA", I18N_NOOP_maybe("voiced velar fricative")},
86 {0x0264, "LATIN SMALL LETTER RAMS HORN", I18N_NOOP_maybe("")},
87 {0x0265, "LATIN SMALL LETTER TURNED H", I18N_NOOP_maybe("voiced rounded palatal approximant")},
88 {0x0266, "LATIN SMALL LETTER H WITH HOOK", I18N_NOOP_maybe("breathy-voiced glottal fricative")},
89 {0x0267, "LATIN SMALL LETTER HENG WITH HOOK", I18N_NOOP_maybe("voiceless coarticulated velar and palatoalveolar fricative")},
90 {0x0268, "LATIN SMALL LETTER I WITH STROKE", I18N_NOOP_maybe("high central unrounded vowel")},
91 {0x0269, "LATIN SMALL LETTER IOTA", I18N_NOOP_maybe("semi-high front unrounded vowel")},
92 {0x026A, "LATIN LETTER SMALL CAPITAL I", I18N_NOOP_maybe("semi-high front unrounded vowel")},
93 {0x026B, "LATIN SMALL LETTER L WITH MIDDLE TILDE", I18N_NOOP_maybe("velarized voiced alveolar lateral approximant")},
94 {0x026C, "LATIN SMALL LETTER L WITH BELT", I18N_NOOP_maybe("voiceless alveolar lateral fricative")},
95 {0x026D, "LATIN SMALL LETTER L WITH RETROFLEX HOOK", I18N_NOOP_maybe("voiced retroflex lateral")},
96 {0x026E, "LATIN SMALL LETTER LEZH", I18N_NOOP_maybe("voiced lateral fricative")},
97 {0x026F, "LATIN SMALL LETTER TURNED M", I18N_NOOP_maybe("high back unrounded vowel")},
98 {0x0270, "LATIN SMALL LETTER TURNED M WITH LONG LEG", I18N_NOOP_maybe("voiced velar approximant")},
99 {0x0271, "LATIN SMALL LETTER M WITH HOOK", I18N_NOOP_maybe("voiced labiodental nasal")},
100 {0x0272, "LATIN SMALL LETTER N WITH LEFT HOOK", I18N_NOOP_maybe("voiced palatal nasal")},
101 {0x0273, "LATIN SMALL LETTER N WITH RETROFLEX HOOK", I18N_NOOP_maybe("voiced retroflex nasal")},
102 {0x0274, "LATIN LETTER SMALL CAPITAL N", I18N_NOOP_maybe("voiced uvular nasal")},
103 {0x0275, "LATIN SMALL LETTER BARRED O", I18N_NOOP_maybe("rounded mid-central vowel, i.e. rounded schwa")},
104 {0x0276, "LATIN LETTER SMALL CAPITAL OE", I18N_NOOP_maybe("low front rounded vowel")},
105 {0x0277, "LATIN SMALL LETTER CLOSED OMEGA", I18N_NOOP_maybe("semi-high back rounded vowel")},
106 {0x0278, "LATIN SMALL LETTER PHI", I18N_NOOP_maybe("voiceless bilabial fricative")},
107 {0x0279, "LATIN SMALL LETTER TURNED R", I18N_NOOP_maybe("voiced alveolar approximant")},
108 {0x027A, "LATIN SMALL LETTER TURNED R WITH LONG LEG", I18N_NOOP_maybe("voiced lateral flap")},
109 {0x027B, "LATIN SMALL LETTER TURNED R WITH HOOK", I18N_NOOP_maybe("voiced retroflex approximant")},
110 {0x027C, "LATIN SMALL LETTER R WITH LONG LEG", I18N_NOOP_maybe("voiced strident apico-alveolar trill")},
111 {0x027D, "LATIN SMALL LETTER R WITH TAIL", I18N_NOOP_maybe("voiced retroflex flap")},
112 {0x027E, "LATIN SMALL LETTER R WITH FISHHOOK", I18N_NOOP_maybe("voiced alveolar flap or tap")},
113 {0x027F, "LATIN SMALL LETTER REVERSED R WITH FISHHOOK", I18N_NOOP_maybe("apical dental vowel")},
114 {0x0280, "LATIN LETTER SMALL CAPITAL R", I18N_NOOP_maybe("voiced uvular trill")},
115 {0x0281, "LATIN LETTER SMALL CAPITAL INVERTED R", I18N_NOOP_maybe("voiced uvular fricative or approximant")},
116 {0x0282, "LATIN SMALL LETTER S WITH HOOK", I18N_NOOP_maybe("voiceless retroflex fricative")},
117 {0x0283, "LATIN SMALL LETTER ESH", I18N_NOOP_maybe("voiceless postalveolar fricative")},
118 {0x0284, "LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK", I18N_NOOP_maybe("implosive palatal stop")},
119 {0x0285, "LATIN SMALL LETTER SQUAT REVERSED ESH", I18N_NOOP_maybe("apical retroflex vowel")},
120 {0x0286, "LATIN SMALL LETTER ESH WITH CURL", I18N_NOOP_maybe("palatalized voiceless postalveolar fricative")},
121 {0x0287, "LATIN SMALL LETTER TURNED T", I18N_NOOP_maybe("dental click")},
122 {0x0288, "LATIN SMALL LETTER T WITH RETROFLEX HOOK", I18N_NOOP_maybe("voiceless retroflex stop")},
123 {0x0289, "LATIN SMALL LETTER U BAR", I18N_NOOP_maybe("high central rounded vowel")},
124 {0x028A, "LATIN SMALL LETTER UPSILON", I18N_NOOP_maybe("semi-high back rounded vowel")},
125 {0x028B, "LATIN SMALL LETTER V WITH HOOK", I18N_NOOP_maybe("voiced labiodental approximant")},
126 {0x028C, "LATIN SMALL LETTER TURNED V", I18N_NOOP_maybe("lower-mid back unrounded vowel")},
127 {0x028D, "LATIN SMALL LETTER TURNED W", I18N_NOOP_maybe("voiceless rounded labiovelar approximant")},
128 {0x028E, "LATIN SMALL LETTER TURNED Y", I18N_NOOP_maybe("voiced lateral approximant")},
129 {0x028F, "LATIN LETTER SMALL CAPITAL Y", I18N_NOOP_maybe("semi-high front rounded vowel")},
130 {0x0290, "LATIN SMALL LETTER Z WITH RETROFLEX HOOK", I18N_NOOP_maybe("voiced retroflex fricative")},
131 {0x0291, "LATIN SMALL LETTER Z WITH CURL", I18N_NOOP_maybe("voiced alveolo-palatal laminal fricative")},
132 {0x0292, "LATIN SMALL LETTER EZH", I18N_NOOP_maybe("voiced postalveolar fricative")},
133 {0x0293, "LATIN SMALL LETTER EZH WITH CURL", I18N_NOOP_maybe("palatalized voiced postalveolar fricative")},
134 {0x0294, "LATIN LETTER GLOTTAL STOP", I18N_NOOP_maybe("")},
135 {0x0295, "LATIN LETTER PHARYNGEAL VOICED FRICATIVE", I18N_NOOP_maybe("voiced pharyngeal fricative")},
136 {0x0296, "LATIN LETTER INVERTED GLOTTAL STOP", I18N_NOOP_maybe("lateral click")},
137 {0x0297, "LATIN LETTER STRETCHED C", I18N_NOOP_maybe("palatal (or alveolar) click")},
138 {0x0298, "LATIN LETTER BILABIAL CLICK", I18N_NOOP_maybe("")},
139 {0x0299, "LATIN LETTER SMALL CAPITAL B", I18N_NOOP_maybe("bilabial trill")},
140 {0x029A, "LATIN SMALL LETTER CLOSED OPEN E", I18N_NOOP_maybe("lower-mid front rounded vowel")},
141 {0x029B, "LATIN LETTER SMALL CAPITAL G WITH HOOK", I18N_NOOP_maybe("voiced uvular implosive")},
142 {0x029C, "LATIN LETTER SMALL CAPITAL H", I18N_NOOP_maybe("voiceless epiglottal fricative")},
143 {0x029D, "LATIN SMALL LETTER J WITH CROSSED-TAIL", I18N_NOOP_maybe("voiced palatal fricative")},
144 {0x029E, "LATIN SMALL LETTER TURNED K", I18N_NOOP_maybe("proposed for velar click")},
145 {0x029F, "LATIN LETTER SMALL CAPITAL L", I18N_NOOP_maybe("velar lateral approximant")},
146 {0x02A0, "LATIN SMALL LETTER Q WITH HOOK", I18N_NOOP_maybe("voiceless uvular implosive")},
147 {0x02A1, "LATIN LETTER GLOTTAL STOP WITH STROKE", I18N_NOOP_maybe("voiced epiglottal stop")},
148 {0x02A2, "LATIN LETTER REVERSED GLOTTAL STOP WITH STROKE", I18N_NOOP_maybe("voiced epiglottal fricative")},
149 {0x02A3, "LATIN SMALL LETTER DZ DIGRAPH", I18N_NOOP_maybe("voiced dental affricate")},
150 {0x02A4, "LATIN SMALL LETTER DEZH DIGRAPH", I18N_NOOP_maybe("voiced postalveolar affricate")},
151 {0x02A5, "LATIN SMALL LETTER DZ DIGRAPH WITH CURL", I18N_NOOP_maybe("voiced alveolo-palatal affricate")},
152 {0x02A6, "LATIN SMALL LETTER TS DIGRAPH", I18N_NOOP_maybe("voiceless dental affricate")},
153 {0x02A7, "LATIN SMALL LETTER TESH DIGRAPH", I18N_NOOP_maybe("voiceless postalveolar affricate")},
154 {0x02A8, "LATIN SMALL LETTER TC DIGRAPH WITH CURL", I18N_NOOP_maybe("voiceless alveolo-palatal affricate")},
155 {0x02A9, "LATIN SMALL LETTER FENG DIGRAPH", I18N_NOOP_maybe("velopharyngeal fricative")},
156 {0x02AA, "LATIN SMALL LETTER LS DIGRAPH", I18N_NOOP_maybe("lateral alveolar fricative (lisp)")},
157 {0x02AB, "LATIN SMALL LETTER LZ DIGRAPH", I18N_NOOP_maybe("voiced lateral alveolar fricative")},
158 {0x02AC, "LATIN LETTER BILABIAL PERCUSSIVE", I18N_NOOP_maybe("audible lip smack")},
159 {0x02AD, "LATIN LETTER BIDENTAL PERCUSSIVE", I18N_NOOP_maybe("audible teeth gnashing")},
161 {0x02CA, "MODIFIER LETTER ACUTE ACCENT (Mandarin Chinese second tone)", I18N_NOOP_maybe("high-rising tone")},
162 {0x02CB, "MODIFIER LETTER GRAVE ACCENT (Mandarin Chinese fourth tone)", I18N_NOOP_maybe("high-falling tone")},
164 {0x2191, "UPWARDS ARROW", I18N_NOOP_maybe("egressive airflow")},
165 {0x2193, "DOWNWARDS ARROW", I18N_NOOP_maybe("ingressive airflow")},
167 {0, 0, 0}
171 void PhoneticButton::slotClicked()
173 if (text().length() != 0)
174 emit page->charSelected(text()[0].unicode());
178 PhoneticEntryPage::PhoneticEntryPage(const QFont &ipafont, QWidget *parent, const char *name, bool modal)
179 : KDialogBase(Plain, i18n("Select Characters From Phonetic Alphabet"), Close, Close, parent, name, modal)
181 int num = sizeof(kv_unicode_ref) / sizeof(kv_unicode_ref[0]);
182 QFrame * phoneticbox = plainPage();
183 QGridLayout *gbox = new QGridLayout(phoneticbox, KV_MAX_HORIZ, (num+KV_MAX_HORIZ-1)/KV_MAX_HORIZ, 1);
185 KV_Unicode_Ref *uni_ref = kv_unicode_ref;
186 int vert = 0;
187 int horiz = 0;
188 while (uni_ref->code != 0) {
189 QChar qc = uni_ref->code;
190 QString text = qc;
191 PhoneticButton *butt = new PhoneticButton(text, phoneticbox, this);
192 connect (butt, SIGNAL(clicked()), butt, SLOT(slotClicked()) );
193 QString tip = i18n("Unicode name: ");
194 tip += QString::fromLatin1(uni_ref->unicodename);
195 tip += "\n";
196 tip += i18n("Describing the sound of the character", "Sound: ");
197 tip += i18n(uni_ref->audible);
198 butt->setFont(ipafont);
199 butt->setSizePolicy(QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
200 int sz = QMAX(14, 1.7*ipafont.pointSize());
201 butt->setMaximumSize(QSize (sz, sz));
202 gbox->addWidget( butt, vert, horiz, AlignCenter );
203 QToolTip::add (butt, tip);
205 if (++horiz >= KV_MAX_HORIZ) {
206 ++vert;
207 horiz = 0;
209 ++uni_ref;
211 resize(sizeHint());
215 void PhoneticEntryPage::keyPressEvent( QKeyEvent *e )
217 if ((e->state() & (ControlButton | AltButton)) == 0) {
218 QString s = e->text();
219 for (unsigned i = 0; i < s.length(); ++i) {
220 emit charSelected(s[i].unicode());
222 e->accept();
224 else
225 e->ignore();
229 #include "PhoneticEntryPage.moc"