Subversion Repositories Kolibri OS

Rev

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

Rev 6746 Rev 6771
Line 1... Line 1...
1
#ifndef AUTOBUILD
1
#ifndef AUTOBUILD
2
	#include "lang.h--"
2
	#include "lang.h--"
3
#endif
3
#endif
Line 4... Line 4...
4
 
4
 
5
#define MEMSIZE 0x8000
5
#define MEMSIZE 4096 * 1024 * 2
6
#include "..\lib\strings.h"
-
 
7
#include "..\lib\io.h"
6
#include 
8
#include "..\lib\gui.h"
7
#include 
Line 9... Line 8...
9
#include "..\lib\obj\box_lib.h"
8
#include 
10
 
9
 
11
#ifdef LANG_RUS
-
 
12
  #define WINDOW_TITLE "‘«®¢ à¨ª 2.2"
10
#ifdef LANG_RUS
13
  #define DICTIONARY_NOT_FOUND "‘«®¢ àì ­¥ ­ ©¤¥­"
11
  #define WINDOW_TITLE "‘«®¢ à¨ª 2.3"
14
  #define DICTIONARY_LOADED "‘«®¢ àì § £à㦥­"
12
  #define DICTIONARY_LOADED "‘«®¢ àì § £à㦥­"
15
  #define WORD_NOT_FOUND "‘«®¢® ­¥ ­ ©¤¥­® ¢ á«®¢ à¥"
13
  #define WORD_NOT_FOUND "‘«®¢® ­¥ ­ ©¤¥­® ¢ á«®¢ à¥"
16
  #define ERROR "Žè¨¡ª  #%d"
14
  #define ERROR "Žè¨¡ª  #%d"
17
#else
-
 
18
  #define WINDOW_TITLE "Dictionary v2.2"
15
#else
19
  #define DICTIONARY_NOT_FOUND "Dictionary not found"
16
  #define WINDOW_TITLE "Dictionary v2.3"
20
  #define DICTIONARY_LOADED "Dictionary loaded"
17
  #define DICTIONARY_LOADED "Dictionary loaded"
21
  #define WORD_NOT_FOUND "Word isn't found in the dictionary"
18
  #define WORD_NOT_FOUND "Word isn't found in the dictionary"
Line 22... Line 19...
22
  #define ERROR "Error #%d"
19
  #define ERROR "Error #%d"
23
  #endif
20
  #endif
24
 
21
 
Line -... Line 22...
-
 
22
proc_info Form;
-
 
23
char edit_text[256], search_word[256], translate_result[4096];
-
 
24
#define TOPH 45
-
 
25
 
25
proc_info Form;
26
unsigned char eng_rus[] = FROM "eng_rus.dict""\0";
26
char edword[256], search_word[256], translate_result[4096];
27
unsigned char rus_eng[] = FROM "rus_eng.dict""\0";
27
#define TOPH 45
28
dword io_buffer_data;
-
 
29
 
28
 
30
#define TEXT_ENG_RUS "ENG\26RUS"
29
#define TEXT_ENG_RUS "ENG\26RUS"
31
#define TEXT_RUS_ENG "RUS\26ENG"
30
#define TEXT_RUS_ENG "RUS\26ENG"
32
#define TEXT_VOC_R_E "ENG     RUS"
31
#define TEXT_VOCABULARIES "ENG     RUS"
33
#define TEXT_VOC_E_R "RUS     ENG"
Line 32... Line 34...
32
#define ENG_RUS 0
34
#define ENG_RUS 0
33
#define RUS_ENG 1
35
#define RUS_ENG 1
-
 
36
#define BUTTON_CHANGE_LANGUAGE 10
Line 34... Line 37...
34
#define BUTTON_CHANGE_LANGUAGE 10
37
int active_dict=2;
35
int active_dict=2;
38
 
36
 
