Subversion Repositories Kolibri OS

Rev

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

Rev 5614 Rev 5615
Line 7... Line 7...
7
#include "..\lib\strings.h" 
7
#include "..\lib\strings.h" 
8
#include "..\lib\mem.h" 
8
#include "..\lib\mem.h" 
9
#include "..\lib\file_system.h"
9
#include "..\lib\file_system.h"
10
#include "..\lib\dll.h"
10
#include "..\lib\dll.h"
11
#include "..\lib\gui.h"
11
#include "..\lib\gui.h"
-
 
12
#include "..\lib\list_box.h"
-
 
13
 
12
#include "..\lib\obj\box_lib.h"
14
#include "..\lib\obj\box_lib.h"
13
#include "..\lib\obj\proc_lib.h"
15
#include "..\lib\obj\proc_lib.h"
14
#include "..\lib\obj\libio_lib.h"
16
#include "..\lib\obj\libio_lib.h"
Line 15... Line 17...
15
 
17
 
Line 59... Line 61...
59
	char sub_menu4[5];
61
	char sub_menu4[5];
60
	byte end;
62
	byte end;
61
};
63
};
62
#endif
64
#endif
Line 63... Line -...
63
 
-
 
64
#define TITLE "Calypte v0.11"
-
 
65
 
65
 
66
#define TOPPANELH 19
66
#define TOPPANELH 19
67
#define BOTPANELH 10
67
#define BOTPANELH 10
68
#define WIN_W 600
68
#define WIN_W 600
Line -... Line 69...
-
 
69
#define WIN_H 400
-
 
70
 
69
#define WIN_H 400
71
#define TITLE "Calypte v0.12"
70
 
72
char win_title[4096] = TITLE;
-
 
73
proc_info Form;
-
 
74
system_colors sc;
Line 71... Line 75...
71
proc_info Form;
75
dword old_width,old_height;
72
system_colors sc;
76
llist tview;
Line 73... Line 77...
73
 
77
 
74
byte active_properties = 0;
78
byte active_properties = 0;
-
 
79
dword properties_window;
-
 
80
 
Line 75... Line 81...
75
dword properties_window;
81
#include "include\gui.h"
76
 
82
#include "include\properties.h"
77
#include "include\gui.h"
83
// #include "include\top_menu.h"
78
#include "include\properties.h"
84
// #include "include\open_dial.h"
Line 88... Line 94...
88
};
94
};
Line 89... Line 95...
89
 
95
 
90
filter filter2;
96
filter filter2;
Line 91... Line 97...
91
menu_text_struct menu_text_area1;
97
menu_text_struct menu_text_area1;
Line 92... Line -...
92
 
-
 
93
char win_title[4096] = "Calypte v0.11";
-
 
94
 
-
 
95
int
-
 
96
	cur_row=0,
-
 
97
	read=0,
-
 
98
	pos=0,
-
 
99
	row_num=0,
-
 
100
	col_count=0,
-
 
Line 101... Line 98...
101
	row_count=0;	
98
 
102
	
99
int read=0;
103
dword old_width,old_height;
100
 
104
 
101
 
