Subversion Repositories Kolibri OS

Rev

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

Rev 7806 Rev 7818
Line 1... Line 1...
1
#define MEMSIZE 4096*25
1
#define MEMSIZE 1024*80
Line 2... Line 2...
2
 
2
 
3
//===================================================//
3
//===================================================//
4
//                                                   //
4
//                                                   //
5
//                       LIB                         //
5
//                       LIB                         //
Line 19... Line 19...
19
 
19
 
Line 20... Line 20...
20
#include "../lib/patterns/simple_open_dialog.h"
20
#include "../lib/patterns/simple_open_dialog.h"
21
 
21
 
22
//===================================================//
22
//===================================================//
23
//                                                   //
23
//                                                   //
24
//                       DATA                        //
24
//                 INTERNAL INCLUDES                 //
Line -... Line 25...
-
 
25
//                                                   //
-
 
26
//===================================================//
-
 
27
 
25
//                                                   //
28
proc_info Form;
26
//===================================================//
29
llist list;
27
 
30
 
Line -... Line 31...
-
 
31
#define TOOLBAR_H 34
28
#define TOOLBAR_H 34
32
#define TOOLBAR_ICON_WIDTH  24
Line 29... Line -...
29
#define TOOLBAR_ICON_WIDTH  24
-
 
30
#define TOOLBAR_ICON_HEIGHT 22
-
 
31
 
-
 
32
#define DEFAULT_EDITOR "/sys/tinypad"
-
 
33
 
-
 
34
#define INTRO_TEXT "This is a plain Text Reader.\nTry to open some text file."
-
 
35
#define VERSION "Text Reader v1.3"
33
#define TOOLBAR_ICON_HEIGHT 22
36
#define ABOUT "Idea: Leency, punk_joker
-
 
37
Code: Leency, Veliant, KolibriOS Team
-
 
38
 
-
 
39
Hotkeys:
34
 
40
Ctrl+O - open file
-
 
41
Ctrl+I - show file properties
-
 
42
Ctrl+Up - bigger font
35
dword bg_color;
43
Ctrl+Down - smaller font
-
 
44
Ctrl+Tab - select charset
-
 
45
Ctrl+E - reopen current file in another app
-
 
46
 
-
 
47
Press any key..."
-
 
48
 
-
 
49
dword color_schemes[] = {
-
 
50
0xFFFfff, 0,
-
 
51
0xF0F0F0, 0,
-
 
52
0xFDF6E3, 0x101A21,
-
 
Line 53... Line -...
53
0xFCF0DA, 0x171501,
-
 
54
0xF0F0C7, 0,
36
dword text_color;
55
0x282C34, 0xABB2BF,
-
 
56
0x282923, 0xD8D8D2
-
 
57
};
37
 
58
 
-
 
59
char color_scheme_names[] =
-
 
60
"White & Black
-
 
Line 61... Line 38...
61
Grey & Black      RtfRead
38
#include "search.h"
-
 
39
#include "prepare_page.h"
-
 
40
#include "data.h"
-
 
41
 
62
Linen & Black     Horst
42
int encoding;
-
 
43
int curcol_scheme;
-
 
44
 
Line 63... Line 45...
63
Antique & Black   Pocket
45
#include "ini.h"
64
Lemon & Black     Fb2Read
-
 
Line 65... Line -...
65
DarkGrey & Grey   Godot
-
 
66
DarkGrey & Grey   Monokai";
46
 
Line 67... Line 47...
67
 
47
//===================================================//
68
char default_dir[] = "/rd/1";
-
 
69
od_filter filter2 = { 8, "TXT\0\0" };
-
 
70
 
-
 
Line -... Line 48...
-
 
48
//                                                   //
-
 
49
//                       DATA                        //
71
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
50
//                                                   //
-
 
51
//===================================================//
Line 72... Line 52...
72
llist list;
52
 
73
 
53
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
74
proc_info Form;
54
 
75
char title[4196];
55
char title[4196];
76
 
56
 
77
bool help_opened = false;
57
bool help_opened = false;
78
int charsets_mx;
58
 