39
int mouse_dd;
37
int mouse_dd;
40
edit_box edit1= {200,13,13,0xffffff,0x94AECE,0xffffff,0x94AECE,0x10000000,248,#edit_text,#mouse_dd,100000000000010b};
38
edit_box edit1= {200,13,13,0xffffff,0x94AECE,0xffffff,0x94AECE,0x10000000,248,#edword,#mouse_dd,100000000000010b};
41
 
39
 
42
 
40
 
43
 
41
void main()
44
void main()
42
{   
45
{   
43
	int id;
46
	int id;
44
	load_dll(boxlib, #box_lib_init,0);
47
	load_dll(boxlib, #box_lib_init,0);
45
	OpenDictionary(ENG_RUS);
48
	OpenDictionary(ENG_RUS);
46
	if (param)
49
	if (param)
47
	{
50
	{
Line 84... Line 87...
84
			DrawBar(0, TOPH, Form.width-9, 1, system.color.work_graph);
87
			DrawBar(0, TOPH, Form.width-9, 1, system.color.work_graph);
85
			edit1.width=Form.width-edit1.left-edit1.left-9 - 116;
88
			edit1.width=Form.width-edit1.left-edit1.left-9 - 116;
86
			edit_box_draw stdcall(#edit1);
89
			edit_box_draw stdcall(#edit1);
87
			DrawWideRectangle(edit1.left-2, edit1.top-2, edit1.width+3, 25, 2, 0xffffff);
90
			DrawWideRectangle(edit1.left-2, edit1.top-2, edit1.width+3, 25, 2, 0xffffff);
88
			DrawRectangle(edit1.left-3, edit1.top-3, edit1.width+4, 26, system.color.work_graph);
91
			DrawRectangle(edit1.left-3, edit1.top-3, edit1.width+4, 26, system.color.work_graph);
89
			WriteText(Form.width-120, edit1.top+3, 0x90, system.color.work_text, TEXT_VOCABULARIES);
-
 
90
			DrawTranslation();
92
			DrawTranslation();
91
			DrawLangButtons();
93
			DrawLangButtons();
92
      }
94
      }
93
   }
95
   }
94
}
96
}
Line 95... Line 97...
95
 
97
 
96
 
98
 
97
void DrawLangButtons()
99
void DrawLangButtons()
-
 
100
{
98
{
101
	dword direction;
-
 
102
	DrawBar(Form.width-120, edit1.top+3, 100, 25, system.color.work);
99
	dword direction;
103
	DefineButton(Form.width-88, edit1.top-4+3, 20, 20, BUTTON_CHANGE_LANGUAGE, system.color.work_button);
100
	DefineButton(Form.width-88, edit1.top-4+3, 20, 20, BUTTON_CHANGE_LANGUAGE, system.color.work_button);
104
	WriteText(Form.width-82, edit1.top-1+3, 10000001b, system.color.work_button_text, "\26");
101
	if (active_dict == ENG_RUS) direction = "\26"; else direction = "\27";
105
	if (active_dict == ENG_RUS) direction = TEXT_VOC_R_E; else direction = TEXT_VOC_E_R;
Line 102... Line 106...
102
	WriteText(Form.width-82, edit1.top-1+3, 10000001b, system.color.work_button_text, direction);
106
	WriteText(Form.width-120, edit1.top+3, 0x90, system.color.work_text, direction);
103
}
107
}
104
 
108
 
Line 105... Line 109...
105
void Translate()
109
void Translate()
106
{
110
{
Line 107... Line 111...
107
	dword translation_start, translation_end;
111
	dword translation_start, translation_end;
Line 108... Line 112...
108
 
112
 
109
	sprintf(#search_word, "\10%s\13", #edword);
113
	sprintf(#search_word, "\10%s\13", #edit_text);
110
	strupr(#search_word);
114
	strupr(#search_word);
111
 
115
 
112
	if (!io.FILES_SIZE) || (!edword) goto _TR_END;
116
	if (!edit_text) goto _TR_END;
113
 
117
 
Line 128... Line 132...
128
}
132
}
Line 129... Line 133...
129
 
133
 
130
 
134
 
131
void OpenDictionary(dword dict_id)
-
 
132
{
135
void OpenDictionary(dword dict_id)
133
	dword res;
136
{
134
	if (dict_id==active_dict) return;
-
 
135
	active_dict = dict_id;
-
 
136
	if (io.buffer_data) free(io.buffer_data);
-
 
137
	if (active_dict==ENG_RUS) res=io.read("dictionaries/eng - rus.dict");
137
	if (dict_id==active_dict) return;
138
	if (active_dict==RUS_ENG) res=io.read("dictionaries/rus - eng.dict");	
138
	active_dict = dict_id;
139
	if (!io.buffer_data)
139
	if (active_dict==ENG_RUS) 
140
	{
140
	{
141
		sprintf(#search_word, ERROR, res);
141
		io_buffer_data=#eng_rus;
142
		strcpy(#translate_result, DICTIONARY_NOT_FOUND);
142
		strcpy(#search_word, TEXT_ENG_RUS);
143
	}
143
	}
144
	else
144
	if (active_dict==RUS_ENG) 
145
	{
145
	{
146
		if (active_dict==ENG_RUS) strcpy(#search_word, TEXT_ENG_RUS);
-
 
147
		if (active_dict==RUS_ENG) strcpy(#search_word, TEXT_RUS_ENG);
146
		io_buffer_data=#rus_eng;
-
 
147
		strcpy(#search_word, TEXT_RUS_ENG);
148
		strcpy(#translate_result, DICTIONARY_LOADED);
148
	}
149
	}
149
	strcpy(#translate_result, DICTIONARY_LOADED);
Line 150... Line 150...
150
	DrawTranslation();	
150
	DrawTranslation();