Subversion Repositories Kolibri OS

Rev

Rev 6656 | Rev 6746 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6653 leency 1
#define MEMSIZE 4096*20
2
 
6662 leency 3
#ifndef AUTOBUILD
4
#include "lang.h--"
5
#endif
6
 
6653 leency 7
//===================================================//
8
//                                                   //
9
//                       LIB                         //
10
//                                                   //
11
//===================================================//
12
 
6631 leency 13
#include "../lib/gui.h"
6653 leency 14
#include "../lib/list_box.h"
15
#include "../lib/obj/box_lib.h"
16
#include "../lib/obj/libio_lib.h"
17
#include "../lib/obj/libini.h"
6654 leency 18
#include "../lib/collection.h"
19
#include "../lib/io.h"
6653 leency 20
#include "../lib/patterns/select_list.h"
21
 
22
//===================================================//
23
//                                                   //
24
//                       DATA                        //
25
//                                                   //
26
//===================================================//
27
 
6631 leency 28
proc_info Form;
29
 
6662 leency 30
#ifdef LANG_RUS
31
	#define WINDOW_TITLE "Установщик драйверов"
32
	#define T_CAUTION_TITLE "ПРЕДУПРЕЖДЕНИЕ"
33
	#define T_CAUTION_PARAGRAPH "Установка дополнительных драйверов может нанести вред стабильности операционной системы и потенциально привести к порче оборудования."
34
	#define T_ASSEPT_RISK "Я принимаю риск"
35
	#define T_README "Readme"
36
	#define T_INSTALL "Установить"
37
#else
38
	#define WINDOW_TITLE "Driver Installer"
39
	#define T_CAUTION_TITLE "CAUTION"
40
	#define T_CAUTION_PARAGRAPH "Installing additional drivers can be harmful to the stability of the operation system and potentionally can harm hardware."
41
	#define T_ASSEPT_RISK "I accept the risk"
42
	#define T_README "Readme"
43
	#define T_INSTALL "Install"
44
#endif
6631 leency 45
 
46
#define BUTTON_ID_ASSEPT_RISK 10
6651 leency 47
#define BUTTON_ID_README 11
48
#define BUTTON_ID_INSTALL 12
6631 leency 49
 
6651 leency 50
//WINDOW STEPS
51
#define WINDOW_STEP_INTRO 1;
52
#define WINDOW_STEP_DRIVER_LIST 2;
53
char window_step = WINDOW_STEP_INTRO;
6631 leency 54
 
6654 leency 55
collection ini_sections;
56
 
6656 leency 57
char drvinf_path[4096] = "/kolibrios/drivers/drvinf.ini";
6654 leency 58
char cur_version[64];
59
char cur_description[1024];
60
char cur_readme_path[4096];
61
char cur_install_path[4096];
62
 
6653 leency 63
//===================================================//
64
//                                                   //
65
//                       CODE                        //
66
//                                                   //
67
//===================================================//
68
 