79
int reopenin_mx;
59
int charsets_mx,
80
int colscheme_mx;
60
    reopenin_mx,
-
 
61
    colscheme_mx,
-
 
62
    search_mx;
-
 
63
 
81
 
64
enum {
Line 82... Line -...
82
int curcol_scheme;
-
 
83
 
-
 
84
enum {
-
 
85
	OPEN_FILE,
-
 
86
	MAGNIFY_MINUS,
-
 
87
	MAGNIFY_PLUS,
65
	OPEN_FILE,
Line 88... Line 66...
88
	CHANGE_ENCODING,
66
	MAGNIFY_MINUS,
89
	RUN_EDIT,
67
	MAGNIFY_PLUS,
90
	SHOW_INFO,
-
 
91
	SHOW_FILE_PROPERTIES,
-
 
92
	COLOR_SCHEME
-
 
93
};
-
 
94
 
-
 
95
int encoding;
-
 
96
 
-
 
97
dword bg_color;
-
 
98
dword text_color;
-
 
99
 
68
	CHANGE_CHARSET,
100
dword menu_id;
69
	REOPEN_IN_APP,
101
 
70
	SHOW_INFO,
Line 102... Line 71...
102
//===================================================//
71
	SHOW_FILE_PROPERTIES,
Line 131... Line 100...
131
	if (param) strcpy(#openfile_path, #param);
100
	if (param) strcpy(#openfile_path, #param);
132
	LoadIniSettings();
101
	LoadIniSettings();
133
	EventSetColorScheme(curcol_scheme);
102
	EventSetColorScheme(curcol_scheme);
134
	kfont.init(DEFAULT_FONT);
103
	kfont.init(DEFAULT_FONT);
135
	Libimg_LoadImage(#skin, abspath("toolbar.png"));
104
	Libimg_LoadImage(#skin, abspath("toolbar.png"));
136
	OpenFile(#param);
105
	LoadFile(#param);
137
	list.no_selection = true;
106
	list.no_selection = true;
138
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
107
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
139
	loop()
108
	loop()
140
	{
109
	{
141
		switch(WaitEvent())
110
		switch(WaitEvent())
Line 156... Line 125...
156
	}
125
	}
157
}
126
}
Line 158... Line 127...
158
 
127
 
159
//===================================================//
128
//===================================================//
160
//                                                   //
129
//                                                   //
161
//                      EVENTS                       //
130
//                  EVENT HANDLERS                   //
162
//                                                   //
131
//                                                   //
Line 163... Line 132...
163
//===================================================//
132
//===================================================//
164
 
133
 
165
void HandleButtonEvent()
-
 
166
{
134
void HandleButtonEvent()
167
	
135
{
168
	byte btn = GetButtonID();
136
	int btn = GetButtonID();
169
	if (btn==1) {
137
	if (btn==1) {
170
		SaveIniSettings();
138
		SaveIniSettings();
171
		ExitProcess();
-
 
172
	}
139
		ExitProcess();
173
	btn-=10;
140
	}
174
	switch(btn)
141
	switch(btn-10)
175
	{
142
	{
176
		case OPEN_FILE:
143
		case OPEN_FILE:
177
			EventOpenFile();
144
			EventOpenDialog();
178
			break;
145
			break;
179
		case SHOW_FILE_PROPERTIES:
146
		case SHOW_FILE_PROPERTIES:
180
			EventShowFileProperties();
147
			EventShowFileProperties();
181
			break;
148
			break;
182
		case MAGNIFY_PLUS:
149
		case MAGNIFY_PLUS:
183
			EventMagnifyPlus();
150
			EventMagnifyPlus();
184
			break;
151
			break;
185
		case MAGNIFY_MINUS:
152
		case MAGNIFY_MINUS:
186
			EventMagnifyMinus();
153
			EventMagnifyMinus();
187
			break;
154
			break;
188
		case CHANGE_ENCODING:
155
		case CHANGE_CHARSET:
189
			EventShowEncodingList();
156
			EventShowCharsetsList();
190
			break;
157
			break;
191
		case RUN_EDIT:
158
		case REOPEN_IN_APP:
192
			EventShowReopenMenu();
159
			EventShowReopenMenu();
193
			break;
160
			break;
194
		case COLOR_SCHEME:
161
		case COLOR_SCHEME:
195
			EventShowColorSchemesList();
162
			EventShowColorSchemesList();
196
			break;
163
			break;
197
		case SHOW_INFO:
164
		case SHOW_INFO:
-
 
165
			EventShowInfo();
-
 
166
			break;
-
 
167
		case SEARCH_BTN:
-
 
168
			if (search.visible) {
-
 
169
				search.hide();
-
 
170
			} else {
-
 
171
				search.show();
-
 
172
			}
-
 
173
			break;
-
 
174
		case BTN_FIND_NEXT:
-
 
175
			EventSearchNext();
-
 
176
			break;
-
 
177
		case BTN_FIND_CLOSE:
198
			EventShowInfo();
178
			search.hide();
199
			break;
179
			break;
200
	}
-
 
Line 201... Line 180...
201
}
180
	}
202
 
181
}
-
 
182
 
203
 
183
void HandleKeyEvent()
204
void HandleKeyEvent()
184
{
205
{
185
	int new_y;
206
	if (help_opened) {
186
	if (help_opened) {
207
		help_opened = false;
187
		help_opened = false;
208
		DrawPage();
188
		DrawPage();
209
		return; 
-
 
210
	}
-
 
211
	GetKeys();
-
 
212
	if (key_scancode == SCAN_CODE_F1) {
-
 
213
		EventShowInfo();
189
		return; 
214
		return;
190
	}
215
	}
191
	GetKeys();
216
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
192
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
217
		switch (key_scancode)
193
		switch (key_scancode)
218
		{
194
		{
219
			case SCAN_CODE_KEY_O:
195
			case SCAN_CODE_KEY_O:
220
				EventOpenFile();
196
				EventOpenDialog();
221
				break;
197
				return;
222
			case SCAN_CODE_KEY_I:
198
			case SCAN_CODE_KEY_I:
223
				EventShowFileProperties();
199
				EventShowFileProperties();
224
				break;
200
				return;
225
			case SCAN_CODE_PLUS:
201
			case SCAN_CODE_PLUS:
226
			case SCAN_CODE_UP:
202
			case SCAN_CODE_UP:
227
				EventMagnifyPlus();
203
				EventMagnifyPlus();
228
				break;
204
				return;
229
			case SCAN_CODE_DOWN:
205
			case SCAN_CODE_DOWN:
230
			case SCAN_CODE_MINUS:
206
			case SCAN_CODE_MINUS:
231
				EventMagnifyMinus();
207
				EventMagnifyMinus();
232
				break;
208
				return;
233
			case SCAN_CODE_KEY_E:
209
			case SCAN_CODE_KEY_E:
234
				EventShowReopenMenu();
210
				EventShowReopenMenu();
235
				break;
211
				return;
-
 
212
			case SCAN_CODE_TAB:
-
 
213
				EventShowCharsetsList();
-
 
214
				return;
-
 
215
			case SCAN_CODE_KEY_F:
-
 
216
				search.show();
-
 
217
				return;
-
 
218
			case SCAN_CODE_HOME:
236
			case SCAN_CODE_TAB:
219
				list.KeyHome();
-
 
220
				DrawPage();
-
 
221
		}
-
 
222
	}
-
 
223
	switch (key_scancode)
-
 
224
	{
-
 
225
		case SCAN_CODE_F1:
-
 
226
			EventShowInfo();
-
 
227
			return;
-
 
228
		case SCAN_CODE_ESC:
-
 
229
			search.hide();
-
 
230
			return;
-
 
231
		case SCAN_CODE_ENTER:
237
				EventChangeEncoding();
232
			if (! search_box.flags & ed_focus) return;
238
				break;
233
		case SCAN_CODE_F3:
-
 
234
			EventSearchNext();
239
		}
235
			return;
240
		return;
236
	}
241
	}
237
	if (!search.edit_key()) {
242
	if (list.ProcessKey(key_scancode))
-
 
Line 243... Line 238...
243
		DrawPage();
238
		if (list.ProcessKey(key_scancode)) DrawPage();
244
}
239
	}
245
 
240
}
246
 
241
 
Line 255... Line 250...
255
	scrollbar_v_mouse (#scroll);
250
	scrollbar_v_mouse (#scroll);
256
	if (list.first != scroll.position) {
251
	if (list.first != scroll.position) {
257
		list.first = scroll.position;
252
		list.first = scroll.position;
258
		DrawPage(); 
253
		DrawPage(); 
259
	}
254
	}
-
 
255
	search.edit_mouse();
260
}
256
}
Line -... Line 257...
-
 
257
 
-
 
258
//===================================================//
-
 
259
//                                                   //
261
 
260
//                      EVENTS                       //
-
 
261
//                                                   //
-
 
262
//===================================================//
-
 
263
 
-
 
264
bool EventSearchNext()
-
 
265
{
-
 
266
	int new_y = search.find_next(list.first, bg_color);
-
 
267
	if (new_y) {
-
 
268
		list.first = new_y / list.item_h;
-
 
269
		list.CheckDoesValuesOkey();
-
 
270
		DrawPage();		
-
 
271
	}
Line 262... Line 272...
262
/* ----------------------------------------------------- */
272
}
263
 
273
 
264
void EventOpenFile()
274
void EventOpenDialog()
265
{
275
{
266
	OpenDialog_start stdcall (#o_dialog);
276
	OpenDialog_start stdcall (#o_dialog);
-
 
277
	if (o_dialog.status) {
267
	if (o_dialog.status) {
278
		LoadFile(#openfile_path);
268
		OpenFile(#openfile_path);
279
		search.clear();
269
		PreparePage();
280
		ParseAndPaint();
Line 270... Line 281...
270
	}
281
	}
271
}
282
}
Line 283... Line 294...
283
{
294
{
284
	kfont.size.pt++;
295
	kfont.size.pt++;
285
	if(!kfont.changeSIZE())
296
	if(!kfont.changeSIZE())
286
		kfont.size.pt--;
297
		kfont.size.pt--;
287
	else
298
	else
288
		PreparePage();
299
		ParseAndPaint();
289
}
300
}
Line 290... Line 301...
290
 
301
 
291
void EventMagnifyMinus()
302
void EventMagnifyMinus()
292
{
303
{
293
	kfont.size.pt--;
304
	kfont.size.pt--;
294
	if(!kfont.changeSIZE())
305
	if(!kfont.changeSIZE())
295
		kfont.size.pt++;
306
		kfont.size.pt++;
296
	else
307
	else
297
		PreparePage();
308
		ParseAndPaint();
Line 298... Line 309...
298
}
309
}
299
 
310
 
-
 
311
void EventShowCharsetsList()
300
void EventShowEncodingList()
312
{
301
{
313
	menu_id = CHANGE_CHARSET;
302
	open_lmenu(Form.left+5 + charsets_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, 
-
 
303
		encoding+1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
314
	open_lmenu(Form.left+5 + charsets_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, 
Line 304... Line 315...
304
	menu_id = 10;
315
		encoding+1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
305
}
316
}
-
 
317
 
306
 
318
void EventShowReopenMenu()
307
void EventShowReopenMenu()
319
{
308
{
-
 
309
	open_lmenu(Form.left+5 + reopenin_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, 0,
320
	menu_id = REOPEN_IN_APP;
Line 310... Line 321...
310
		"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther");
321
	open_lmenu(Form.left+5 + reopenin_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, 0,
311
	menu_id = 20;
322
		"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther");
-
 
323
}
-
 
324
 
312
}
325
void EventShowColorSchemesList()
313
 
326
{
314
void EventShowColorSchemesList()
-
 
315
{
327
	menu_id = COLOR_SCHEME;
Line 316... Line 328...
316
	open_lmenu(Form.left+5 + colscheme_mx, Form.top+29+skin_height, MENU_ALIGN_TOP_LEFT, 
328
	open_lmenu(Form.left+2 + colscheme_mx + 26, 
317
		curcol_scheme+1, #color_scheme_names);
329
		Form.top+29+skin_height, MENU_ALIGN_TOP_RIGHT, 
318
	menu_id = 30;
330
		curcol_scheme+1, #color_scheme_names);
319
}
331
}
320
 
332
 
-
 
333
void EventSetColorScheme(dword _setn)
321
void EventSetColorScheme(dword _setn)
334
{
Line 322... Line 335...
322
{
335
	curcol_scheme = _setn;
323
	curcol_scheme = _setn;
336
	bg_color   = color_schemes[curcol_scheme*2];
324
	bg_color   = color_schemes[curcol_scheme*2];
337
	text_color = color_schemes[curcol_scheme*2+1];
325
	text_color = color_schemes[curcol_scheme*2+1];
338
	if (list.count) ParseAndPaint();
326
}
339
}
327
 
340
 
Line 328... Line 341...
328
void EventShowInfo() {
341
void EventShowInfo() {
329
	help_opened = true;
342
	help_opened = true;
330
	DrawBar(list.x, list.y, list.w, list.h, 0xFFFfff);
343
	DrawBar(list.x, list.y, list.w, list.h, bg_color);
331
	WriteText(list.x + 10, list.y + 10, 10000001b, 0x555555, VERSION);
344
	WriteText(list.x + 10, list.y + 10, 10000001b, text_color, VERSION);
332
	WriteTextLines(list.x + 10, list.y+40, 10110000b, 0, ABOUT, 20);
345
	WriteTextLines(list.x + 10, list.y+40, 10110000b, text_color, ABOUT, 20);
333
}
346
}
334
 
347
 
Line 335... Line 348...
335
void EventChangeEncoding(dword id)
348
void EventChangeCharset(dword id)
336
{
-
 
337
	encoding = id;
-
 
338
	OpenFile(#openfile_path);
-
 
339
	PreparePage();
-
 
340
	draw_window();
-
 
341
}
349
{
-
 
350
	encoding = id;
342
 
351
	LoadFile(#openfile_path);
343
void EventOpenFileInAnotherProgram(dword _app)
-
 
344
{
-
 
345
	RunProgram(_app, #param);
-
 
346
}
352
	ParseAndPaint();
347
 
-
 
348
void EventMenuClick()
-
 
349
{
-
 
350
	byte open_param[4096];
-
 
351
	dword click_id = get_menu_click();
353
	draw_window();
352
	if (click_id) switch(click_id + menu_id - 1)
354
}
353
	{
355
 
354
		//Encoding
356
void EventOpenFileInAnotherProgram(dword _id)
355
		case 10...15:
357
{
356
			EventChangeEncoding(click_id-1);
358
	dword app;
357
			break;
359
	byte open_param[4096];
358
		//Reopen
360
	switch(_id) {
359
		case 20:
361
		case 0:
360
			EventOpenFileInAnotherProgram("/sys/tinypad");
362
			app = "/sys/tinypad";
361
			break;
363
			break;
362
		case 21:
364
		case 1:
363
			EventOpenFileInAnotherProgram("/sys/develop/t_edit");
365
			app = "/sys/develop/t_edit";
364
			break;
366
			break;
365
		case 22:
367
		case 2:
366
			EventOpenFileInAnotherProgram("/sys/network/webview");
368
			app = "/sys/network/webview";
367
			break;
369
			break;
368
		case 23:
370
		case 3:
369
			EventOpenFileInAnotherProgram("/sys/fb2read");
371
			app = "/sys/fb2read";
370
			break;
372
			break;
371
		case 24:
-
 
372
			EventOpenFileInAnotherProgram("/sys/develop/heed");
-
 
373
			break;
-
 
374
		case 25:
-
 
375
			open_param[0]='~';
-
 
376
			strcpy(#open_param+1,#param);
373
		case 4:
-
 
374
			app = "/sys/develop/heed";
-
 
375
			break;
-
 
376
		case 5:
-
 
377
			open_param[0]='~';
-
 
378
			strcpy(#open_param+1,#param);
-
 
379
			RunProgram("/sys/@open", #open_param);
-
 
380
			break;
-
 
381
	}
-
 
382
	RunProgram(app, #param);
-
 
383
}
-
 
384
 
-
 
385
void EventMenuClick()
-
 
386
{
-
 
387
	dword click_id = get_menu_click();
-
 
388
 
377
			RunProgram("/sys/@open", #open_param);
389
	if (click_id) && (menu_id)
Line 378... Line 390...
378
			break;
390
	{
379
		//ColorSchemes
391
		if (menu_id == CHANGE_CHARSET) EventChangeCharset(click_id-1);
380
		case 30...38:
392
		else if (menu_id == REOPEN_IN_APP) EventOpenFileInAnotherProgram(click_id-1);
381
			EventSetColorScheme(click_id-1);
393
		else if (menu_id == COLOR_SCHEME) EventSetColorScheme(click_id-1);
382
			PreparePage();
394
		else notify("'Error: wrong menu number'E");
Line 383... Line 395...
383
			break;
395
	}
384
	}
396
	menu_id = NULL;
385
}
397
}
386
 
398
 
387
//===================================================//
399
//===================================================//
388
//                                                   //
400
//                                                   //
389
//               DRAWS AND OTHER FUNCS               //
401
//               DRAWS AND OTHER FUNCS               //
390
//                                                   //
402
//                                                   //
391
//===================================================//
403
//===================================================//
392
 
404
 
-
 
405
void LoadFile(dword f_path) 
393
void OpenFile(dword f_path) 
406
{
394
{
407
	int tmp;
395
	int tmp;
408
	if (ESBYTE[f_path]) {
396
	if (ESBYTE[f_path]) {
409
		strcpy(#param, f_path);
397
		strcpy(#param, f_path);
410
		if (!io.read(#param)) goto NO_DATA;
398
		io.read(#param);
-
 
399
		strcpy(#title, #param);
411
		strcpy(#title, #param);
400
		strcat(#title, " - Text Reader"); 
412
		strcat(#title, " - Text Reader"); 
Line -... Line 413...
-
 
413
	}
-
 
414
	else {
-
 
415
		NO_DATA:
-
 
416
		if (list.count) return;
-
 
417
		io.buffer_data = INTRO_TEXT;
-
 
418
		strcpy(#title, "Text Reader"); 
-
 
419
	}
-
 
420
	if (encoding!=CH_CP866) ChangeCharset(encoding, "CP866", io.buffer_data);
-
 
421
	list.ClearList();
-
 
422
}
-
 
423
 
-
 
424
int DrawToolbarButton(char image_id, int x)
-
 
425
{
-
 
426
	DrawOvalBorder(x, 5, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, sc.work_graph, 
401
	}
427
		sc.work_graph,sc.work_graph, sc.work_dark);
402
	else {
428
	img_draw stdcall(skin.image, x+1, 5+1, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, TOOLBAR_ICON_WIDTH*image_id, 0);
403
		if (list.count) return;
429
 
404
		io.buffer_data = INTRO_TEXT;
430
	if (menu_id) && (menu_id == image_id) {
405
		strcpy(#title, "Text Reader"); 
431
		DrawRectangle3D(x+1, 6, TOOLBAR_ICON_WIDTH-1, TOOLBAR_ICON_HEIGHT-1, 0xCCCccc, 0xF8FCF8);
406
	}
432
		PutShadow(x+1, 6, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, true, 2);
-
 
433
	} 
407
	if (encoding!=CH_CP866) ChangeCharset(encoding, "CP866", io.buffer_data);
434
	DefineHiddenButton(x+1, 6, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, 10+image_id);
408
	list.KeyHome();
435
	return x;
409
	list.ClearList();
436
}
410
}
437
 
Line 411... Line 438...
411
 
438
void draw_window()
412
void draw_window()
439
{
Line 413... Line 440...
413
{
440
	#define BUTTONS_GAP 5
414
	#define BUTTONS_GAP 6
441
	#define BLOCKS_GAP 18
Line 430... Line 457...
430
	DrawToolbarButton(OPEN_FILE,       x.inc(8));
457
	DrawToolbarButton(OPEN_FILE,       x.inc(8));
431
	DrawToolbarButton(SHOW_FILE_PROPERTIES, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP));
458
	DrawToolbarButton(SHOW_FILE_PROPERTIES, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP));
Line 432... Line 459...
432
 
459
 
433
	DrawToolbarButton(MAGNIFY_MINUS,   x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP));
460
	DrawToolbarButton(MAGNIFY_MINUS,   x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP));
434
	DrawToolbarButton(MAGNIFY_PLUS,    x.inc(TOOLBAR_BUTTON_WIDTH - 1));
-
 
Line -... Line 461...
-
 
461
	DrawToolbarButton(MAGNIFY_PLUS,    x.inc(TOOLBAR_BUTTON_WIDTH - 1));
435
	DrawToolbarButton(COLOR_SCHEME,    x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP)); colscheme_mx = x.n;
462
 
436
 
463
	search_mx    = DrawToolbarButton(SEARCH_BTN,     x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP));
-
 
464
	charsets_mx  = DrawToolbarButton(CHANGE_CHARSET, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP));
-
 
465
	reopenin_mx  = DrawToolbarButton(REOPEN_IN_APP,  x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP));
437
	DrawToolbarButton(CHANGE_ENCODING, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); charsets_mx = x.n;
466
 
-
 
467
	x.n = Form.cwidth - 34;
438
	DrawToolbarButton(RUN_EDIT,        x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); reopenin_mx = x.n;
468
	DrawToolbarButton(SHOW_INFO, x.n);
439
	DrawToolbarButton(SHOW_INFO,       Form.cwidth - 34);
469
	colscheme_mx = DrawToolbarButton(COLOR_SCHEME,   x.inc(-TOOLBAR_BUTTON_WIDTH - BUTTONS_GAP));
440
	
470
 
-
 
471
	if (search.draw(BTN_FIND_NEXT+10, BTN_FIND_CLOSE+10)) {
-
 
472
		DrawRectangle3D(search_mx+1, 6, TOOLBAR_ICON_WIDTH-1, 
-
 
473
			TOOLBAR_ICON_HEIGHT-1, 0xCCCccc, 0xF8FCF8);
441
	if ((Form.cwidth-scroll.size_x-1 == list.w) && 
474
	}
-
 
475
 
-
 
476
	old_w = list.w;
-
 
477
 
442
		(Form.cheight-TOOLBAR_H == list.h) && 
478
	list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, 
-
 
479
		Form.cheight-TOOLBAR_H-search.height(), math.round(kfont.size.pt * 1.4));
443
		(list.count) 
480
 
444
	) {
481
	if ((Form.cwidth-scroll.size_x-1 == old_w) && (list.count)) {
445
		DrawPage(); 
482
		DrawPage(); 
446
	} else {
483
	} else {
Line 447... Line 484...
447
		PreparePage();
484
		ParseAndPaint();
448
	}		
485
	}		
Line 449... Line 486...
449
	
486
	
450
	DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
487
	DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
451
}
488
}
452
 
-
 
453
void DrawPage()
-
 
Line 454... Line -...
454
{
-
 
455
	kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w);
-
 
456
	DrawScroller();
-
 
457
}
-
 
458
 
-
 
459
void DrawToolbarButton(char image_id, int x)
-
 
460
{
-
 
461
	DefineButton(x+1, 6, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, 10+image_id + BT_HIDE, 0);
-
 
462
	//img_draw stdcall(skin.image, x, 5, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, TOOLBAR_ICON_WIDTH-1*image_id, 0);
-
 
463
	DrawOvalBorder(x, 5, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, sc.work_graph, 
-
 
464
		sc.work_graph,sc.work_graph, sc.work_dark);
-
 
465
	img_draw stdcall(skin.image, x+1, 5+1, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, TOOLBAR_ICON_WIDTH*image_id, 0);
489
 
466
}
490
void DrawPage()
467
 
491
{
468
void DrawScroller()
492
	kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w);
469
{
493