Table 0.98.5: UI refinement, bugfixing

git-svn-id: svn://kolibrios.org@7503 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-26 13:12:28 +00:00
parent 9bdda6b839
commit 3a9d0253bb
6 changed files with 289 additions and 376 deletions

View File

@ -6,13 +6,15 @@
#include "kosSyst.h" #include "kosSyst.h"
//#include "KosFile.h" //#include "KosFile.h"
extern DWORD def_col_width, def_row_height; #define DEFAULT_CELL_W 80
#define DEFAULT_CELL_H 19
extern DWORD col_count, row_count; extern DWORD col_count, row_count;
extern char ***cells; extern char ***cells;
extern DWORD *col_width, *row_height; extern DWORD *cell_w, *cell_h;
extern char ***values; extern char ***values;
extern DWORD *col_left, *row_top; extern DWORD *cell_x, *cell_y;
// áóôåð îáìåíà // áóôåð îáìåíà
extern char ***buffer; extern char ***buffer;
@ -21,6 +23,11 @@ extern DWORD buf_old_x, buf_old_y;
extern bool sel_moved; extern bool sel_moved;
extern struct GRID
{
int x,y,w,h;
} grid;
int cf_x0, cf_x1, cf_y0, cf_y1; int cf_x0, cf_x1, cf_y0, cf_y1;
@ -45,7 +52,7 @@ int get_x(int x)
if (x > col_count) if (x > col_count)
x = col_count; x = col_count;
for (i = 0; i < x; i++) for (i = 0; i < x; i++)
r+=col_width[i]; r+=cell_w[i];
return r; return r;
} }
@ -56,7 +63,7 @@ int get_y(int y)
if (y > row_count) if (y > row_count)
y = row_count; y = row_count;
for (i = 0; i < y; i++) for (i = 0; i < y; i++)
r+=row_height[i]; r+=cell_h[i];
return r; return r;
} }
@ -106,22 +113,19 @@ void init()
{ {
int i, j; int i, j;
//col_count = WND_W / def_col_width; cell_w = (DWORD*)allocmem(col_count * sizeof(DWORD));
//row_count = WND_H / def_row_height; cell_h = (DWORD*)allocmem(row_count * sizeof(DWORD));
cell_x = (DWORD*)allocmem(col_count * sizeof(DWORD));
col_width = (DWORD*)allocmem(col_count * sizeof(DWORD)); cell_y = (DWORD*)allocmem(row_count * sizeof(DWORD));
row_height = (DWORD*)allocmem(row_count * sizeof(DWORD));
col_left = (DWORD*)allocmem(col_count * sizeof(DWORD));
row_top = (DWORD*)allocmem(row_count * sizeof(DWORD));
for (i = 0; i < col_count; i++) for (i = 0; i < col_count; i++)
{ {
col_width[i] = def_col_width; cell_w[i] = DEFAULT_CELL_W;
} }
col_width[0] = 30; cell_w[0] = 30; //make row headers smaller
for (i = 0; i < row_count; i++) for (i = 0; i < row_count; i++)
{ {
row_height[i] = def_row_height; cell_h[i] = DEFAULT_CELL_H;
} }
cells = (char***)allocmem(col_count * sizeof(char**)); cells = (char***)allocmem(col_count * sizeof(char**));
@ -151,12 +155,12 @@ void reinit()
for (i = 0; i < col_count; i++) for (i = 0; i < col_count; i++)
{ {
col_width[i] = def_col_width; cell_w[i] = DEFAULT_CELL_W;
} }
for (i = 0; i < row_count; i++) for (i = 0; i < row_count; i++)
{ {
row_height[i] = def_row_height; cell_h[i] = DEFAULT_CELL_H;
} }
for (i = 1; i < col_count; i++) for (i = 1; i < col_count; i++)
@ -486,7 +490,7 @@ int SaveFile(char *fname)
{ {
char smalbuf[32]; char smalbuf[32];
memset((Byte*)smalbuf,0,32); memset((Byte*)smalbuf,0,32);
sprintf(smalbuf, "%U,", col_width[i]); sprintf(smalbuf, "%U,", cell_w[i]);
strcpy(buffer+strlen(buffer),smalbuf); strcpy(buffer+strlen(buffer),smalbuf);
} }
buffer[strlen(buffer)-1] = '\n'; // çàìåíèëè ïîñëåäíþþ çàïÿòóþ íà ïåðåâîä ñòðîêè buffer[strlen(buffer)-1] = '\n'; // çàìåíèëè ïîñëåäíþþ çàïÿòóþ íà ïåðåâîä ñòðîêè
@ -508,7 +512,7 @@ int SaveFile(char *fname)
{ {
char smalbuf[32]; char smalbuf[32];
memset((Byte*)smalbuf,0,32); memset((Byte*)smalbuf,0,32);
sprintf(smalbuf, "%U,", row_height[i]); sprintf(smalbuf, "%U,", cell_h[i]);
strcpy(buffer+strlen(buffer),smalbuf); strcpy(buffer+strlen(buffer),smalbuf);
} }
buffer[strlen(buffer)-1] = '\n'; // çàìåíèëè ïîñëåäíþþ çàïÿòóþ íà ïåðåâîä ñòðîêè buffer[strlen(buffer)-1] = '\n'; // çàìåíèëè ïîñëåäíþþ çàïÿòóþ íà ïåðåâîä ñòðîêè
@ -769,13 +773,13 @@ int LoadFile(char *fname)
} }
*d = '\0'; *d = '\0';
i = atoi(buffer); i = atoi(buffer);
col_width[items++] = i; cell_w[items++] = i;
if (items == col_count) if (items == col_count)
{ {
step++; step++;
items = 1; // òåïåðü âûñîòû ñòðîê ÷èòàòü ìû áóäåì ñìåëî items = 1; // òåïåðü âûñîòû ñòðîê ÷èòàòü ìû áóäåì ñìåëî
// ÷òîá èõ âîññòàíîâèòü è áûëî êàê âñåãäà // ÷òîá èõ âîññòàíîâèòü è áûëî êàê âñåãäà
//sprintf(debuf, "cols read done last buf %S file pos %U",buffer,fileInfo.OffsetLow); //sprintf(debuf, "col_count read done last buf %S file pos %U",buffer,fileInfo.OffsetLow);
//rtlDebugOutString(debuf); //rtlDebugOutString(debuf);
} }
d+=2; d+=2;
@ -793,7 +797,7 @@ int LoadFile(char *fname)
} }
*d = '\0'; *d = '\0';
i = atoi(buffer); i = atoi(buffer);
row_height[items++] = i; cell_h[items++] = i;
/*if (items > 5) /*if (items > 5)
{ {
sprintf(debuf, "set row from %S hei %U %U",buffer,items-1,i); sprintf(debuf, "set row from %S hei %U %U",buffer,items-1,i);

View File

@ -7,35 +7,23 @@ int SysColor = 0;
char debuf[50] = ""; char debuf[50] = "";
// ïî÷åìó-òî íå áûëî â ñòàíäàðòíîé áèáëèîòåêå void kos_DrawRegion(Word x, Word y,Word width, Word height, Dword color1, Word invert)
void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword invert )
{ {
Dword arg1, arg2, arg3; kos_DrawLine(x,y,x+width-2,y,color1,invert);
kos_DrawLine(x,y+1,x,y+height-1,color1,invert);
kos_DrawLine(x+width-1,y,x+width-1,y+height-2,color1,invert);
kos_DrawLine(x+1,y+height-1,x+width-1,y+height-1,color1,invert);
}
// void kos_DrawCutTextSmall(Word x, Word y, int areaWidth, Dword textColour, char *textPtr)
arg1 = ( x1 << 16 ) | x2; {
arg2 = ( y1 << 16 ) | y2; if (textPtr) {
arg3 = (invert)?0x01000000:colour; int textLen = strlen(textPtr);
// if (textLen*6 > areaWidth) textLen = areaWidth / 6;
__asm{ kos_WriteTextToWindow(x,y,0,textColour,textPtr,textLen);
mov eax, 38
mov ebx, arg1
mov ecx, arg2
mov edx, arg3
int 0x40
} }
} }
// ïîõèùåíî èç áèáëèîòåêè ê C--
void DrawRegion(Dword x,Dword y,Dword width,Dword height,Dword color1)
{
kos_DrawBar(x,y,width,1,color1); //ïîëîñà ãîð ñâåðõó
kos_DrawBar(x,y+height,width,1,color1); //ïîëîñà ãîð ñíèçó
kos_DrawBar(x,y,1,height,color1); //ïîëîñà âåðò ñëåâà
kos_DrawBar(x+width,y,1,height+1,color1); //ïîëîñà âåðò ñïðàâà
}
// äà, ýòî áàÿí // äà, ýòî áàÿí
int atoi(const char* string) int atoi(const char* string)
{ {

View File

@ -51,8 +51,8 @@ Dword kos_GetActiveSlot();
Dword kos_GetSkinHeight(); Dword kos_GetSkinHeight();
Dword kos_GetSpecialKeyState(); Dword kos_GetSpecialKeyState();
void kos_GetMouseStateWnd( Dword & buttons, int & cursorX, int & cursorY ); void kos_GetMouseStateWnd( Dword & buttons, int & cursorX, int & cursorY );
void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword invert); void kos_DrawRegion(Word x, Word y,Word width, Word height, Dword color1, Word invert);
void DrawRegion(Dword x,Dword y,Dword width,Dword height,Dword color1); void kos_DrawCutTextSmall(Word x, Word y, int areaWidth, Dword textColour, char *textPtr);
int atoi(const char* string); int atoi(const char* string);
void kos_GetScrollInfo(int &vert, int &hor); void kos_GetScrollInfo(int &vert, int &hor);

View File

@ -1,4 +1,3 @@
//не идёт дальше 98 строки
//если выделить область ячеек и сдвинуть курсор ввода с помощью клавиш, "следы" остануться //если выделить область ячеек и сдвинуть курсор ввода с помощью клавиш, "следы" остануться
//нельзя перемещаться по буквам в редактируемой строке //нельзя перемещаться по буквам в редактируемой строке
@ -7,7 +6,7 @@
#include "calc.h" #include "calc.h"
#include "use_library.h" #include "use_library.h"
#define TABLE_VERSION "0.98.1" #define TABLE_VERSION "0.98.7"
// строки, которые выводит программа // строки, которые выводит программа
const char *sFileSign = "KolibriTable File\n"; const char *sFileSign = "KolibriTable File\n";
@ -34,9 +33,8 @@ int cHeight;
#define TEXT_COLOR 0x000000 #define TEXT_COLOR 0x000000
#define CELL_COLOR 0xffffff #define CELL_COLOR 0xffffff
#define SEL_CELL_COLOR 0xe0e0ff #define SEL_CELL_COLOR 0xe0e0ff
#define FIXED_CELL_COLOR 0xe0e0ff #define HEADER_CELL_COLOR 0xE9E7E3
#define SEL_FIXED_CELL_COLOR 0x758FC1 #define SEL_HEADER_CELL_COLOR 0xC4C5BA //0xBBBBFF
#define TEXT_SEL_FIXED_COLOR 0xffffff
#define PANEL_BG_COLOR 0xe4dfe1 #define PANEL_BG_COLOR 0xe4dfe1
#define SCROLL_SIZE 16 #define SCROLL_SIZE 16
@ -57,18 +55,16 @@ int cHeight;
// bottom panel // bottom panel
#define MENU_PANEL_HEIGHT 40 #define MENU_PANEL_HEIGHT 40
Dword panel_y = 0; Dword panel_y = 0;
Dword mouse_dd;
// editbox data // editbox data
char edit_text[256] = ""; char edit_text[256] = "";
edit_box cell_box = {0,9*8-5,WND_H - 16-32,0xffffff,0x6a9480,0,0x808080,0,255,(dword)&edit_text,(dword)&mouse_dd,0}; edit_box cell_box = {0,9*8-5,WND_H - 16-32,0xffffff,0x6a9480,0,0x808080,0,255,(dword)&edit_text,0,0};
scroll_bar scroll_v = { SCROLL_SIZE,200,398, NULL, SCROLL_SIZE,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; scroll_bar scroll_v = { SCROLL_SIZE,200,398, NULL, SCROLL_SIZE,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
scroll_bar scroll_h = { 200,NULL,SCROLL_SIZE, NULL, SCROLL_SIZE,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; scroll_bar scroll_h = { 200,NULL,SCROLL_SIZE, NULL, SCROLL_SIZE,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
// ячейки - их параметры и текст // ячейки - их параметры и текст
DWORD def_col_width = 80, def_row_height = 16; DWORD col_count = 100, row_count = 100;
DWORD col_count = 200, row_count = 100; DWORD *cell_w, *cell_h;
DWORD *col_width, *row_height;
char ***cells; char ***cells;
struct GRID struct GRID
@ -78,10 +74,10 @@ struct GRID
char ***values; // значения формул, если есть char ***values; // значения формул, если есть
bool display_formulas = 0; // отображать ли формулы вместо значений bool display_formulas = false; // отображать ли формулы вместо значений
// координаты отображаемых столбцов и строк // координаты отображаемых столбцов и строк
DWORD *col_left, *row_top; DWORD *cell_x, *cell_y;
// буфер обмена // буфер обмена
char ***buffer = NULL; char ***buffer = NULL;
@ -112,7 +108,7 @@ DWORD nx = 0, ny = 0;
// редактирование имени файла // редактирование имени файла
bool fn_edit = 0; bool fn_edit = 0;
char fname[256]; char fname[256];
edit_box file_box = {98,9*8-5,WND_H - 16-32,0xffffff,0x6a9480,0,0x808080,0,255,(dword)&fname,(dword)&mouse_dd,0}; edit_box file_box = {98,9*8-5,WND_H - 16-32,0xffffff,0x6a9480,0,0x808080,0,255,(dword)&fname,0,0};
// изменение размеров // изменение размеров
#define SIZE_X 1 // состояние #define SIZE_X 1 // состояние
@ -126,44 +122,7 @@ int drag_x, drag_y;
int old_end_x, old_end_y; int old_end_x, old_end_y;
void draw_window(); void draw_window();
void draw_grid();
void kos_DrawRegion(Word x, Word y,Word width, Word height, Dword color1, Word invert)
{
kos_DrawLine(x,y,x+width-2,y,color1,invert);
kos_DrawLine(x,y+1,x,y+height-1,color1,invert);
kos_DrawLine(x+width-1,y,x+width-1,y+height-2,color1,invert);
kos_DrawLine(x+1,y+height-1,x+width-1,y+height-1,color1,invert);
}
void kos_DebugValue(char *str, int n)
{
char debuf[50];
sprintf(debuf, "%S: %U\n", str, n);
rtlDebugOutString(debuf);
}
void DrawScrolls()
{
// HOR
scroll_h.x = 0;
scroll_h.y = grid.y + grid.h;
scroll_h.w = grid.w;
scroll_h.all_redraw = true;
scroll_h.max_area = col_count;
scroll_h.cur_area = nx-scroll_x-1;
scroll_h.position = scroll_x-1;
scrollbar_h_draw((DWORD)&scroll_h);
// VER
scroll_v.x = grid.x + grid.w;
scroll_v.y = 0;
scroll_v.h = grid.h;
scroll_v.all_redraw = true;
scroll_v.max_area = row_count;
scroll_v.cur_area = ny-scroll_y-1;
scroll_v.position = scroll_y-1;
scrollbar_v_draw((DWORD)&scroll_v);
}
void DrawSelectedFrame(int x, int y, int w, int h, DWORD col) void DrawSelectedFrame(int x, int y, int w, int h, DWORD col)
{ {
@ -174,11 +133,30 @@ void DrawSelectedFrame(int x, int y, int w, int h, DWORD col)
kos_DrawBar(x+w-4,y+h-4,4,4,col); kos_DrawBar(x+w-4,y+h-4,4,4,col);
} }
void kos_DeleteButton(int id) void DrawScrolls()
{ {
kos_DefineButton(NULL, NULL, NULL, NULL, id+BT_DEL, NULL); // HOR
scroll_h.x = 0;
scroll_h.y = grid.y + grid.h;
scroll_h.w = grid.w + SCROLL_SIZE + 1;
scroll_h.all_redraw = true;
scroll_h.max_area = col_count - 2;
scroll_h.cur_area = nx-scroll_x-1;
scroll_h.position = scroll_x-1;
scrollbar_h_draw((DWORD)&scroll_h);
// VER
scroll_v.x = grid.x + grid.w;
scroll_v.y = 0;
scroll_v.h = grid.h + 1;
scroll_v.all_redraw = true;
scroll_v.max_area = row_count - 2;
scroll_v.cur_area = ny-scroll_y-1;
scroll_v.position = scroll_y-1;
scrollbar_v_draw((DWORD)&scroll_v);
} }
void start_edit(int x, int y) void start_edit(int x, int y)
{ {
int ch = 0; int ch = 0;
@ -201,10 +179,10 @@ void start_edit(int x, int y)
file_box.flags &= ~ed_focus; file_box.flags &= ~ed_focus;
cell_box.flags |= ed_focus; cell_box.flags |= ed_focus;
cell_box.left = col_left[x] + 1; cell_box.left = cell_x[x] + 2;
cell_box.top = row_top[y] + 1; cell_box.top = cell_y[y] + 2;
cell_box.width = col_width[x] - 2; cell_box.width = cell_w[x] - 4;
//cell_box.height= row_height[y]; //cell_box.height= cell_h[y];
memset((Byte*)edit_text, 0, sizeof(edit_text)); memset((Byte*)edit_text, 0, sizeof(edit_text));
if (cells[x][y]) if (cells[x][y])
{ {
@ -288,7 +266,7 @@ void move_selection(DWORD new_x, DWORD new_y)
sel_y = row_count - 1; sel_y = row_count - 1;
sel_end_y = sel_y; sel_end_y = sel_y;
check_sel(); check_sel();
draw_window(); draw_grid();
} }
// x - между low и high ? - необязательно low<high // x - между low и high ? - необязательно low<high
@ -300,20 +278,20 @@ bool is_between(Dword x, Dword low, Dword high)
void clear_cell_slow(int px, int py) void clear_cell_slow(int px, int py)
{ {
int i; int i;
int x0 = col_width[0]; int x0 = cell_w[0];
for (i = scroll_x; i < px; i++) for (i = scroll_x; i < px; i++)
{ {
x0 += col_width[i]; x0 += cell_w[i];
} }
int x1 = x0; int x1 = x0;
x1 += col_width[px]; x1 += cell_w[px];
int y0 = row_height[0]; int y0 = cell_h[0];
for (i = scroll_y; i < py; i++) for (i = scroll_y; i < py; i++)
{ {
y0 += row_height[i]; y0 += cell_h[i];
} }
int y1 = y0; int y1 = y0;
y1 += row_height[py]; y1 += cell_h[py];
kos_DrawBar(x0 + 1, y0 + 1, x1 - x0 - 1, y1 - y0 - 1, 0xffffff); kos_DrawBar(x0 + 1, y0 + 1, x1 - x0 - 1, y1 - y0 - 1, 0xffffff);
} }
@ -323,12 +301,32 @@ void clear_cell_slow(int px, int py)
#define is_x_changed(v) ((v) == sel_x || (v) == prev_x) #define is_x_changed(v) ((v) == sel_x || (v) == prev_x)
#define is_y_changed(v) ((v) == sel_y || (v) == prev_y) #define is_y_changed(v) ((v) == sel_y || (v) == prev_y)
void DrawCell(int x, int y, Dword w, Dword h, Dword id, Dword bg_color, char* text, bool header)
{
bool small = false;
if (x>grid.x+grid.w || w>grid.w || w<=0) return;
if (x+w > grid.x + grid.w) {
w = grid.x + grid.w - x;
small = true;
}
if (y+h > grid.y + grid.h) {
h = grid.y + grid.h - y;
small = true;
}
kos_DrawBar(x, y, w, h, bg_color);
if (!small) {
if (id) kos_DefineButton(x+5, y, w-10, h-1, id+BT_NODRAW,0);
if (header) kos_WriteTextToWindow( x + w/2 -strlen(text)*3, h/2-4+y, 0x80,TEXT_COLOR,text,0); //WriteTextCenter
else kos_DrawCutTextSmall(x+2, h/2-4+y, w-7, TEXT_COLOR, text);
}
}
void draw_grid() void draw_grid()
{ {
int i,j; int i,j;
long x0 = 0, y0 = 0, x = 0, y = 0, dx; long x0 = 0, y0 = 0, x = 0, y = 0;
DWORD text_color;
DWORD bg_color; DWORD bg_color;
kos_DrawBar(0,0,cell_w[0],cell_h[0],HEADER_CELL_COLOR); // left top cell
nx=ny=0; nx=ny=0;
@ -340,193 +338,107 @@ void draw_grid()
} }
else else
{ {
// очистить всю область ячеек // clean all cells
//kos_DrawBar(col_width[0]+1, row_height[0]+1, grid.w - SCROLL_SIZE-col_width[0]-1, he - SCROLL_SIZE-row_height[0]-1, 0xffffff); //kos_DrawBar(cell_w[0]+1, cell_h[0]+1, grid.w - SCROLL_SIZE-cell_w[0]-1, he - SCROLL_SIZE-cell_h[0]-1, 0xffffff);
} }
col_left[0] = 0; // column headers + vertical lines
// ячейки - заголовки столбцов + вертикальные линии cell_x[0] = 0;
x = col_width[0]; x = cell_w[0];
nx = 1; nx = 1;
for (i = 1; i < col_count; i++) for (i = 1; i < col_count && x-x0 < grid.w; i++)
{ {
col_left[i] = -1; cell_x[i] = -1;
if (i >= scroll_x) if (i >= scroll_x)
{ {
{ {
if (!sel_moved || is_x_changed(i)) {
kos_DrawLine(x-x0, 0, x-x0, row_height[0], GRID_COLOR, 0);
}
// и заголовок ячейки по х
text_color = TEXT_COLOR;
dx = (col_width[i]-6)/2;
int dy = (row_height[0] - 8) / 2 + 1;
int cur_width = col_width[i] - 1;
if (cur_width + x - x0 > grid.w)
cur_width = grid.w - x + x0 -1;
if (!sel_moved || (is_x_changed(i))) { if (!sel_moved || (is_x_changed(i))) {
if (is_between(i,sel_x,sel_end_x)) if (is_between(i,sel_x,sel_end_x)) bg_color = SEL_HEADER_CELL_COLOR; else bg_color = HEADER_CELL_COLOR;
{ kos_DrawBar(x-x0, 0, 1, grid.h, GRID_COLOR);
bg_color = SEL_FIXED_CELL_COLOR; DrawCell(x-x0+1, 0, cell_w[i]-1, cell_h[0], i+COL_HEAD_BUTTON, bg_color, cells[i][0], true);
text_color = TEXT_SEL_FIXED_COLOR;
}
else
{
bg_color = FIXED_CELL_COLOR;
text_color = TEXT_COLOR;
}
kos_DrawBar(x - x0 + 1,0,cur_width,row_height[0],bg_color);
kos_WriteTextToWindow(x-x0+2+dx,dy,0,text_color,cells[i][0],strlen(cells[i][0]));
} }
// есть кнопка стоблца и еще кнопка изменения ширины cell_x[i] = x - x0;
if (x - x0 + col_width[i] <= grid.w - col_width[0])
{
kos_DeleteButton(COL_HEAD_BUTTON+i);
kos_DefineButton(x-x0+5,0,cur_width - 10,row_height[0]-1,BT_NODRAW+COL_HEAD_BUTTON+i,0);
}
//kos_DefineButton(x-x0+col_width[i]-10,0,15,row_height[0]-1,BT_NODRAW+COL_SIZE_BUTTON+i,0);
col_left[i] = x - x0;
}
if (x - x0 > grid.w - col_width[0])
{
x += col_width[i];
nx++;
break;
} }
} }
else else
{ {
x0 += col_width[i]; x0 += cell_w[i];
} }
x += col_width[i]; x += cell_w[i];
nx++; nx++;
} }
//kos_DefineButton(0,0,0,0,0x80000000+COL_HEAD_BUTTON+i,0); // row headers + horizontal lines
y = cell_h[0];
for (j = i + 1; j < col_count; j++)
col_left[j] = grid.w;
//if (!sel_moved || (is_x_changed(nx))) kos_DrawLine(x - x0, 0, x - x0, grid.h, GRID_COLOR, 0);
// ячейки - заголовки строк + горизонт. линии
y = row_height[0];
ny = 1; ny = 1;
row_top[0] = 0; cell_y[0] = 0;
for (i = 1; i < row_count && y - y0 < grid.h; i++) for (i = 1; i < row_count && y-y0 < grid.h; i++)
{ {
row_top[i] = -1; cell_y[i] = -1;
if (i >= scroll_y) if (i >= scroll_y)
{ {
{ {
if (!sel_moved || (is_y_changed(i))) if (!sel_moved || (is_y_changed(i))) {
kos_DrawLine(0, y - y0, grid.w - 1, y - y0, GRID_COLOR, 0); if (is_between(i,sel_y,sel_end_y)) bg_color = SEL_HEADER_CELL_COLOR; else bg_color = HEADER_CELL_COLOR;
// и заголовок ячейки по y kos_DrawBar(0, y-y0, grid.w, 1, GRID_COLOR);
text_color = TEXT_COLOR; DrawCell(0, y-y0+1, cell_w[0], cell_h[i]-1, i+ROW_HEAD_BUTTON, bg_color, cells[0][i], true);
dx = (col_width[0]-6 * strlen(cells[0][i]))/2; // optimize this, change strlen }
int dy = (row_height[i] - 8) / 2 + 1; cell_y[i] = y - y0;
if (!sel_moved || (is_y_changed(i)))
if (is_between(i,sel_y,sel_end_y))
{
kos_DrawBar(0,y-y0+1,col_width[0],row_height[i] - 1,SEL_FIXED_CELL_COLOR);
text_color = TEXT_SEL_FIXED_COLOR;
}
else
{
kos_DrawBar(0,y-y0+1,col_width[0],row_height[i] - 1,FIXED_CELL_COLOR);
text_color = TEXT_COLOR;
}
if (!sel_moved || (is_y_changed(i)))
kos_WriteTextToWindow(2+dx,y-y0+dy,0,text_color,cells[0][i],strlen(cells[0][i]));
kos_DeleteButton(ROW_HEAD_BUTTON+i);
kos_DefineButton(0,y-y0+5,col_width[0]-1,row_height[i]-6,BT_NODRAW+ROW_HEAD_BUTTON+i,0);
//kos_DefineButton(0,y-y0+row_height[i]-5,col_width[0]-1,10,BT_NODRAW+ROW_SIZE_BUTTON+i,0);
row_top[i] = y - y0;
} }
} }
else else
{ {
y0 += row_height[i]; y0 += cell_h[i];
} }
y += row_height[i]; y += cell_h[i];
ny++; ny++;
} }
kos_DefineButton(0,0,0,0,0x80000000+ROW_HEAD_BUTTON+ny-1,0);
for (j = i + 1; j < row_count; j++)
row_top[j] = grid.h;
if (!sel_moved || (is_y_changed(ny)))
kos_DrawLine(0, y - y0, grid.w, y - y0, GRID_COLOR, 0);
if (!sel_moved || (is_x_changed(0) && is_y_changed(0)))
kos_DrawBar(0,0,col_width[0],row_height[0],FIXED_CELL_COLOR);
// ЛВ ячейка
//sprintf(debuf, "%U, %U; %U, %U", x0, y0, nx, ny);
//rtlDebugOutString(debuf);
// cells itself // cells itself
y = cell_h[0];
y = row_height[0];
for (i = scroll_y; i < ny; i++) for (i = scroll_y; i < ny; i++)
{ {
x = col_width[0]; x = cell_w[0];
if (!sel_moved) for (j = scroll_x; j < nx; j++)
kos_DrawBar(col_width[0]+1, y+1, grid.w -col_width[0]-1, row_height[i]-1, 0xffffff);
for (j = scroll_x; j < nx-1; j++)
{ {
if (!sel_moved || is_x_changed(j) || is_y_changed(i)) if (i && j) //no need to draw headers one more
kos_DrawLine(col_left[j], row_top[i], col_left[j], row_height[i], GRID_COLOR, 0);
// заголовки уже нарисованы - пропускаем их
if (i && j)
{ {
//kos_DrawBar(x+1, y+1, col_width[i]-1, row_height[i]-1, 0xffffff); bool draw_frame_selection = false;
bool error = false;
bg_color = CELL_COLOR;
//rtlDebugOutString(cap); if (is_between(j,sel_x,sel_end_x) && is_between(i, sel_y, sel_end_y) // (j,i) - selected
//if (j >= sel_x && j <= sel_end_x && i >= sel_y && i <= sel_end_y) && ((!sel_moved) || (is_x_changed(j) && is_y_changed(i)))) // and we must draw it
if (is_between(j,sel_x,sel_end_x) && is_between(i, sel_y, sel_end_y) // (j,i) - âûäåëåíà
&& ((!sel_moved) || (is_x_changed(j) && is_y_changed(i)))) // è åå íóæíî íàðèñîâàòü
{ {
if (i == sel_y && j == sel_x) // frame if (i == sel_y && j == sel_x)
{ {
DrawSelectedFrame(x+1,y, col_width[j]-1, row_height[j], TEXT_COLOR); draw_frame_selection = true;
drag_x = x + col_width[j] - 4; drag_x = x + cell_w[j] - 4;
drag_y = y + row_height[i] - 4; drag_y = y + cell_h[i] - 4;
}
else {
bg_color = SEL_CELL_COLOR; // selected but not main
} }
else
kos_DrawBar(x + 1,y + 1,col_width[j] - 2,row_height[i] - 2,SEL_CELL_COLOR); // âûäåëåíà íî íå îñíîâíàÿ(ñåðàÿ)
} }
//kos_DefineButton(x,y,col_width[j]-1,row_height[i]-1,BT_NODRAW+CELL_BUTTON+((i << 8) + j),0);
char *text; char *text;
if (values[j][i] && values[j][i][0] == '#') if (values[j][i] && values[j][i][0] == '#')
{ {
text = cells[j][i]; text = cells[j][i];
kos_DrawRegion(x+1, y+1, col_width[j]-1, row_height[i]-1, 0xff0000, 0); error = true;
} }
else else {
text = (values[j][i] && !display_formulas ? values[j][i] : cells[j][i]); text = (values[j][i] && !display_formulas ? values[j][i] : cells[j][i]);
}
int dy = (row_height[i] - 8) / 2 + 1; DrawCell(x+1, y+1, cell_w[j]-1, cell_h[i]-1, 0, bg_color, text, false);
if (draw_frame_selection) DrawSelectedFrame(x+1,y, cell_w[j]-1, cell_h[i], TEXT_COLOR);
if (text) else if (error) kos_DrawRegion(x+1, y+1, cell_w[j]-1, cell_h[i]-1, 0xff0000, 0);
if (strlen(text) < col_width[j]/6)
kos_WriteTextToWindow(x+2,y+dy,0,text_color,text,strlen(text));
else
kos_WriteTextToWindow(x+2,y+dy,0,text_color,text,col_width[j]/6);
} }
if (!sel_moved || is_x_changed(j) || is_y_changed(i)) x += cell_w[j];
kos_DrawLine(col_left[j]+col_width[j], row_top[i], col_left[j]+col_width[j], row_height[i], GRID_COLOR, 0);
x += col_width[j];
} }
y += row_height[i]; y += cell_h[i];
} }
DrawScrolls(); DrawScrolls();
} }
@ -539,9 +451,9 @@ void draw_size_grid()
{ {
int x, x0, i; int x, x0, i;
x = col_width[0]; x = cell_w[0];
x0 = 0; x0 = 0;
for (i = 1; i < col_count && x - x0 + col_width[i] < grid.w - 10; i++) for (i = 1; i < col_count && x - x0 + cell_w[i] < grid.w - 10; i++)
{ {
if (i >= scroll_x) if (i >= scroll_x)
{ {
@ -549,8 +461,8 @@ void draw_size_grid()
kos_DrawLine(x - x0, 0, x - x0, grid.h, 0, 1); kos_DrawLine(x - x0, 0, x - x0, grid.h, 0, 1);
} }
else else
x0 += col_width[i]; x0 += cell_w[i];
x += col_width[i]; x += cell_w[i];
} }
kos_DrawLine(x - x0, 0, x - x0, grid.h, 0, 1); kos_DrawLine(x - x0, 0, x - x0, grid.h, 0, 1);
} }
@ -558,9 +470,9 @@ void draw_size_grid()
{ {
int y, y0, i; int y, y0, i;
y = row_height[0]; y = cell_h[0];
y0 = 0; y0 = 0;
for (i = 1; i < col_count && y - y0 + row_height[i] < grid.h - 10; i++) for (i = 1; i < col_count && y - y0 + cell_h[i] < grid.h - 10; i++)
{ {
if (i >= scroll_y) if (i >= scroll_y)
{ {
@ -568,8 +480,8 @@ void draw_size_grid()
kos_DrawLine(0, y - y0, grid.w, y - y0, 0, 1); kos_DrawLine(0, y - y0, grid.w, y - y0, 0, 1);
} }
else else
y0 += row_height[i]; y0 += cell_h[i];
y += row_height[i]; y += cell_h[i];
} }
kos_DrawLine(0, y - y0, grid.w, y - y0, 0, 1); kos_DrawLine(0, y - y0, grid.w, y - y0, 0, 1);
} }
@ -584,16 +496,15 @@ void draw_size_grid()
void draw_drag() void draw_drag()
{ {
// inverted lines // inverted lines
int k0 = min(sel_x, sel_end_x); int k0 = min(sel_x, sel_end_x);
int k1 = max(sel_x, sel_end_x); int k1 = max(sel_x, sel_end_x);
int n0 = min(sel_y, sel_end_y); int n0 = min(sel_y, sel_end_y);
int n1 = max(sel_y, sel_end_y); int n1 = max(sel_y, sel_end_y);
DWORD x0 = col_left[k0] - 1; DWORD x0 = cell_x[k0] - 1;
DWORD x1 = col_left[k1] + col_width[k1] + 1; DWORD x1 = cell_x[k1] + cell_w[k1] + 1;
DWORD y0 = row_top[n0] - 1; DWORD y0 = cell_y[n0] - 1;
DWORD y1 = row_top[n1] + row_height[n1] + 1; DWORD y1 = cell_y[n1] + cell_h[n1] + 1;
if (x0 > grid.w - 1) x0 = grid.w - 1; if (x0 > grid.w - 1) x0 = grid.w - 1;
if (x1 > grid.w - 1) x1 = grid.w - 1; if (x1 > grid.w - 1) x1 = grid.w - 1;
if (y0 > grid.h - 1) y0 = grid.h - 1; if (y0 > grid.h - 1) y0 = grid.h - 1;
@ -621,7 +532,7 @@ bool draw_and_define_window()
grid.x = 0; grid.x = 0;
grid.y = 0; grid.y = 0;
grid.w = cWidth - SCROLL_SIZE; grid.w = cWidth - SCROLL_SIZE - 1;
grid.h = cHeight - MENU_PANEL_HEIGHT - SCROLL_SIZE; grid.h = cHeight - MENU_PANEL_HEIGHT - SCROLL_SIZE;
if (info.processInfo.status_window&0x04) return false; //draw nothing if window is rolled-up if (info.processInfo.status_window&0x04) return false; //draw nothing if window is rolled-up
@ -629,23 +540,20 @@ bool draw_and_define_window()
if (grid.h < 100) { kos_ChangeWindow( -1, -1, -1, 180 ); return false; } if (grid.h < 100) { kos_ChangeWindow( -1, -1, -1, 180 ); return false; }
if (grid.w < 340) { kos_ChangeWindow( -1, -1, 350, -1 ); return false; } if (grid.w < 340) { kos_ChangeWindow( -1, -1, 350, -1 ); return false; }
sel_moved = 0;
return true; return true;
} }
void draw_window() void draw_window()
{ {
if (sel_end_move) if (sel_end_move) sel_moved = 0;
sel_moved = 0;
panel_y = cHeight - MENU_PANEL_HEIGHT; panel_y = cHeight - MENU_PANEL_HEIGHT + 1;
if (!sel_moved) kos_DrawBar(0, panel_y, cWidth, MENU_PANEL_HEIGHT-1, PANEL_BG_COLOR);
{ kos_WriteTextToWindow(3 + 1, panel_y + 16, 0x80, 0x000000, (char*)sFilename, 0);
kos_DrawBar(cWidth-SCROLL_SIZE, panel_y - SCROLL_SIZE, SCROLL_SIZE, SCROLL_SIZE, PANEL_BG_COLOR);
kos_DrawBar(0, panel_y, cWidth, MENU_PANEL_HEIGHT, PANEL_BG_COLOR);
kos_WriteTextToWindow(3 + 1, panel_y + 16, 0x80, 0x000000, (char*)sFilename, 0);
}
file_box.top = panel_y + 12; file_box.top = panel_y + 12;
@ -686,9 +594,6 @@ void process_mouse()
int vert, hor; int vert, hor;
kos_GetScrollInfo(vert, hor); kos_GetScrollInfo(vert, hor);
//sprintf(debuf, "scroll %U %U", vert, hor);
//rtlDebugOutString(debuf);
if (vert != 0) if (vert != 0)
{ {
stop_edit(); stop_edit();
@ -743,13 +648,13 @@ void process_mouse()
old_end_x = sel_end_x; old_end_x = sel_end_x;
old_end_y = sel_end_y; old_end_y = sel_end_y;
} }
else if (mouse_y <= row_height[0]) else if (mouse_y <= cell_h[0])
{ {
//rtlDebugOutString("can resize cols"); //rtlDebugOutString("can resize col_count");
int kx = -1, i; int kx = -1, i;
for (i = 0; i < col_count - 1; i++) for (i = 0; i < col_count - 1; i++)
if (mouse_x >= col_left[i] + col_width[i] - 5 && if (mouse_x >= cell_x[i] + cell_w[i] - 5 &&
mouse_x <= col_left[i + 1] + 5) mouse_x <= cell_x[i + 1] + 5)
{ {
kx = i; break; kx = i; break;
} }
@ -761,12 +666,12 @@ void process_mouse()
size_state = SIZE_X; size_state = SIZE_X;
} }
} }
else if (mouse_x <= col_width[0]) else if (mouse_x <= cell_w[0])
{ {
int ky = -1; int ky = -1;
for (i = 0; i < row_count - 1; i++) for (i = 0; i < row_count - 1; i++)
if (mouse_y >= row_top[i] + row_height[i] - 5 && if (mouse_y >= cell_y[i] + cell_h[i] - 5 &&
mouse_y <= row_top[i + 1] + 5) mouse_y <= cell_y[i + 1] + 5)
{ {
ky = i; break; ky = i; break;
} }
@ -777,20 +682,20 @@ void process_mouse()
} }
} }
else // click on cell else // click on cell
if (mouse_x <= col_left[nx - 1] && mouse_y <= row_top[ny - 1]) if (mouse_x <= cell_x[nx - 1] && mouse_y <= cell_y[ny - 1])
{ {
was_single_selection = sel_x == sel_end_x && sel_y == sel_end_y; was_single_selection = sel_x == sel_end_x && sel_y == sel_end_y;
int kx = -1, i; int kx = -1, i;
for (i = 0; i < col_count - 1; i++) for (i = 0; i < col_count - 1; i++)
if (mouse_x >= col_left[i] && if (mouse_x >= cell_x[i] &&
mouse_x <= col_left[i] + col_width[i]) mouse_x <= cell_x[i] + cell_w[i])
{ {
kx = i; break; kx = i; break;
} }
int ky = -1; int ky = -1;
for (i = 0; i < row_count - 1; i++) for (i = 0; i < row_count - 1; i++)
if (mouse_y >= row_top[i] && if (mouse_y >= cell_y[i] &&
mouse_y <= row_top[i] + row_height[i]) mouse_y <= cell_y[i] + cell_h[i])
{ {
ky = i; break; ky = i; break;
} }
@ -834,21 +739,21 @@ void process_mouse()
if (size_state == SIZE_X && mouse_x != size_mouse_x) if (size_state == SIZE_X && mouse_x != size_mouse_x)
{ {
draw_size_grid(); draw_size_grid();
col_width[size_id] += mouse_x - size_mouse_x; cell_w[size_id] += mouse_x - size_mouse_x;
if (col_width[size_id] < 15) if (cell_w[size_id] < 15)
col_width[size_id] = 15; cell_w[size_id] = 15;
else if (col_width[size_id] > grid.w / 2) else if (cell_w[size_id] > grid.w / 2)
col_width[size_id] = grid.w / 2; cell_w[size_id] = grid.w / 2;
draw_size_grid(); draw_size_grid();
} }
if (size_state == SIZE_Y && mouse_y != size_mouse_y) if (size_state == SIZE_Y && mouse_y != size_mouse_y)
{ {
draw_size_grid(); draw_size_grid();
row_height[size_id] += mouse_y - size_mouse_y; cell_h[size_id] += mouse_y - size_mouse_y;
if (row_height[size_id] < 15) if (cell_h[size_id] < 15)
row_height[size_id] = 15; cell_h[size_id] = 15;
else if (row_height[size_id] > grid.h / 2) else if (cell_h[size_id] > grid.h / 2)
row_height[size_id] = grid.h / 2; cell_h[size_id] = grid.h / 2;
draw_size_grid(); draw_size_grid();
} }
if ((size_state == SIZE_SELECT || size_state == SIZE_DRAG) && (mouse_x != size_mouse_x || mouse_y != size_mouse_y)) if ((size_state == SIZE_SELECT || size_state == SIZE_DRAG) && (mouse_x != size_mouse_x || mouse_y != size_mouse_y))
@ -856,22 +761,22 @@ void process_mouse()
draw_drag(); draw_drag();
int kx = -1, i; int kx = -1, i;
for (i = 0; i < col_count - 1; i++) for (i = 0; i < col_count - 1; i++)
if (mouse_x >= col_left[i] && if (mouse_x >= cell_x[i] &&
mouse_x <= col_left[i + 1]) mouse_x <= cell_x[i + 1])
{ {
//sprintf(debuf, "yyy %U",col_left[i+1]); //sprintf(debuf, "yyy %U",cell_x[i+1]);
//rtlDebugOutString(debuf); //rtlDebugOutString(debuf);
kx = i; break; kx = i; break;
} }
int ky = -1; int ky = -1;
for (i = 0; i < row_count - 1; i++) for (i = 0; i < row_count - 1; i++)
if (mouse_y >= row_top[i] && if (mouse_y >= cell_y[i] &&
mouse_y <= row_top[i + 1]) mouse_y <= cell_y[i + 1])
{ {
ky = i; break; ky = i; break;
} }
if (kx != -1) sel_end_x = kx; if (kx != -1) sel_end_x = kx;
if (kx != -1) sel_end_y = ky; if (ky != -1) sel_end_y = ky;
if (size_state == SIZE_DRAG) if (size_state == SIZE_DRAG)
{ {
if (abs(sel_end_x - sel_x) > 0) if (abs(sel_end_x - sel_x) > 0)
@ -899,9 +804,6 @@ void process_key()
ckeys = kos_GetSpecialKeyState(); ckeys = kos_GetSpecialKeyState();
shift = ckeys & 0x3; shift = ckeys & 0x3;
ctrl = ckeys & 0x0c; ctrl = ckeys & 0x0c;
//if (ctrl)
// rtlDebugOutString("control pressed!");
dx = 0, dy = 0;
sel_moved = 0; sel_moved = 0;
sel_end_move = 0; sel_end_move = 0;
kos_GetKey(keyCode); kos_GetKey(keyCode);
@ -917,40 +819,22 @@ void process_key()
switch (keyCode) switch (keyCode)
{ {
case 178: case 178:
//dx = 0;
dy = -1; dy = -1;
break; break;
case 176: case 176:
dx = -1; dx = -1;
//dy = 0;
break; break;
case 179: case 179:
dx = 1; dx = 1;
//dy = 0;
break; break;
case 177: case 177:
//dx = 0;
dy = 1; dy = 1;
break; break;
case 183: case 183:
/* dy = ny - scroll_y-1;
if (sel_y < row_count-(ny - scroll_y)) // page down
dy = ny - scroll_y;
else
dy = row_count-(ny - scroll_y) - sel_y;
dx = 0;
redraw = 1;
*/
break; break;
case 184: case 184:
/* dy = - (ny - scroll_y);
if (sel_y > ny - scroll_y) // page up
dy= - (ny - scroll_y);
else
dy = - (ny - scroll_y) + sel_y;
dx = 0;
redraw = 1;
*/
break; break;
case 180: //home case 180: //home
dx = -sel_x + 1; dx = -sel_x + 1;
@ -1173,7 +1057,6 @@ void process_button()
{ {
Dword mouse_btn, ckeys, shift, ctrl; Dword mouse_btn, ckeys, shift, ctrl;
int mouse_x, mouse_y, i, p, dx = 0, dy = 0; int mouse_x, mouse_y, i, p, dx = 0, dy = 0;
int redraw = 0;
Dword button; Dword button;
if (!kos_GetButtonID(button)) return; if (!kos_GetButtonID(button)) return;

View File

@ -421,7 +421,7 @@ void sprintf( char *Str, char* Format, ... )
} }
// функция -1 завершения процесса // function -1 çàâåðøåíèÿ ïðîöåññà
void kos_ExitApp() void kos_ExitApp()
{ {
int i; int i;
@ -440,7 +440,7 @@ void kos_ExitApp()
} }
// функция 0 // function 0
void kos_DefineAndDrawWindow( void kos_DefineAndDrawWindow(
Word x, Word y, Word x, Word y,
Word sizeX, Word sizeY, Word sizeX, Word sizeY,
@ -471,7 +471,7 @@ void kos_DefineAndDrawWindow(
} }
// функция 1 поставить точку // function 1 ïîñòàâèòü òî÷êó
void kos_PutPixel( Dword x, Dword y, Dword colour ) void kos_PutPixel( Dword x, Dword y, Dword colour )
{ {
// //
@ -485,7 +485,7 @@ void kos_PutPixel( Dword x, Dword y, Dword colour )
} }
// функция 2 получить код нажатой клавиши // function 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
bool kos_GetKey( Byte &keyCode ) bool kos_GetKey( Byte &keyCode )
{ {
Dword result; Dword result;
@ -503,7 +503,7 @@ bool kos_GetKey( Byte &keyCode )
} }
// функция 3 получить время // function 3 ïîëó÷èòü âðåìÿ
Dword kos_GetSystemClock() Dword kos_GetSystemClock()
{ {
// Dword result; // Dword result;
@ -519,7 +519,7 @@ Dword kos_GetSystemClock()
} }
// функция 4 // function 4
void kos_WriteTextToWindow( void kos_WriteTextToWindow(
Word x, Word x,
Word y, Word y,
@ -546,7 +546,7 @@ void kos_WriteTextToWindow(
} }
// функция 5 пауза, в сотых долях секунды // function 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
void kos_Pause( Dword value ) void kos_Pause( Dword value )
{ {
// //
@ -558,7 +558,7 @@ void kos_Pause( Dword value )
} }
// функция 7 нарисовать изображение // function 7 íàðèñîâàòü èçîáðàæåíèå
void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ) void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y )
{ {
Dword arg1, arg2; Dword arg1, arg2;
@ -578,8 +578,15 @@ void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y )
// функция 8 определить кнопку // function 8 îïðåäåëèòü êíîïêó
void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ) void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour )
{
kos_UnsaveDefineButton(NULL, NULL, NULL, NULL, buttonID+BT_DEL, NULL);
kos_UnsaveDefineButton(x, y, sizeX, sizeY, buttonID, colour);
}
//
void kos_UnsaveDefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour )
{ {
Dword arg1, arg2; Dword arg1, arg2;
@ -598,7 +605,7 @@ void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, D
} }
// функция 9 - информация о процессе // function 9 - èíôîðìàöèÿ î ïðîöåññå
Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID ) Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID )
{ {
// Dword result; // Dword result;
@ -616,7 +623,7 @@ Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID )
} }
// функция 10 // function 10
Dword kos_WaitForEvent() Dword kos_WaitForEvent()
{ {
// Dword result; // Dword result;
@ -631,7 +638,7 @@ Dword kos_WaitForEvent()
} }
// функция 11 // function 11
Dword kos_CheckForEvent() Dword kos_CheckForEvent()
{ {
// Dword result; // Dword result;
@ -646,7 +653,7 @@ Dword kos_CheckForEvent()
} }
// функция 12 // function 12
void kos_WindowRedrawStatus( Dword status ) void kos_WindowRedrawStatus( Dword status )
{ {
__asm{ __asm{
@ -657,7 +664,7 @@ void kos_WindowRedrawStatus( Dword status )
} }
// функция 13 нарисовать полосу // function 13 íàðèñîâàòü ïîëîñó
void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ) void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour )
{ {
Dword arg1, arg2; Dword arg1, arg2;
@ -676,7 +683,7 @@ void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour )
} }
// функция 17 // function 17
bool kos_GetButtonID( Dword &buttonID ) bool kos_GetButtonID( Dword &buttonID )
{ {
Dword result; Dword result;
@ -694,7 +701,7 @@ bool kos_GetButtonID( Dword &buttonID )
} }
// функция 23 // function 23
Dword kos_WaitForEventTimeout( Dword timeOut ) Dword kos_WaitForEventTimeout( Dword timeOut )
{ {
// Dword result; // Dword result;
@ -710,7 +717,7 @@ Dword kos_WaitForEventTimeout( Dword timeOut )
} }
// получение информации о состоянии "мыши" функция 37 // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" function 37
void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY ) void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY )
{ {
Dword mB; Dword mB;
@ -739,8 +746,26 @@ void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY )
cursorY = curY - sPI.processInfo.y_start; cursorY = curY - sPI.processInfo.y_start;
} }
// function 38
void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword invert )
{
Dword arg1, arg2, arg3;
// функция 40 установить маску событий //
arg1 = ( x1 << 16 ) | x2;
arg2 = ( y1 << 16 ) | y2;
arg3 = (invert)?0x01000000:colour;
//
__asm{
mov eax, 38
mov ebx, arg1
mov ecx, arg2
mov edx, arg3
int 0x40
}
}
// function 40 óñòàíîâèòü ìàñêó ñîáûòèé
void kos_SetMaskForEvents( Dword mask ) void kos_SetMaskForEvents( Dword mask )
{ {
// //
@ -752,7 +777,7 @@ void kos_SetMaskForEvents( Dword mask )
} }
// функция 47 вывести в окно приложения число // function 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
void kos_DisplayNumberToWindow( void kos_DisplayNumberToWindow(
Dword value, Dword value,
Dword digitsNum, Dword digitsNum,
@ -782,7 +807,7 @@ void kos_DisplayNumberToWindow(
} }
// функция 70 доступ к файловой системе // function 70 äîñòóï ê ôàéëîâîé ñèñòåìå
Dword kos_FileSystemAccess( kosFileInfo *fileInfo ) Dword kos_FileSystemAccess( kosFileInfo *fileInfo )
{ {
// Dword result; // Dword result;
@ -799,7 +824,7 @@ Dword kos_FileSystemAccess( kosFileInfo *fileInfo )
} }
// функция 63 вывод символя в окно отладки // function 63 âûâîä ñèìâîëÿ â îêíî îòëàäêè
void kos_DebugOutChar( char ccc ) void kos_DebugOutChar( char ccc )
{ {
// //
@ -812,7 +837,7 @@ void kos_DebugOutChar( char ccc )
} }
// функция 66 режим получения данных от клавиатуры // function 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
void kos_SetKeyboardDataMode( Dword mode ) void kos_SetKeyboardDataMode( Dword mode )
{ {
// //
@ -838,8 +863,15 @@ void rtlDebugOutString( char *str )
kos_DebugOutChar( 10 ); kos_DebugOutChar( 10 );
} }
void kos_DebugValue(char *str, int n)
{
char debuf[50];
sprintf(debuf, "%S: %U", str, n);
rtlDebugOutString(debuf);
}
// функция 64 изменение количества памяти, выделенной для программы
// function 64 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
bool kos_ApplicationMemoryResize( Dword targetSize ) bool kos_ApplicationMemoryResize( Dword targetSize )
{ {
Dword result; Dword result;
@ -857,7 +889,7 @@ bool kos_ApplicationMemoryResize( Dword targetSize )
} }
// функция 67 изменить параметры окна, параметр == -1 не меняется // function 67 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY ) void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY )
{ {
// //

View File

@ -159,9 +159,9 @@ void memset( Byte *dst, Byte filler, Dword count );
void sprintf( char *Str, char* Format, ... ); void sprintf( char *Str, char* Format, ... );
// //
Dword rtlInterlockedExchange( Dword *target, Dword value ); Dword rtlInterlockedExchange( Dword *target, Dword value );
// функция -1 завершения процесса // function -1 çàâåðøåíèÿ ïðîöåññà
void kos_ExitApp(); void kos_ExitApp();
// функция 0 // function 0
void kos_DefineAndDrawWindow( void kos_DefineAndDrawWindow(
Word x, Word y, Word x, Word y,
Word sizeX, Word sizeY, Word sizeX, Word sizeY,
@ -169,13 +169,13 @@ void kos_DefineAndDrawWindow(
Byte headerType, Dword headerColour, Byte headerType, Dword headerColour,
Dword borderColour Dword borderColour
); );
// функция 1 поставить точку // function 1 ïîñòàâèòü òî÷êó
void kos_PutPixel( Dword x, Dword y, Dword colour ); void kos_PutPixel( Dword x, Dword y, Dword colour );
// функция 2 получить код нажатой клавиши // function 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
bool kos_GetKey( Byte &keyCode ); bool kos_GetKey( Byte &keyCode );
// функция 3 получить время // function 3 ïîëó÷èòü âðåìÿ
Dword kos_GetSystemClock(); Dword kos_GetSystemClock();
// функция 4 // function 4
void __declspec(noinline) kos_WriteTextToWindow( void __declspec(noinline) kos_WriteTextToWindow(
Word x, Word y, Word x, Word y,
Byte fontType, Byte fontType,
@ -183,25 +183,27 @@ void __declspec(noinline) kos_WriteTextToWindow(
char *textPtr, char *textPtr,
Dword textLen Dword textLen
); );
// функция 7 нарисовать изображение // function 7 íàðèñîâàòü èçîáðàæåíèå
void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ); void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y );
// функция 8 определить кнопку // function 8 îïðåäåëèòü êíîïêó
void __declspec(noinline) kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ); void __declspec(noinline) kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour );
// функция 5 пауза, в сотых долях секунды //
void __declspec(noinline) kos_UnsaveDefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour );
// function 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
void kos_Pause( Dword value ); void kos_Pause( Dword value );
// функция 9 - информация о процессе // function 9 - èíôîðìàöèÿ î ïðîöåññå
Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF ); Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF );
// функция 10 // function 10
Dword kos_WaitForEvent(); Dword kos_WaitForEvent();
// функция 11 // function 11
Dword kos_CheckForEvent(); Dword kos_CheckForEvent();
// функция 12 // function 12
void kos_WindowRedrawStatus( Dword status ); void kos_WindowRedrawStatus( Dword status );
// функция 13 нарисовать полосу // function 13 íàðèñîâàòü ïîëîñó
void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); void __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour );
// функция 17 // function 17
bool kos_GetButtonID( Dword &buttonID ); bool kos_GetButtonID( Dword &buttonID );
// функция 23 // function 23
Dword kos_WaitForEventTimeout( Dword timeOut ); Dword kos_WaitForEventTimeout( Dword timeOut );
// //
enum eNumberBase enum eNumberBase
@ -210,11 +212,13 @@ enum eNumberBase
nbHex, nbHex,
nbBin nbBin
}; };
// получение информации о состоянии "мыши" функция 37 // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" function 37
void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY ); void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY );
// функция 40 установить маску событий // function 38
void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword invert );
// function 40 óñòàíîâèòü ìàñêó ñîáûòèé
void kos_SetMaskForEvents( Dword mask ); void kos_SetMaskForEvents( Dword mask );
// функция 47 вывести в окно приложения число // function 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
void kos_DisplayNumberToWindow( void kos_DisplayNumberToWindow(
Dword value, Dword value,
Dword digitsNum, Dword digitsNum,
@ -224,17 +228,19 @@ void kos_DisplayNumberToWindow(
eNumberBase nBase = nbDecimal, eNumberBase nBase = nbDecimal,
bool valueIsPointer = false bool valueIsPointer = false
); );
// функция 58 доступ к файловой системе // function 58 äîñòóï ê ôàéëîâîé ñèñòåìå
Dword kos_FileSystemAccess( kosFileInfo *fileInfo ); Dword kos_FileSystemAccess( kosFileInfo *fileInfo );
// функция 63 // function 63
void kos_DebugOutChar( char ccc ); void kos_DebugOutChar( char ccc );
// //
void rtlDebugOutString( char *str ); void rtlDebugOutString( char *str );
// функция 64 изменить параметры окна, параметр == -1 не меняется //
void kos_DebugValue(char *str, int n);
// function 64 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY ); void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY );
// функция 67 изменение количества памяти, выделенной для программы // function 67 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
bool kos_ApplicationMemoryResize( Dword targetSize ); bool kos_ApplicationMemoryResize( Dword targetSize );
// функция 66 режим получения данных от клавиатуры // function 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
void kos_SetKeyboardDataMode( Dword mode ); void kos_SetKeyboardDataMode( Dword mode );
void kos_InitHeap(); void kos_InitHeap();