Rev 7806 | Rev 8946 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7806 | Rev 8923 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | #ifndef AUTOBUILD |
- | |
2 | #include "lang.h--" |
- | |
3 | #endif |
- | |
4 | - | ||
5 | #define MEMSIZE 4096 * 1024 * 2 |
1 | #define MEMSIZE 4096 * 1024 * 2 |
- | 2 | #define NO_DLL_INIT |
|
6 | #include "../lib/strings.h" |
3 | #include "../lib/strings.h" |
7 | #include "../lib/gui.h" |
4 | #include "../lib/gui.h" |
8 | #include "../lib/obj/box_lib.h" |
5 | #include "../lib/obj/box_lib.h" |
Line 9... | Line 6... | ||
9 | 6 | ||
10 | #ifdef LANG_RUS |
7 | #ifdef LANG_RUS |
11 | #define WINDOW_TITLE "«®¢ ਪ 2.3" |
8 | #define WINDOW_TITLE "«®¢ ਪ 2.4" |
12 | #define DICTIONARY_LOADED "«®¢ àì § £à㦥" |
9 | #define DICTIONARY_LOADED "«®¢ àì § £à㦥" |
13 | #define WORD_NOT_FOUND "«®¢® ¥ ©¤¥® ¢ á«®¢ à¥" |
10 | #define WORD_NOT_FOUND "«®¢® ¥ ©¤¥® ¢ á«®¢ à¥" |
14 | #define ERROR "訡ª #%d" |
11 | #define ERROR "訡ª #%d" |
15 | #else |
12 | #else |
16 | #define WINDOW_TITLE "Dictionary v2.3" |
13 | #define WINDOW_TITLE "Dictionary v2.4" |
17 | #define DICTIONARY_LOADED "Dictionary loaded" |
14 | #define DICTIONARY_LOADED "Dictionary loaded" |
18 | #define WORD_NOT_FOUND "Word isn't found in the dictionary" |
15 | #define WORD_NOT_FOUND "Word isn't found in the dictionary" |
19 | #define ERROR "Error #%d" |
16 | #define ERROR "Error #%d" |
Line -... | Line 17... | ||
- | 17 | #endif |
|
- | 18 | ||
- | 19 | #define TEXT_ENG_RUS "ENG\26RUS" |
|
- | 20 | #define TEXT_RUS_ENG "RUS\26ENG" |
|
- | 21 | #define TEXT_RU2EN "ENG RUS" |
|
- | 22 | #define TEXT_EN2RU "RUS ENG" |
|
- | 23 | ||
20 | #endif |
24 | unsigned char speaker[23*40*3]= FROM "speaker.raw"; |
21 | 25 | ||
22 | proc_info Form; |
26 | proc_info Form; |
- | 27 | char search_word[256], translate_result[4096]; |
|
- | 28 | #define TOPH 45 |
|
- | 29 | #define PRONOUNCED_FILE "/tmp0/1/pronounced.txt" |
|
Line 23... | Line 30... | ||
23 | char edit_text[256], search_word[256], translate_result[4096]; |
30 | #define SPEECH_PATH "/kolibrios/media/speech/speech" |
24 | #define TOPH 45 |
31 | dword speaker_id; |
25 | 32 | ||
Line 26... | Line -... | ||
26 | unsigned char eng_rus[] = FROM "eng_rus.dict""\0"; |
- | |
27 | unsigned char rus_eng[] = FROM "rus_eng.dict""\0"; |
- | |
28 | dword io_buffer_data; |
- | |
29 | - | ||
30 | #define TEXT_ENG_RUS "ENG\26RUS" |
33 | unsigned char eng_rus[] = FROM "eng_rus.dict""\0"; |
31 | #define TEXT_RUS_ENG "RUS\26ENG" |
34 | unsigned char rus_eng[] = FROM "rus_eng.dict""\0"; |
32 | #define TEXT_VOC_R_E "ENG RUS" |
- | |
33 | #define TEXT_VOC_E_R "RUS ENG" |
35 | dword io_buffer_data; |
Line 34... | Line 36... | ||
34 | #define ENG_RUS 0 |
36 | |
35 | #define RUS_ENG 1 |
- | |
- | 37 | #define ENG_RUS 0 |
|
Line -... | Line 38... | ||
- | 38 | #define RUS_ENG 1 |
|
- | 39 | int active_dict=2; |
|
- | 40 | ||
Line 36... | Line 41... | ||
36 | #define BUTTON_CHANGE_LANGUAGE 10 |
41 | #define BTN_CHANGE_LANGUAGE 10 |
37 | int active_dict=2; |
42 | #define BTN_SPEAKER 11 |
38 | 43 | ||
39 | edit_box edit1= {200,13,13,0xffffff,0x94AECE,0xffffff,0x94AECE,0x10000000,248,#edit_text,0,100000000000010b}; |
44 | char edit_text[256]; |
40 | 45 | edit_box edit1 = {0,13,13,0xffffff,0x94AECE,0xffffff,0xffffff, |
|
41 | 46 | 0x10000000,248,#edit_text,0,ed_focus+ed_always_focus}; |
|
42 | - | ||
43 | void main() |
47 | |
44 | { |
48 | void main() |
45 | int id; |
49 | { |
46 | load_dll(boxlib, #box_lib_init,0); |
50 | int btnid; |
47 | OpenDictionary(ENG_RUS); |
51 | load_dll(boxlib, #box_lib_init,0); |
48 | if (param) |
- | |
49 | { |
- | |
50 | strcpy(#edit_text, #param); |
52 | OpenDictionary(ENG_RUS); |
51 | edit1.size=edit1.pos=strlen(#edit_text); |
53 | if (param) { |
52 | Translate(); |
54 | strcpy(#edit_text, #param); |
53 | } |
55 | edit_box_set_text stdcall (#edit1, #param); |
54 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
56 | Translate(); |
Line 55... | Line 57... | ||
55 | loop() |
57 | } |
56 | { |
58 | @SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
57 | switch(WaitEvent()) |
59 | loop() switch(@WaitEvent()) |
58 | { |
60 | { |
59 | case evMouse: |
61 | case evMouse: |
- | 62 | edit_box_mouse stdcall (#edit1); |
|
- | 63 | break; |
|
- | 64 | ||
- | 65 | case evButton: |
|
60 | edit_box_mouse stdcall (#edit1); |
66 | btnid = @GetButtonID(); |
61 | break; |
67 | if (btnid==01) ExitProcess(); |
- | 68 | if (btnid==BTN_CHANGE_LANGUAGE) { |
|
- | 69 | if (active_dict == ENG_RUS) { |
|
- | 70 | OpenDictionary(RUS_ENG); |
|
- | 71 | } else { |
|
- | 72 | OpenDictionary(ENG_RUS); |
|
- | 73 | } |
|
- | 74 | DrawLangButtons(); |
|
- | 75 | } |
|
- | 76 | if (btnid==BTN_SPEAKER) { |
|
- | 77 | if (GetProcessSlot(speaker_id)!=0) { |
|
- | 78 | KillProcess(speaker_id); |
|
62 | 79 | pause(50); |
|
Line 63... | Line 80... | ||
63 | case evButton: |
80 | } else { |
64 | id=GetButtonID(); |
81 | if (CreateFile(strlen(#translate_result)+1, #translate_result, PRONOUNCED_FILE)!=0) break; |
65 | if (id==01) ExitProcess(); |
82 | pause(50); |
66 | if (id==BUTTON_CHANGE_LANGUAGE) { |
83 | speaker_id = RunProgram(SPEECH_PATH, PRONOUNCED_FILE); |
67 | if (active_dict == ENG_RUS) OpenDictionary(RUS_ENG); else OpenDictionary(ENG_RUS); |
84 | } |
Line 68... | Line 85... | ||
68 | DrawLangButtons(); |
85 | SpeakerDraw(); |
Line 90... | Line 107... | ||
90 | DrawRectangle(edit1.left-3, edit1.top-3, edit1.width+4, 26, sc.work_graph); |
107 | DrawRectangle(edit1.left-3, edit1.top-3, edit1.width+4, 26, sc.work_graph); |
91 | DrawTranslation(); |
108 | DrawTranslation(); |
92 | DrawLangButtons(); |
109 | DrawLangButtons(); |
93 | } |
110 | } |
94 | } |
111 | } |
95 | } |
- | |
Line 96... | Line 112... | ||
96 | 112 | ||
97 | 113 | ||
98 | void DrawLangButtons() |
114 | void DrawLangButtons() |
- | 115 | { |
|
99 | { |
116 | dword direction; |
100 | dword direction; |
117 | int y = edit1.top+3; |
101 | DrawBar(Form.cwidth-111, edit1.top+3, 100, 25, sc.work); |
118 | DrawBar(Form.cwidth-111, y, 100, 25, sc.work); |
102 | DefineButton(Form.cwidth-79, edit1.top-4+3, 20, 20, BUTTON_CHANGE_LANGUAGE, sc.button); |
119 | DefineButton(Form.cwidth-79, y-4, 20, 20, BTN_CHANGE_LANGUAGE, sc.button); |
- | 120 | WriteText(Form.cwidth-73, y-1, 10000001b, sc.work_text, "\26"); |
|
- | 121 | if (active_dict == ENG_RUS) { |
|
- | 122 | direction = TEXT_RU2EN; |
|
- | 123 | } else { |
|
103 | WriteText(Form.cwidth-73, edit1.top-1+3, 10000001b, sc.button_text, "\26"); |
124 | direction = TEXT_EN2RU; |
104 | if (active_dict == ENG_RUS) direction = TEXT_VOC_R_E; else direction = TEXT_VOC_E_R; |
125 | } |
Line 105... | Line 126... | ||
105 | WriteText(Form.cwidth-111, edit1.top+3, 0x90, sc.work_text, direction); |
126 | WriteText(Form.cwidth-111, y, 0x90, sc.work_text, direction); |
106 | } |
127 | } |
107 | 128 | ||
Line 108... | Line 129... | ||
108 | void Translate() |
129 | void Translate() |
109 | { |
130 | { |
Line 110... | Line 131... | ||
110 | dword translation_start, translation_end; |
131 | dword tr_start, tr_end; |
Line 111... | Line 132... | ||
111 | 132 | ||
112 | sprintf(#search_word, "\10%s\13", #edit_text); |
133 | sprintf(#search_word, "\10%s\13", #edit_text); |
113 | strupr(#search_word); |
- | |
114 | 134 | strupr(#search_word); |
|
115 | if (!edit_text) goto _TR_END; |
- | |
116 | 135 | ||
117 | translation_start = strstr(io_buffer_data, #search_word); |
- | |
118 | if (!translation_start) |
136 | if (!edit_text) goto _TR_END; |
119 | { |
137 | |
120 | strcpy(#translate_result, WORD_NOT_FOUND); |
138 | tr_start = strstr(io_buffer_data, #search_word); |
121 | } |
139 | if (!tr_start) { |
122 | else |
140 | strcpy(#translate_result, WORD_NOT_FOUND); |
123 | { |
141 | } else { |
124 | translation_start = strchr(translation_start, '"') + 1; |
142 | tr_start = strchr(tr_start, '"') + 1; |
125 | translation_end = strchr(translation_start, '"'); |
143 | tr_end = strchr(tr_start, '"'); |
Line 160... | Line 178... | ||
160 | strttl(#draw_buf); |
178 | strttl(#draw_buf); |
161 | WriteTextB(10+1, y_pos+8, 10000001b, 0x800080, #search_word); |
179 | WriteTextB(10+1, y_pos+8, 10000001b, 0x800080, #search_word); |
Line 162... | Line 180... | ||
162 | 180 | ||
163 | DrawTextViewArea(10, y_pos+31, Form.cwidth-20, Form.cheight-30, |
181 | DrawTextViewArea(10, y_pos+31, Form.cwidth-20, Form.cheight-30, |
- | 182 | #draw_buf, -1, 0x000000); |
|
- | 183 | ||
164 | #draw_buf, -1, 0x000000); |
184 | SpeakerDraw(); |
Line -... | Line 185... | ||
- | 185 | } |
|
- | 186 | ||
- | 187 | void SpeakerDraw() |
|
- | 188 | { |
|
- | 189 | dword x = Form.cwidth-38; |
|
- | 190 | dword y = Form.cheight-32; |
|
- | 191 | if (active_dict == RUS_ENG) |
|
- | 192 | { |
|
- | 193 | DeleteButton(15); |
|
- | 194 | DrawBar(x,y,23,20,0xFFFFFF); |
|
- | 195 | } else { |
|
- | 196 | DefineHiddenButton(x-5, y-5, 23+10, 20+9, BTN_SPEAKER); |
|
- | 197 | if (!GetProcessSlot(speaker_id)) { |
|
- | 198 | _PutImage(x, y, 23,20, #speaker); |
|
- | 199 | } else { |
|
- | 200 | _PutImage(x, y, 23,20, 23*20*3+#speaker); |
|
- | 201 | } |
|
Line 165... | Line 202... | ||
165 | } |
202 | } |