Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5615 → Rev 5614

/programs/cmm/Calypte/Calypte.c
9,8 → 9,6
#include "..\lib\file_system.h"
#include "..\lib\dll.h"
#include "..\lib\gui.h"
#include "..\lib\list_box.h"
 
#include "..\lib\obj\box_lib.h"
#include "..\lib\obj\proc_lib.h"
#include "..\lib\obj\libio_lib.h"
63,17 → 61,15
};
#endif
 
#define TITLE "Calypte v0.11"
 
#define TOPPANELH 19
#define BOTPANELH 10
#define WIN_W 600
#define WIN_H 400
 
#define TITLE "Calypte v0.12"
char win_title[4096] = TITLE;
proc_info Form;
system_colors sc;
dword old_width,old_height;
llist tview;
 
byte active_properties = 0;
dword properties_window;
80,8 → 76,6
 
#include "include\gui.h"
#include "include\properties.h"
// #include "include\top_menu.h"
// #include "include\open_dial.h"
 
struct filter
{
96,9 → 90,18
filter filter2;
menu_text_struct menu_text_area1;
 
int read=0;
char win_title[4096] = "Calypte v0.11";
 
int
cur_row=0,
read=0,
pos=0,
row_num=0,
col_count=0,
row_count=0;
 
dword old_width,old_height;
 
proc_info pr_inf;
char communication_area_name[] = "FFFFFFFF_open_dialog";
byte plugin_path[4096];
118,7 → 121,6
void main()
{
int id, key;
mouse m;
strcpy(#filter2.ext1, "TXT");
//strcpy(#filter2.ext2, "ASM");
139,6 → 141,7
if (load_dll2(libio, #libio_init,1)!=0) notify(ERROR_LOAD_LIBIO);
if (load_dll2(Proc_lib, #OpenDialog_init,0)!=0) notify(ERROR_LOAD_PROC_LIB);
OpenDialog_init stdcall (#o_dialog);
SetEventMask(0x27);
loop()
{
145,11 → 148,8
switch(WaitEvent())
{
case evMouse:
m.get();
if (tview.MouseScrollNoSelection(m.vert)) DrawText();
menu_bar_mouse stdcall (#menudata1);
if (menudata1.click)
if (menudata1.click==1)
{
switch(menudata1.cursor_out)
{
185,14 → 185,14
case evButton:
id=GetButtonID();
if (id==1) ExitProcess();
if (id==1) || (id==10) ExitProcess();
break;
case evKey:
if (Form.status_window>2) break;
key = GetKey();
switch (key)
{
if (Form.status_window>2) break;
case 015: //Ctrl+O
OpenDialog_start stdcall (#o_dialog);
OpenFile(#openfile_path);
200,20 → 200,32
draw_window();
break;
case ASCII_KEY_HOME:
cur_row = 0;
DrawText();
break;
case ASCII_KEY_END:
cur_row = row_num - row_count - 1;
DrawText();
break;
case ASCII_KEY_UP:
if (!cur_row) break;
else cur_row = cur_row-1;
DrawText();
break;
case ASCII_KEY_DOWN:
if (tview.ProcessKey(key)) DrawText();
if (cur_row+row_count>=row_num) break;
cur_row = cur_row+1;
DrawText();
break;
case ASCII_KEY_PGUP:
if (!tview.current) break;
if (tview.current<tview.visible) tview.current = 0;
else tview.current = tview.current-tview.visible;
if (!cur_row) break;
if (cur_row<row_count) cur_row = 0;
else cur_row = cur_row-row_count;
DrawText();
break;
case ASCII_KEY_PGDN:
if (tview.current+tview.visible>tview.count) break;
tview.current = tview.current+tview.visible;
if (cur_row+row_count>row_num) break;
cur_row = cur_row+row_count;
DrawText();
break;
}
232,8 → 244,6
sc.get();
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) return;
tview.SetSizes(0, TOPPANELH, Form.cwidth, Form.cheight-BOTPANELH-TOPPANELH, 200, 12);
DrawBar(0, 0, Form.cwidth, TOPPANELH, sc.work);
DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, sc.work);
244,14 → 254,18
{
old_width = Form.width;
old_height = Form.height;
col_count = Form.cwidth/6;
row_count = Form.cheight-BOTPANELH-TOPPANELH-2;
row_count = row_count/10;
if (read==1) Prepare();
tview.debug_values();
}
if (read==1)
{
DrawText();
}
else DrawBar(tview.x, tview.y, tview.w, tview.h, 0xFFFFFF);
else DrawBar(0, TOPPANELH, Form.cwidth, Form.cheight-BOTPANELH-TOPPANELH, 0xFFFFFF);
}
 
void OpenFile(dword path)
273,7 → 287,7
void FreeBuf()
{
int i;
for (i=0; i<tview.count; i++)
for (i=0; i<row_num; i++)
{
mem_Free(DSDWORD[i*4+draw_sruct]);
}
284,17 → 298,16
void Prepare()
{
int i, sub_pos;
static int cur_pos;
int len_str = 0;
byte do_eof = 0;
word bukva[2];
dword address;
tview.count = 0;
row_num = 0;
while(1)
{
while(1)
{
bukva = DSBYTE[bufpointer+cur_pos+len_str];
bukva = DSBYTE[bufpointer+pos+len_str];
if (bukva=='\0')
{
do_eof = 1;
303,22 → 316,22
if (bukva==0x0a) break;
else len_str++;
}
if (len_str<=tview.column_max)
if (len_str<=col_count)
{
cur_pos=cur_pos+len_str+1;
tview.count++;
pos=pos+len_str+1;
row_num++;
}
else
{
cur_pos=cur_pos+tview.column_max;
tview.count++;
pos=pos+col_count;
row_num++;
}
len_str = 0;
if (do_eof) break;
}
mem_Free(draw_sruct);
draw_sruct = mem_Alloc(tview.count*4);
cur_pos=0;
draw_sruct = mem_Alloc(row_num*4);
pos=0;
sub_pos=0;
len_str = 0;
do_eof = 0;
326,7 → 339,7
{
while(1)
{
bukva = DSBYTE[bufpointer+cur_pos+len_str];
bukva = DSBYTE[bufpointer+pos+len_str];
if (bukva=='\0')
{
do_eof = 1;
335,12 → 348,12
if (bukva==0x0a) break;
else len_str++;
}
if (len_str<=tview.column_max)
if (len_str<=col_count)
{
address = mem_Alloc(len_str+1);
ESDWORD[sub_pos*4+draw_sruct] = address;
strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+cur_pos, len_str);
cur_pos=cur_pos+len_str+1;
strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, len_str);
pos=pos+len_str+1;
sub_pos++;
}
else
347,32 → 360,32
{
address = mem_Alloc(len_str+1);
ESDWORD[sub_pos*4+draw_sruct] = address;
strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+cur_pos, tview.column_max);
cur_pos=cur_pos+tview.column_max;
strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, col_count);
pos=pos+col_count;
sub_pos++;
}
len_str = 0;
if (cur_pos>=bufsize-1) break;
if (pos>=bufsize-1) break;
}
cur_pos=0;
pos=0;
}
 
void DrawText()
{
int i, top, num_line;
if (tview.count<tview.visible) top = tview.count;
if (row_num<row_count) top = row_num;
else
{
if (tview.count-tview.current<=tview.visible) top = tview.count-tview.current-1;
else top = tview.visible;
if (row_num-cur_row<=row_count) top = row_num-cur_row-1;
else top = row_count;
}
DrawBar(tview.x, tview.y, tview.w, 3, 0xFFFFFF);
for (i=0, num_line = tview.current; i<top; i++, num_line++)
DrawBar(0, TOPPANELH, Form.cwidth, 3, 0xFFFFFF);
for (i=0, num_line = cur_row; i<top; i++, num_line++)
{
DrawBar(tview.x, i * tview.line_h + tview.y + 3, tview.w, tview.line_h, 0xFFFFFF);
WriteText(tview.x + 2, i * tview.line_h + tview.y + 3, 0x80, 0x000000, DSDWORD[num_line*4+draw_sruct]);
DrawBar(0, i*10+TOPPANELH+3, Form.cwidth, 10, 0xFFFFFF);
WriteText(2, i*10+TOPPANELH+3, 0x80, 0x000000, DSDWORD[num_line*4+draw_sruct]);
}
DrawBar(0, i * tview.line_h + tview.y + 3, tview.w, -i* tview.line_h + tview.h, 0xFFFFFF);
DrawBar(0, i*10+TOPPANELH+3, Form.cwidth, -i*10-TOPPANELH-BOTPANELH+Form.cheight, 0xFFFFFF);
}
 
stop: