Subversion Repositories Kolibri OS

Rev

Rev 5818 | Rev 6640 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5818 Rev 6638
Line 6... Line 6...
6
#include "..\lib\strings.h"
6
#include "..\lib\strings.h"
7
#include "..\lib\io.h"
7
#include "..\lib\io.h"
8
#include "..\lib\gui.h"
8
#include "..\lib\gui.h"
9
#include "..\lib\obj\box_lib.h"
9
#include "..\lib\obj\box_lib.h"
Line 10... Line -...
10
 
-
 
11
unsigned char speaker[23*40*3]= FROM "speaker.raw";
-
 
12
 
10
 
13
#ifdef LANG_RUS
11
#ifdef LANG_RUS
14
  #define WINDOW_TITLE "‘«®¢ à¨ª 2.0"
12
  #define WINDOW_TITLE "‘«®¢ à¨ª 2.2"
15
  #define DICTIONARY_NOT_FOUND "‘«®¢ àì ­¥ ­ ©¤¥­"
13
  #define DICTIONARY_NOT_FOUND "‘«®¢ àì ­¥ ­ ©¤¥­"
16
  #define DICTIONARY_LOADED "‘«®¢ àì § £à㦥­"
14
  #define DICTIONARY_LOADED "‘«®¢ àì § £à㦥­"
17
  #define WORD_NOT_FOUND "‘«®¢® ­¥ ­ ©¤¥­® ¢ á«®¢ à¥"
15
  #define WORD_NOT_FOUND "‘«®¢® ­¥ ­ ©¤¥­® ¢ á«®¢ à¥"
18
  #define ERROR "Žè¨¡ª  #"
16
  #define ERROR "Žè¨¡ª  #%d"
19
#else
17
#else
20
  #define WINDOW_TITLE "Dictionary v2.0"
18
  #define WINDOW_TITLE "Dictionary v2.2"
21
  #define DICTIONARY_NOT_FOUND "Dictionary not found"
19
  #define DICTIONARY_NOT_FOUND "Dictionary not found"
22
  #define DICTIONARY_LOADED "Dictionary loaded"
20
  #define DICTIONARY_LOADED "Dictionary loaded"
23
  #define WORD_NOT_FOUND "Word isn't found in the dictionary"
21
  #define WORD_NOT_FOUND "Word isn't found in the dictionary"
24
  #define ERROR "Error #"
22
  #define ERROR "Error #%d"
Line 25... Line 23...
25
  #endif
23
  #endif
26
 
24
 
27
proc_info Form;
-
 
28
char edword[256], search_word[256], translate_result[4096];
-
 
29
#define PRONOUNCED_FILE "/sys/pronounced.txt"
25
proc_info Form;
Line 30... Line 26...
30
#define SPEECH_PATH "/kolibrios/media/speech/speech"
26
char edword[256], search_word[256], translate_result[4096];
31
#define TOPH 44
27
#define TOPH 44
-
 
28
 
32
 
29
#define TEXT_ENG_RUS "ENG\26RUS"
33
#define TEXT_ENG_RUS "ENG\26RUS"
30
#define TEXT_RUS_ENG "RUS\26ENG"
-
 
31
#define TEXT_VOCABULARIES "ENG     RUS"
34
#define TEXT_RUS_ENG "RUS\26ENG"
32
#define ENG_RUS 0
Line 35... Line 33...
35
#define ENG_RUS 0
33
#define RUS_ENG 1
36
#define RUS_ENG 1
34
#define BUTTON_CHANGE_LANGUAGE 10
Line 37... Line 35...
37
int active_dict=2;
35
int active_dict=2;
38
 
36
 
Line 60... Line 58...
60
			edit_box_mouse stdcall (#edit1);
58
			edit_box_mouse stdcall (#edit1);
61
			break;
59
			break;
Line 62... Line 60...
62
 
60
 
63
		case evButton:
61
		case evButton:
64
            id=GetButtonID();               
62
            id=GetButtonID();               
65
            if (id==01) { KillProcess(speaker_id); ExitProcess(); }
63
            if (id==01) ExitProcess();
66
			if (id==10) { OpenDictionary(ENG_RUS); DrawLangButtons(); }
64
			if (id==BUTTON_CHANGE_LANGUAGE) { 
67
			if (id==11) { OpenDictionary(RUS_ENG); DrawLangButtons(); }
-
 
68
			if (id==15)
-
 
69
			{
-
 
70
				if (GetProcessSlot(speaker_id)!=0))
-
 
71
				{
-
 
72
					KillProcess(speaker_id);
-
 
73
					pause(50);
-
 
74
				}
-
 
75
				else
-
 
76
				{
-
 
77
					if (WriteFile(strlen(#translate_result)+1, #translate_result, PRONOUNCED_FILE)!=0) break;
-
 
78
					pause(50);
-
 
79
					speaker_id = RunProgram(SPEECH_PATH, PRONOUNCED_FILE);
-
 
80
				}
65
				if (active_dict == ENG_RUS) OpenDictionary(RUS_ENG); else OpenDictionary(ENG_RUS);
81
				SpeakerDraw();
66
				DrawLangButtons();
82
			}
67
			}
Line 83... Line 68...
83
			break;
68
			break;
84
 
69
 
Line 89... Line 74...
89
			Translate();
74
			Translate();
90
			break;
75
			break;
Line 91... Line 76...
91
			
76
			
92
         case evReDraw:
77
         case evReDraw:
93
			system.color.get();
78
			system.color.get();
94
			DefineAndDrawWindow(215,120,400,250,0x73,system.color.work,WINDOW_TITLE);
79
			DefineAndDrawWindow(215,120,500,350,0x73,system.color.work,WINDOW_TITLE);
95
			GetProcessInfo(#Form, SelfInfo);
80
			GetProcessInfo(#Form, SelfInfo);
96
			if (Form.status_window>2) break;
81
			if (Form.status_window>2) break;
97
			if (Form.height<140) { MoveSize(OLD,OLD,OLD,140); break; }
82
			if (Form.height<140) { MoveSize(OLD,OLD,OLD,140); break; }
98
			if (Form.width<400) { MoveSize(OLD,OLD,400,OLD); break; }
83
			if (Form.width<400) { MoveSize(OLD,OLD,400,OLD); break; }
99
			DrawBar(0, 0, Form.width-9, TOPH, system.color.work); //top bg
84
			DrawBar(0, 0, Form.width-9, TOPH, system.color.work); //top bg
100
			DrawBar(0, TOPH, Form.width-9, 1, system.color.work_graph);
85
			DrawBar(0, TOPH, Form.width-9, 1, system.color.work_graph);
101
			edit1.width=Form.width-edit1.left-edit1.left-9 - 116;
86
			edit1.width=Form.width-edit1.left-edit1.left-9 - 116;
102
			edit_box_draw stdcall(#edit1);
87
			edit_box_draw stdcall(#edit1);
103
			DrawWideRectangle(edit1.left-2, edit1.top-2, edit1.width+3, 19, 2, 0xffffff);
88
			DrawWideRectangle(edit1.left-2, edit1.top-2, edit1.width+3, 19, 2, 0xffffff);
-
 
89
			DrawRectangle(edit1.left-3, edit1.top-3, edit1.width+4, 20, system.color.work_graph);
104
			DrawRectangle(edit1.left-3, edit1.top-3, edit1.width+4, 20, system.color.work_graph);
90
			WriteText(Form.width-120, edit1.top, 0x90, system.color.work_text, TEXT_VOCABULARIES);
105
			DrawTranslation();
91
			DrawTranslation();
106
			DrawLangButtons();
92
			DrawLangButtons();
107
      }
93
      }
108
   }
94
   }
Line 109... Line 95...
109
}
95
}
110
 
96
 
111
 
-
 
112
void DrawLangButtons()
-
 
113
{
-
 
114
	DrawCaptButton(Form.width-130, edit1.top-3, 50,19, 10, system.color.work_button, system.color.work_button_text, TEXT_ENG_RUS);
-
 
115
	DrawCaptButton(Form.width-70, edit1.top-3, 50,19, 11, system.color.work_button, system.color.work_button_text, TEXT_RUS_ENG);
-
 
116
	PutShadow(-active_dict*60 + Form.width-70, edit1.top-3, 50,19, 1, 2);
-
 
117
	SpeakerDraw();
-
 
118
}
-
 
119
 
97
 
120
void SpeakerDraw()
-
 
121
{
-
 
122
	dword x, y;
-
 
123
	x = Form.cwidth-38;
-
 
124
	y = Form.cheight-32;
-
 
125
	if (active_dict)
98
void DrawLangButtons()
126
	{
-
 
127
		DeleteButton(15);
-
 
128
		DrawBar(x,y,23,20,0xFFFFFF);
-
 
129
	}
99
{
130
	else
100
	dword direction;
131
	{
-
 
132
		DefineButton(x-5, y-5, 23+10, 20+9, 15+BT_HIDE+BT_NOFRAME, 0);
101
	DefineButton(Form.width-88, edit1.top-4, 20, 20, BUTTON_CHANGE_LANGUAGE, system.color.work_button);
Line 133... Line 102...
133
		if (GetProcessSlot(speaker_id)==0)) _PutImage(x, y, 23,20, #speaker); else _PutImage(x, y, 23,20, 23*20*3+#speaker);		
102
	if (active_dict == ENG_RUS) direction = "\26"; else direction = "\27";
134
	}
103
	WriteText(Form.width-82, edit1.top-1, 10000001b, system.color.work_button_text, direction);
135
}
104
}
Line 136... Line -...
136
 
-
 
137
void Translate()
105
 
138
{
106
void Translate()
Line 139... Line 107...
139
	dword translation_start, translation_end;
107
{
Line 163... Line 131...
163
 
131
 
164
void OpenDictionary(dword dict_id)
132
void OpenDictionary(dword dict_id)
165
{
133
{
166
	dword res;
134
	dword res;
167
	if (dict_id==active_dict) return;
-
 
168
	KillProcess(speaker_id);
135
	if (dict_id==active_dict) return;
169
	active_dict = dict_id;
136
	active_dict = dict_id;
170
	if (io.buffer_data) free(io.buffer_data);
137
	if (io.buffer_data) free(io.buffer_data);
171
	if (active_dict==ENG_RUS) res=io.read("dictionaries/eng - rus.dict");
138
	if (active_dict==ENG_RUS) res=io.read("dictionaries/eng - rus.dict");
172
	if (active_dict==RUS_ENG) res=io.read("dictionaries/rus - eng.dict");	
139
	if (active_dict==RUS_ENG) res=io.read("dictionaries/rus - eng.dict");	
Line 185... Line 152...
185
}
152
}
Line 186... Line 153...
186
 
153
 
187
 
154
 
188
void DrawTranslation()
-
 
189
{
-
 
190
	int text_break=0;
-
 
191
	char tt[4096]='';
155
void DrawTranslation()
192
	
156
{
193
	int y_pos=TOPH+1;
157
	int y_pos=TOPH+1;
Line 194... Line 158...
194
	char draw_buf[4096];
158
	char draw_buf[4096];
195
	strcpy(#draw_buf, #translate_result);
159
	strlcpy(#draw_buf, #translate_result, sizeof(draw_buf));
196
	
160
	
197
	DrawBar(0, y_pos, Form.width-9, Form.cheight - y_pos, 0xFFFFFF);
-
 
198
	strttl(#draw_buf);
161
	DrawBar(0, y_pos, Form.width-9, Form.cheight - y_pos, 0xFFFFFF);
199
	WriteTextB(10+1, y_pos+8, 10000001b, 0x800080, #search_word);
-
 
200
	while (draw_buf)
-
 
201
	{
-
 
202
		text_break= Form.width/6-6;
162
	strttl(#draw_buf);
203
		if (text_break>strlen(#draw_buf))
-
 
204
		{
-
 
205
			WriteText(10, y_pos+31, 0x80, 0, #draw_buf);
-
 
206
			break;
-
 
207
		}
163
	WriteTextB(10+1, y_pos+8, 10000001b, 0x800080, #search_word);
208
		while (draw_buf[text_break]<>' ') && (text_break>0) text_break--;
-
 
209
		strcpy(#tt, #draw_buf+text_break+1);
-
 
210
		draw_buf[text_break]=0x0;
-
 
211
		WriteText(10, y_pos+31, 0x80, 0, #draw_buf);
-
 
212
		strcpy(#draw_buf, #tt);
-
 
213
		y_pos+=12;
-
 
214
		if (y_pos+24+8>Form.cheight) break;
164
 
Line 215... Line 165...
215
	}
165
	DrawTextViewArea(10, y_pos+31, Form.cwidth-20, Form.cheight-30, 15,