69
void GetIniData()
70
{
6654 leency 71
	select_list.count = 0;
72
	ini_enum_sections stdcall (#drvinf_path, #process_sections);
6653 leency 73
}
74
 
75
byte process_sections(dword sec_name, f_name)
76
{
6654 leency 77
	select_list.count++;
78
	ini_sections.add(sec_name);
6653 leency 79
	return true;
80
}
81
 
6631 leency 82
void main()
83
{
6653 leency 84
	int id;
85
	load_dll(libio,  #libio_init,1);
86
	load_dll(libini, #lib_init,1);
87
	load_dll(boxlib, #box_lib_init,0);
6654 leency 88
	GetIniData();
6653 leency 89
	SetEventMask(0x27);
6631 leency 90
	loop() switch(WaitEvent())
91
	{
6653 leency 92
		case evMouse:
6654 leency 93
			if (!CheckActiveProcess(Form.ID)) break;
6653 leency 94
			SelectList_ProcessMouse();
95
			break;
96
 
6631 leency 97
		case evButton:
98
			id=GetButtonID();
99
			if (id==1) ExitProcess();
6653 leency 100
			if (id==BUTTON_ID_ASSEPT_RISK) Event_AsseptRisk();
101
			if (id==BUTTON_ID_README) Event_ShowReadme();
102
			if (id==BUTTON_ID_INSTALL) Event_RunInstall();
6631 leency 103
			break;
104
 
105
		case evKey:
106
			GetKeys();
6653 leency 107
			if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
6631 leency 108
			break;
109
 
110
		case evReDraw:
6653 leency 111
			Event_DrawWindow();
6631 leency 112
	}
113
}
114
 
115
 
6651 leency 116
void draw_intro_window()
6631 leency 117
{
118
	incn y;
6651 leency 119
	y.n = Form.cheight/2 - 80;
6631 leency 120
	WriteTextB(30+2,y.n+2,0x81,MixColors(system.color.work, 0xB92234,220),T_CAUTION_TITLE);
121
	WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE);
6651 leency 122
	y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140,
6631 leency 123
		T_CAUTION_PARAGRAPH, -1, system.color.work_text);
124
	DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK);
125
}
126
 
127
 
6651 leency 128
void draw_driver_list_window()
129
{
130
	int PADDING = 12;
6654 leency 131
	int right_frame_x = Form.cwidth*46/100;
132
	int readme_w = 0;
6651 leency 133
	//LEFT FRAME
6653 leency 134
	SelectList_Init(PADDING,
135
		PADDING,
6654 leency 136
		right_frame_x - PADDING - PADDING - 8 - scroll1.size_x,
6653 leency 137
		Form.cheight - PADDING - PADDING,
138
		false);
139
	SelectList_Draw();
6662 leency 140
	SelectList_DrawBorder();
6651 leency 141
	//RIGHT FRAME
6654 leency 142
	GetCurrentSectionData();
143
	DrawBar(right_frame_x, PADDING+3, Form.cwidth - right_frame_x - PADDING, 80, system.color.work);
144
	WriteTextB(right_frame_x, PADDING+3, 0x81, system.color.work_text, ini_sections.get(select_list.cur_y));
145
	WriteText(right_frame_x, PADDING+23, 0x80, system.color.work_text, #cur_version);
146
	if(cur_readme_path[0]) readme_w = DrawStandartCaptButton(right_frame_x, PADDING+45, BUTTON_ID_README, T_README);
147
	DrawStandartCaptButton(right_frame_x + readme_w, PADDING+45, BUTTON_ID_INSTALL, T_INSTALL);
148
	DrawTextViewArea(right_frame_x-2, PADDING+83, Form.cwidth - right_frame_x - PADDING, Form.cheight-PADDING-PADDING,
149
		#cur_description, system.color.work, system.color.work_text);
6651 leency 150
}
6653 leency 151
 
152
void SelectList_DrawLine(dword i)
153
{
154
	int yyy, list_last;
155
 
156
	yyy = i*select_list.item_h+select_list.y;
157
 
158
	if (select_list.cur_y-select_list.first==i)
159
	{
160
		DrawBar(select_list.x, yyy, select_list.w, select_list.item_h, system.color.work_button);
6654 leency 161
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,system.color.work_button_text, ini_sections.get(i));
6653 leency 162
	}
163
	else
164
	{
165
		DrawBar(select_list.x,yyy,select_list.w, select_list.item_h, 0xFFFfff);
6654 leency 166
		WriteText(select_list.x+12,yyy+select_list.text_y,select_list.font_type,0, ini_sections.get(i));
6653 leency 167
	}
168
}
169
 
170
void SelectList_LineChanged()
171
{
6654 leency 172
	draw_driver_list_window();
6653 leency 173
}
174
 
6662 leency 175
 
6654 leency 176
void GetCurrentSectionData()
177
{
6662 leency 178
	dword section_name = ini_sections.get(select_list.cur_y);
179
	dword description_name;
180
	if (GetSystemLanguage() == SYS_LANG_RUS) description_name = "description_ru"; else description_name = "description_en";
181
	ini_get_str stdcall (#drvinf_path, section_name, "ver", #cur_version, sizeof(cur_version), 0);
182
	ini_get_str stdcall (#drvinf_path, section_name, description_name, #cur_description, sizeof(cur_description), 0);
183
	ini_get_str stdcall (#drvinf_path, section_name, "readme", #cur_readme_path, sizeof(cur_readme_path), 0);
184
	ini_get_str stdcall (#drvinf_path, section_name, "install", #cur_install_path, sizeof(cur_install_path), 0);
6654 leency 185
}
186
 
6653 leency 187
//===================================================//
188
//                                                   //
189
//                     EVENTS                        //
190
//                                                   //
191
//===================================================//
192
 
193
void Event_DrawWindow()
194
{
195
	system.color.get();
196
	DefineAndDrawWindow(215, 100, 600, 400, 0x33, system.color.work, WINDOW_TITLE);
197
	GetProcessInfo(#Form, SelfInfo);
6654 leency 198
	if (Form.status_window>2) return;
199
	if (Form.width  < 450) { MoveSize(OLD,OLD,450,OLD); return; }
200
	if (Form.height < 250) { MoveSize(OLD,OLD,OLD,250); return; }
6653 leency 201
	if (window_step == WINDOW_STEP_INTRO) draw_intro_window();
202
	if (window_step == WINDOW_STEP_DRIVER_LIST) draw_driver_list_window();
203
	return;
204
}
205
 
206
void Event_AsseptRisk()
207
{
208
	window_step = WINDOW_STEP_DRIVER_LIST;
209
	Event_DrawWindow();
210
}
211
 
212
void Event_ShowReadme()
213
{
6654 leency 214
	io.run("/sys/textreader", #cur_readme_path);
6653 leency 215
}
216
 
217
void Event_RunInstall()
218
{
6654 leency 219
	io.run(#cur_install_path, NULL);
6653 leency 220
}