Line 119... Line 116...
119
menu_data menudata1 = {0, 40, 2, 15, 2, #menu_text_area1.menu, #menu_text_area1.sub_menu1, #menu_text_area1.end, 0, 0, 80, 2, 100, 18, 0xEEEEEE, 0xFF, 0xEEEEEE, 0, 0, 0, #Form, 0, 0, 0, 16, 0, 0, 0x00CC00, 0, 0xFFFFFF, 0, 8, 0, 0};
116
menu_data menudata1 = {0, 40, 2, 15, 2, #menu_text_area1.menu, #menu_text_area1.sub_menu1, #menu_text_area1.end, 0, 0, 80, 2, 100, 18, 0xEEEEEE, 0xFF, 0xEEEEEE, 0, 0, 0, #Form, 0, 0, 0, 16, 0, 0, 0x00CC00, 0, 0xFFFFFF, 0, 8, 0, 0};
Line 120... Line 117...
120
 
117
 
121
void main()
118
void main()
122
{   
119
{   
-
 
120
	int id, key;
Line 123... Line 121...
123
	int id, key;
121
	mouse m;
124
	
122
	
125
	strcpy(#filter2.ext1, "TXT");
123
	strcpy(#filter2.ext1, "TXT");
126
	//strcpy(#filter2.ext2, "ASM");
124
	//strcpy(#filter2.ext2, "ASM");
Line 139... Line 137...
139
	mem_Init();
137
	mem_Init();
140
	if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_LOAD_BOX_LIB);
138
	if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_LOAD_BOX_LIB);
141
	if (load_dll2(libio, #libio_init,1)!=0) notify(ERROR_LOAD_LIBIO);
139
	if (load_dll2(libio, #libio_init,1)!=0) notify(ERROR_LOAD_LIBIO);
142
	if (load_dll2(Proc_lib, #OpenDialog_init,0)!=0) notify(ERROR_LOAD_PROC_LIB);
140
	if (load_dll2(Proc_lib, #OpenDialog_init,0)!=0) notify(ERROR_LOAD_PROC_LIB);
143
	OpenDialog_init stdcall (#o_dialog);
141
	OpenDialog_init stdcall (#o_dialog);
144
	
-
 
145
	SetEventMask(0x27);
142
	SetEventMask(0x27);
146
	loop()
143
	loop()
147
	{
144
	{
148
      switch(WaitEvent())
145
      switch(WaitEvent())
149
      {
146
      {
150
		case evMouse:
147
		case evMouse:
-
 
148
			m.get();
-
 
149
			if (tview.MouseScrollNoSelection(m.vert)) DrawText();
-
 
150
		
151
			menu_bar_mouse stdcall (#menudata1);
151
			menu_bar_mouse stdcall (#menudata1);			
152
			if (menudata1.click==1)
152
			if (menudata1.click)
153
			{
153
			{
154
				switch(menudata1.cursor_out)
154
				switch(menudata1.cursor_out)
155
				{
155
				{
156
					case 1:
156
					case 1:
157
						OpenDialog_start stdcall (#o_dialog);
157
						OpenDialog_start stdcall (#o_dialog);
Line 183... Line 183...
183
			}
183
			}
184
			break;
184
			break;
Line 185... Line 185...
185
		
185
		
186
        case evButton:
186
        case evButton:
187
            id=GetButtonID();               
187
            id=GetButtonID();               
188
            if (id==1) || (id==10) ExitProcess();
188
            if (id==1) ExitProcess();
Line 189... Line 189...
189
			break;
189
			break;
-
 
190
      
190
      
191
        case evKey:
191
        case evKey:
192
			if (Form.status_window>2) break;
192
			key = GetKey();
193
			key = GetKey();
193
			switch (key)
-
 
194
			{
194
			switch (key)
195
				if (Form.status_window>2) break;
195
			{
196
				case 015:               //Ctrl+O
196
				case 015:  //Ctrl+O
197
					OpenDialog_start stdcall (#o_dialog);
197
					OpenDialog_start stdcall (#o_dialog);
198
					OpenFile(#openfile_path);
198
					OpenFile(#openfile_path);
199
					Prepare();
199
					Prepare();
200
					draw_window();
200
					draw_window();
201
					break;
-
 
202
				case ASCII_KEY_HOME:
-
 
203
					cur_row = 0;
-
 
204
					DrawText();
201
					break;
205
					break;
-
 
206
				case ASCII_KEY_END:
-
 
207
					cur_row = row_num - row_count - 1;
-
 
208
					DrawText();
202
				case ASCII_KEY_HOME:
209
					break;
-
 
210
				case ASCII_KEY_UP:
-
 
211
					if (!cur_row) break;
-
 
212
					else cur_row = cur_row-1;
-
 
213
					DrawText();
203
				case ASCII_KEY_END:
214
					break;
204
				case ASCII_KEY_UP:
215
				case ASCII_KEY_DOWN:
-
 
216
					if (cur_row+row_count>=row_num) break;
-
 
217
					cur_row = cur_row+1;
205
				case ASCII_KEY_DOWN:
218
					DrawText();
206
					if (tview.ProcessKey(key)) DrawText();
219
					break;
207
					break;
220
				case ASCII_KEY_PGUP:
208
				case ASCII_KEY_PGUP:
221
					if (!cur_row) break;
209
					if (!tview.current) break;
222
					if (cur_row
210
					if (tview.current
223
					else cur_row = cur_row-row_count;
211
					else tview.current = tview.current-tview.visible;
224
					DrawText();
212
					DrawText();
225
					break;
213
					break;
226
				case ASCII_KEY_PGDN:
214
				case ASCII_KEY_PGDN:
227
					if (cur_row+row_count>row_num) break;
215
					if (tview.current+tview.visible>tview.count) break;
228
					cur_row = cur_row+row_count;
216
					tview.current = tview.current+tview.visible;
229
					DrawText();
217
					DrawText();
230
					break;
218
					break;
Line 242... Line 230...
242
void draw_window()
230
void draw_window()
243
{
231
{
244
	sc.get();
232
	sc.get();
245
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title);
233
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title);
246
	GetProcessInfo(#Form, SelfInfo);
234
	GetProcessInfo(#Form, SelfInfo);
-
 
235
	if (Form.status_window>2) return;
-
 
236
	tview.SetSizes(0, TOPPANELH, Form.cwidth, Form.cheight-BOTPANELH-TOPPANELH, 200, 12);
247
	DrawBar(0, 0, Form.cwidth, TOPPANELH, sc.work);
237
	DrawBar(0, 0, Form.cwidth, TOPPANELH, sc.work);
248
	DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, sc.work);
238
	DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, sc.work);
Line 249... Line 239...
249
	
239
	
250
	menudata1.bckg_col = sc.work;
240
	menudata1.bckg_col = sc.work;
Line 251... Line 241...
251
	menu_bar_draw stdcall (#menudata1);
241
	menu_bar_draw stdcall (#menudata1);
252
	
242
	
253
	if (old_width!=Form.width) || (old_height!=Form.height)
243
	if (old_width!=Form.width) || (old_height!=Form.height)
254
	{
244
	{
255
		old_width = Form.width;
-
 
256
		old_height = Form.height;
-
 
257
		
-
 
258
		col_count = Form.cwidth/6;
-
 
259
		row_count = Form.cheight-BOTPANELH-TOPPANELH-2;
-
 
260
		row_count = row_count/10;
245
		old_width = Form.width;
-
 
246
		old_height = Form.height;
261
	
247
		if (read==1) Prepare();
262
		if (read==1) Prepare();
248
		tview.debug_values();
263
	}
249
	}
264
	if (read==1) 
250
	if (read==1) 
265
	{
251
	{
266
		DrawText();
252
		DrawText();
267
	}
253
	}
Line 268... Line 254...
268
	else DrawBar(0, TOPPANELH, Form.cwidth, Form.cheight-BOTPANELH-TOPPANELH, 0xFFFFFF);
254
	else DrawBar(tview.x, tview.y, tview.w, tview.h, 0xFFFFFF);
269
}
255
}
270
 
256
 
Line 285... Line 271...
285
}
271
}
Line 286... Line 272...
286
 
272
 
287
void FreeBuf()
273
void FreeBuf()
288
{
274
{
289
	int i;
275
	int i;
290
	for (i=0; i
276
	for (i=0; i
291
	{
277
	{
292
		mem_Free(DSDWORD[i*4+draw_sruct]);
278
		mem_Free(DSDWORD[i*4+draw_sruct]);
293
	}
279
	}
294
	mem_Free(draw_sruct);
280
	mem_Free(draw_sruct);
295
	mem_Free(bufpointer);
281
	mem_Free(bufpointer);
Line 296... Line 282...
296
}
282
}
297
 
283
 
298
void Prepare()
284
void Prepare()
-
 
285
{
299
{
286
	int i, sub_pos;
300
	int i, sub_pos;
287
	static int cur_pos;
301
	int len_str = 0;
288
	int len_str = 0;
302
	byte do_eof = 0;
289
	byte do_eof = 0;
303
	word bukva[2];
290
	word bukva[2];
304
	dword address;
291
	dword address;
305
	row_num = 0;
292
	tview.count = 0;
306
	while(1)
293
	while(1)
307
	{
294
	{
308
		while(1)
295
		while(1)
309
		{
296
		{
310
			bukva = DSBYTE[bufpointer+pos+len_str];
297
			bukva = DSBYTE[bufpointer+cur_pos+len_str];
311
			if (bukva=='\0')
298
			if (bukva=='\0')
312
			{
299
			{
313
				do_eof = 1;
300
				do_eof = 1;
314
				break;
301
				break;
315
			}
302
			}
316
			if (bukva==0x0a) break;
303
			if (bukva==0x0a) break;
317
			else len_str++;
304
			else len_str++;
318
		}
305
		}
319
		if (len_str<=col_count)
306
		if (len_str<=tview.column_max)
320
		{
307
		{
321
			pos=pos+len_str+1;
308
			cur_pos=cur_pos+len_str+1;
322
			row_num++;
309
			tview.count++;
323
		}
310
		}
324
		else
311
		else
325
		{
312
		{
326
			pos=pos+col_count;
313
			cur_pos=cur_pos+tview.column_max;
327
			row_num++;
314
			tview.count++;
328
		}
315
		}
329
		len_str = 0;
316
		len_str = 0;
330
		if (do_eof) break;
317
		if (do_eof) break;
331
	}
318
	}
332
	mem_Free(draw_sruct);
319
	mem_Free(draw_sruct);
333
	draw_sruct = mem_Alloc(row_num*4);
320
	draw_sruct = mem_Alloc(tview.count*4);
334
	pos=0;
321
	cur_pos=0;
335
	sub_pos=0;
322
	sub_pos=0;
336
	len_str = 0;
323
	len_str = 0;
337
	do_eof = 0;
324
	do_eof = 0;
338
	while(1)
325
	while(1)
339
	{
326
	{
340
		while(1)
327
		while(1)
341
		{
328
		{
342
			bukva = DSBYTE[bufpointer+pos+len_str];
329
			bukva = DSBYTE[bufpointer+cur_pos+len_str];
343
			if (bukva=='\0')
330
			if (bukva=='\0')
344
			{
331
			{
345
				do_eof = 1;
332
				do_eof = 1;
346
				break;
333
				break;
347
			}
334
			}
348
			if (bukva==0x0a) break;
335
			if (bukva==0x0a) break;
349
			else len_str++;
336
			else len_str++;
350
		}
337
		}
351
		if (len_str<=col_count)
338
		if (len_str<=tview.column_max)
352
		{
339
		{
353
			address = mem_Alloc(len_str+1);
340
			address = mem_Alloc(len_str+1);
354
			ESDWORD[sub_pos*4+draw_sruct] = address;
341
			ESDWORD[sub_pos*4+draw_sruct] = address;
355
			strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, len_str);
342
			strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+cur_pos, len_str);
356
			pos=pos+len_str+1;
343
			cur_pos=cur_pos+len_str+1;
357
			sub_pos++;
344
			sub_pos++;
358
		}
345
		}
359
		else
346
		else
360
		{
347
		{
361
			address = mem_Alloc(len_str+1);
348
			address = mem_Alloc(len_str+1);
362
			ESDWORD[sub_pos*4+draw_sruct] = address;
349
			ESDWORD[sub_pos*4+draw_sruct] = address;
363
			strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, col_count);
350
			strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+cur_pos, tview.column_max);
364
			pos=pos+col_count;
351
			cur_pos=cur_pos+tview.column_max;
365
			sub_pos++;
352
			sub_pos++;
366
		}
353
		}
367
		len_str = 0;
354
		len_str = 0;
368
		if (pos>=bufsize-1) break;
355
		if (cur_pos>=bufsize-1) break;
369
	}
356
	}
Line 370... Line 357...
370
	pos=0;
357
	cur_pos=0;
371
}
358
}
372
 
359
 
373
void DrawText()
360
void DrawText()
374
{
361
{
375
	int i, top, num_line;
362
	int i, top, num_line;
376
	if (row_num
363
	if (tview.count
377
	else
364
	else
378
	{
365
	{
379
		if (row_num-cur_row<=row_count) top = row_num-cur_row-1;
366
		if (tview.count-tview.current<=tview.visible) top = tview.count-tview.current-1;
380
		else top = row_count;
367
		else top = tview.visible;
381
	}
368
	}
382
	DrawBar(0, TOPPANELH, Form.cwidth, 3, 0xFFFFFF);
369
	DrawBar(tview.x, tview.y, tview.w, 3, 0xFFFFFF);
383
	for (i=0, num_line = cur_row; i
370
	for (i=0, num_line = tview.current; i
384
	{
371
	{
385
		DrawBar(0, i*10+TOPPANELH+3, Form.cwidth, 10, 0xFFFFFF);
372
		DrawBar(tview.x, i * tview.line_h + tview.y + 3, tview.w, tview.line_h, 0xFFFFFF);
386
		WriteText(2, i*10+TOPPANELH+3, 0x80, 0x000000, DSDWORD[num_line*4+draw_sruct]);
373
		WriteText(tview.x + 2, i * tview.line_h + tview.y + 3, 0x80, 0x000000, DSDWORD[num_line*4+draw_sruct]);
Line 387... Line 374...
387
	}
374
	}
388
	DrawBar(0, i*10+TOPPANELH+3, Form.cwidth, -i*10-TOPPANELH-BOTPANELH+Form.cheight, 0xFFFFFF);
375
	DrawBar(0, i * tview.line_h + tview.y + 3, tview.w, -i* tview.line_h + tview.h, 0xFFFFFF);
389
}
376
}