612 lines
19 KiB
C
612 lines
19 KiB
C
#include <sys/ksys.h>
|
||
#include <clayer/boxlib.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <system/proc_lib.h>
|
||
#include "system/gui.h"
|
||
|
||
#include "window.h"
|
||
#include "config.h"
|
||
#include "table_lib.h"
|
||
#include "grid.h"
|
||
|
||
extern open_dialog* dlg_open;
|
||
extern char* path_table_doc;
|
||
|
||
static char* sys_open_app = "/sys/@open";
|
||
static char* sys_notify_app = "/sys/@notify";
|
||
|
||
static ksys_thread_t procinfo;
|
||
static uint32_t old_header_h ;
|
||
|
||
uint32_t selected_screen ;
|
||
|
||
// new window size and coordinates
|
||
static int cWidth;
|
||
static int cHeight;
|
||
|
||
edit_box editbox_cell = {
|
||
.width = 0,
|
||
.left = 0,
|
||
.top = 0,
|
||
.color = 0xFFFFFF,
|
||
.shift_color = 0x6a9480,
|
||
.focus_border_color = 0,
|
||
.blur_border_color = 0x6a9480,
|
||
.text_color = 0x10000000, //BLACK | TEXT_SIZE,
|
||
.max = 0, //ED_BUFF_LEN,
|
||
.text = NULL, //ed_buff,
|
||
.mouse_variable = NULL,
|
||
.flags = ed_focus
|
||
};
|
||
|
||
ksys_colors_table_t color_table; //for all graphic functions
|
||
|
||
|
||
extern void __stdcall num2cell_num(uint32_t num, char* buff);
|
||
|
||
// Обработка данных ячеек таблицы для грида
|
||
void __stdcall table_grid_cell_format(struct GRID* this, GRID_CELL_FORMAT* buff, uint32_t col, uint32_t row){
|
||
// call table_lib get_value
|
||
if (false) { // Если формат ячейки найден в таблице
|
||
// copy data
|
||
//memmove(buff, ,sizeof(GRID_CELL_FORMAT));
|
||
}else {
|
||
if (false) { // Если для строки найден формат
|
||
|
||
}else {
|
||
buff -> height = TABLE_CELL_DEFAULT_HEIGHT;
|
||
};
|
||
|
||
if (false) { // Если для столбца найден формат
|
||
|
||
}else {
|
||
buff -> width = TABLE_CELL_DEFAULT_WIDTH;
|
||
}
|
||
|
||
if (col == 0 || row == 0) {
|
||
buff -> bg_color = color_table.grab_bar_button;
|
||
buff -> text_color = color_table.work_text;
|
||
}else {
|
||
buff -> bg_color = 0xFFFFFF;
|
||
buff -> text_color = color_table.work_text;
|
||
}
|
||
buff -> text_params = GRID_TEXT_ALIGN_LEFT;
|
||
buff -> border_bitmask = 0;
|
||
|
||
// test
|
||
if (col == 2 && row == 2) {
|
||
buff -> bg_color = 0xFFFF;
|
||
buff -> text_color = 0;
|
||
buff -> height = 48;
|
||
buff -> width = 120;
|
||
}
|
||
|
||
};
|
||
if ((row == 0 && this -> selected_cell_col <= col &&
|
||
this -> selected_cell_w + this -> selected_cell_col > col) ||
|
||
(col == 0 && this -> selected_cell_row <= row &&
|
||
row < this -> selected_cell_h + this -> selected_cell_row)){
|
||
buff -> bg_color -= 0x00252525;
|
||
}
|
||
|
||
if (col == this -> selected_cell_col && row == this -> selected_cell_row){
|
||
buff -> border_bitmask = 0x03030F03;
|
||
buff -> border_l.color = 0;
|
||
buff -> border_l.line[0].format = GRID_BORDER_TYPE_PATTERN;
|
||
buff -> border_l.line[0].pattern = 0xFF;
|
||
buff -> border_l.line[1].format = GRID_BORDER_TYPE_PATTERN;
|
||
buff -> border_l.line[1].pattern = 0xFF;
|
||
|
||
buff -> border_r.color = 0;
|
||
buff -> border_r.line[0].format = GRID_BORDER_TYPE_PATTERN_END_1;
|
||
buff -> border_r.line[0].pattern = 0b11110111;
|
||
buff -> border_r.line[1].format = GRID_BORDER_TYPE_PATTERN_END_1;
|
||
buff -> border_r.line[1].pattern = 0b11110111;
|
||
buff -> border_r.line[2].format = GRID_BORDER_TYPE_PATTERN_END_0;
|
||
buff -> border_r.line[2].pattern = 0b11110000;
|
||
buff -> border_r.line[3].format = GRID_BORDER_TYPE_PATTERN_END_0;
|
||
buff -> border_r.line[3].pattern = 0b11110000;;
|
||
|
||
buff -> border_t.color = 0;
|
||
buff -> border_t.line[0].format = GRID_BORDER_TYPE_PATTERN;
|
||
buff -> border_t.line[0].pattern = 0xFF;
|
||
buff -> border_t.line[1].format = GRID_BORDER_TYPE_PATTERN;
|
||
buff -> border_t.line[1].pattern = 0xFF;
|
||
|
||
buff -> border_b.color = 0;
|
||
buff -> border_b.line[0].format = GRID_BORDER_TYPE_PATTERN_END_1;
|
||
buff -> border_b.line[0].pattern = 0b11110111;
|
||
buff -> border_b.line[1].format = GRID_BORDER_TYPE_PATTERN_END_1;
|
||
buff -> border_b.line[1].pattern = 0b11110111;
|
||
|
||
}
|
||
|
||
// destruct table_object
|
||
return ;
|
||
}
|
||
|
||
table_object* __stdcall table_grid_cell_value(struct GRID* this, uint32_t col, uint32_t row){
|
||
|
||
table_object* buff = 0;
|
||
|
||
char grid_line_text [12];
|
||
memset(grid_line_text, '\0', 12);
|
||
|
||
// call table_lib get_value
|
||
|
||
if (buff == 0){
|
||
|
||
buff = create_table_object(4+2+12);
|
||
buff -> type = TABLE_OBJECT_TYPE_STR;
|
||
buff -> size = 4+2+12;
|
||
((table_object_str*)buff) -> str_len = 12;
|
||
|
||
if (row == 0 && col>0){
|
||
num2cell_num(col ,grid_line_text);
|
||
memcpy( &(((table_object_str*)buff) -> str), grid_line_text, 12);
|
||
}
|
||
if (col == 0 && row > 0){
|
||
memset(grid_line_text, '\0', 12);
|
||
itoa(row ,grid_line_text);
|
||
memcpy(&(((table_object_str*)buff) -> str), grid_line_text, 12);
|
||
}
|
||
if (col == 1 && row == 1)
|
||
memcpy(&(((table_object_str*)buff) -> str), " test 2 ", 12);
|
||
if (col == 3 && row == 11)
|
||
memcpy(&(((table_object_str*)buff) -> str), "123", 12);
|
||
return buff;
|
||
}
|
||
|
||
// check formula
|
||
return buff;
|
||
|
||
};
|
||
|
||
void __stdcall table_free_cell_value(struct GRID* this, table_object* buff){
|
||
destruct_table_object(buff);
|
||
return;
|
||
}
|
||
|
||
void __stdcall table_grid_cell_mouse(struct GRID* this, uint32_t col, uint32_t row){
|
||
|
||
return;
|
||
}
|
||
|
||
void __stdcall table_grid_cell_key(struct GRID* this, uint32_t col, uint32_t row, ksys_oskey_t ch){
|
||
if (ch.ctrl_key == KSYS_SCANCODE_ENTER) {
|
||
this -> flags = this -> flags ^ GRID_FLAG_EDIT_DATA;
|
||
|
||
editbox_cell.left = this -> current_cell_x;
|
||
editbox_cell.top = this -> current_cell_y;
|
||
editbox_cell.width = this -> current_cell_w;
|
||
};
|
||
|
||
return;
|
||
}
|
||
|
||
|
||
// callbacks for draw grid data
|
||
|
||
void __stdcall table_grid_draw_text(struct GRID* this, uint32_t x, uint32_t y, uint32_t w, uint32_t h, char* text, uint64_t text_params){
|
||
write_text_utf8_center(x, y, w, text, 0);
|
||
return;
|
||
}
|
||
|
||
|
||
void __stdcall table_grid_draw_image(struct GRID* this, uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t* data){
|
||
ksys_draw_bitmap_palette(data, x, y, w, h, 32, NULL, 0);
|
||
return;
|
||
}
|
||
|
||
void __stdcall table_grid_draw_bar(struct GRID* this, uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t color){
|
||
_ksys_draw_bar(x, y, w, h, color);
|
||
return;
|
||
}
|
||
|
||
static GRID table_grid = {
|
||
.flags = 0,
|
||
.content_pos_col = 1,
|
||
.content_pos_row = 1,
|
||
|
||
.selected_cell_col = 1,
|
||
.selected_cell_row = 1,
|
||
.selected_cell_w = 1,
|
||
.selected_cell_h = 1,
|
||
|
||
.current_cell_x = 0,
|
||
.current_cell_y = 0,
|
||
.current_cell_w = 0,
|
||
.current_cell_h = 0,
|
||
|
||
.get_cell_format = &table_grid_cell_format,
|
||
.get_cell_value = &table_grid_cell_value,
|
||
.event_cell_mouse = &table_grid_cell_mouse,
|
||
.free_cell_value = &table_free_cell_value,
|
||
.event_cell_key = &table_grid_cell_key,
|
||
|
||
.draw_text = table_grid_draw_text,
|
||
.draw_bar = &table_grid_draw_bar,
|
||
.draw_image = &table_grid_draw_image
|
||
};
|
||
|
||
|
||
// ОТРИСОВКА ОКНА
|
||
|
||
void draw_main_window(){
|
||
draw_grid(&table_grid);
|
||
|
||
if (table_grid.flags & GRID_FLAG_EDIT_DATA)
|
||
// draw editbox
|
||
edit_box_draw(&editbox_cell);
|
||
return;
|
||
}
|
||
|
||
|
||
void draw_menu_bar(){
|
||
_ksys_draw_line((procinfo.clientwidth-1)/4, MENU_PANEL_HEIGHT,
|
||
(procinfo.clientwidth-1)/4 , procinfo.clientheight-1, color_table.work_graph);
|
||
// draw background and borders
|
||
_ksys_draw_bar(1, MENU_PANEL_HEIGHT + 1,
|
||
(procinfo.clientwidth-1)/4 -1, procinfo.clientheight - MENU_PANEL_HEIGHT-2,
|
||
color_table.work_area);
|
||
switch (selected_screen) {
|
||
case SCREEN_INFO:
|
||
_ksys_draw_bar(1, MENU_PANEL_HEIGHT + 20*3 ,
|
||
(procinfo.clientwidth-1)/4 -1, 24, color_table.grab_bar_button);
|
||
break;
|
||
case SCREEN_GRAPH:
|
||
_ksys_draw_bar(1, MENU_PANEL_HEIGHT + 20*3 + 24,
|
||
(procinfo.clientwidth-1)/4 -1, 24, color_table.grab_bar_button);
|
||
break;
|
||
case SCREEN_PRINT:
|
||
_ksys_draw_bar(1, MENU_PANEL_HEIGHT + 20*3 + 24*2,
|
||
(procinfo.clientwidth-1)/4 -1, 24, color_table.grab_bar_button);
|
||
break;
|
||
case SCREEN_SETTING:
|
||
_ksys_draw_bar(1, MENU_PANEL_HEIGHT + 20*3 + 24*3,
|
||
(procinfo.clientwidth-1)/4 -1, 24, color_table.grab_bar_button);
|
||
break;
|
||
};
|
||
_ksys_draw_line( 0, MENU_PANEL_HEIGHT + 20*3,
|
||
(procinfo.clientwidth-1)/4 , MENU_PANEL_HEIGHT + 20*3,
|
||
color_table.work_graph);
|
||
_ksys_draw_line( 0, MENU_PANEL_HEIGHT + 20*3 + 24,
|
||
(procinfo.clientwidth-1)/4 , MENU_PANEL_HEIGHT + 20*3 + 24,
|
||
color_table.work_graph);
|
||
_ksys_draw_line( 0, MENU_PANEL_HEIGHT + 20*3 + 24*2,
|
||
(procinfo.clientwidth-1)/4 , MENU_PANEL_HEIGHT + 20*3 + 24*2,
|
||
color_table.work_graph);
|
||
_ksys_draw_line( 0, MENU_PANEL_HEIGHT + 20*3 + 24*3,
|
||
(procinfo.clientwidth-1)/4 , MENU_PANEL_HEIGHT + 20*3 + 24*3,
|
||
color_table.work_graph);
|
||
_ksys_draw_line( 0, MENU_PANEL_HEIGHT + 20*3 + 24*4,
|
||
(procinfo.clientwidth-1)/4 , MENU_PANEL_HEIGHT + 20*3 + 24*4,
|
||
color_table.work_graph);
|
||
// draw text
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + 2,
|
||
(procinfo.clientwidth-1)/4, "Save", 0);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + 20 + 2,
|
||
(procinfo.clientwidth-1)/4, "Save as", 0);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + 20*2 + 2,
|
||
(procinfo.clientwidth-1)/4, "Open", 0);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + 20*3 + 4,
|
||
(procinfo.clientwidth-1)/4, "Property", 0);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + 20*3 + 24 + 4,
|
||
(procinfo.clientwidth-1)/4, "Graph", 0);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + 20*3 + 24*2 + 4,
|
||
(procinfo.clientwidth-1)/4, "Print", 0);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + 20*3 + 24*3 + 4,
|
||
(procinfo.clientwidth-1)/4, "Settings", 0);
|
||
// define buttons
|
||
_ksys_define_button(0, MENU_PANEL_HEIGHT + 20*3,
|
||
(procinfo.clientwidth-1)/4, 24, BTN_OTHER_INFO + 0x40000000, 0);
|
||
_ksys_define_button(0, MENU_PANEL_HEIGHT + 20*3 + 24,
|
||
(procinfo.clientwidth-1)/4, 24, BTN_OTHER_GRAPH + 0x40000000, 0);
|
||
_ksys_define_button(0, MENU_PANEL_HEIGHT + 20*3 + 24*2,
|
||
(procinfo.clientwidth-1)/4, 24, BTN_OTHER_PRINT + 0x40000000, 0);
|
||
_ksys_define_button(0, MENU_PANEL_HEIGHT + 20*3 + 24*3,
|
||
(procinfo.clientwidth-1)/4, 24, BTN_OTHER_SETTING + 0x40000000, 0);
|
||
//_ksys_draw_bar(1, MENU_PANEL_HEIGHT+1 ,procinfo.clientwidth-2,
|
||
// procinfo.clientheight - MENU_PANEL_HEIGHT-2, 0x0000FF);
|
||
// set full background
|
||
// draw background from list
|
||
return;
|
||
}
|
||
|
||
void draw_about(){
|
||
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)/16,
|
||
procinfo.clientwidth, "Table for KolibriOS", 1);
|
||
// draw text info: version, simple description, authors
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)/5,
|
||
procinfo.clientwidth, "Version: 0.1.1", 0);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)/5 + 20,
|
||
procinfo.clientwidth, "Author: Mikhail Frolov aka Doczom", 0);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)/2 - 16,
|
||
procinfo.clientwidth, "Документация", 1);
|
||
|
||
_ksys_define_button(procinfo.clientwidth/(2*14),
|
||
MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)*3/5 - 3,
|
||
procinfo.clientwidth/2 - procinfo.clientwidth/(2*14)*2,
|
||
32 + 6, BTN_ABOUT_FORMULS , color_table.grab_button_text);
|
||
_ksys_define_button(procinfo.clientwidth/2 + procinfo.clientwidth/(2*14),
|
||
MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)*3/5 - 3,
|
||
procinfo.clientwidth/2 - procinfo.clientwidth/(2*14)*2,
|
||
32 + 6, BTN_ABOUT_GRAPH , color_table.grab_button_text);
|
||
_ksys_define_button(procinfo.clientwidth/(2*14),
|
||
MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)*4/5 - 3,
|
||
procinfo.clientwidth/2 - procinfo.clientwidth/(2*14)*2,
|
||
32 + 6, BTN_ABOUT_HOTKEYS , color_table.grab_button_text);
|
||
_ksys_define_button(procinfo.clientwidth/2 + procinfo.clientwidth/(2*14),
|
||
MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)*4/5 - 3,
|
||
procinfo.clientwidth/2 - procinfo.clientwidth/(2*14)*2,
|
||
32 + 6, BTN_ABOUT_DEVS , color_table.grab_button_text);
|
||
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)*3/5,
|
||
procinfo.clientwidth/2, "Формулы", 1);
|
||
write_text_utf8_center(procinfo.clientwidth/2, MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)*3/5,
|
||
procinfo.clientwidth/2, "Графики", 1);
|
||
write_text_utf8_center(0, MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)*4/5,
|
||
procinfo.clientwidth/2, "Управление", 1);
|
||
write_text_utf8_center(procinfo.clientwidth/2, MENU_PANEL_HEIGHT + (procinfo.clientheight - MENU_PANEL_HEIGHT)*4/5,
|
||
procinfo.clientwidth/2, "API модулей", 1);
|
||
// define 4 buttons for links of docs
|
||
return;
|
||
}
|
||
|
||
|
||
void draw_content(){
|
||
// draw subwindow
|
||
if ((selected_screen & (SCREEN_INFO | SCREEN_ABOUT)) == SCREEN_BASE) draw_main_window();
|
||
else if (selected_screen & SCREEN_ABOUT) draw_about();
|
||
else {
|
||
// draw menu bar
|
||
draw_menu_bar();
|
||
switch (selected_screen) {
|
||
case SCREEN_INFO:
|
||
|
||
break;
|
||
case SCREEN_GRAPH:
|
||
|
||
break;
|
||
case SCREEN_PRINT:
|
||
|
||
break;
|
||
case SCREEN_SETTING:
|
||
|
||
break;
|
||
};
|
||
};
|
||
}
|
||
|
||
void draw_toolbar(){
|
||
_ksys_draw_bar(0,0,procinfo.clientwidth, procinfo.clientheight , color_table.work_area);
|
||
|
||
gui_draw_button_icon18(BTN_OTHER, 5, (40-26)/2, -1, 0);
|
||
gui_draw_button_icon18(BTN_SAVE, 5+(27+11)*1,(40-26)/2, 5, 0);
|
||
gui_draw_button_icon18(BTN_SAVE_AS, 5+(27+11)*2,(40-26)/2, 20, 0);
|
||
gui_draw_button_icon18(BTN_LOAD, 5+(27+11)*3,(40-26)/2, 0, 0);
|
||
gui_draw_button_icon18(BTN_NEW, 5+(27+11)*4,(40-26)/2, 2, 0);
|
||
gui_draw_button_icon18(BTN_ABOUT, procinfo.clientwidth - (27+5),(40-26)/2, 66, 0);
|
||
|
||
// draw border for toolbar and subwindow
|
||
_ksys_draw_line(0, MENU_PANEL_HEIGHT, 0, procinfo.clientheight-1 , color_table.work_graph);
|
||
_ksys_draw_line(procinfo.clientwidth-1, MENU_PANEL_HEIGHT, procinfo.clientwidth-1,
|
||
procinfo.clientheight-1 , color_table.work_graph);
|
||
_ksys_draw_line(0, procinfo.clientheight-1, procinfo.clientwidth-1,
|
||
procinfo.clientheight-1 , color_table.work_graph);
|
||
switch (selected_screen & SCREEN_ALL_TABS){
|
||
case SCREEN_INFO:
|
||
_ksys_draw_line(0, MENU_PANEL_HEIGHT, 0, 3 , color_table.work_graph);
|
||
_ksys_draw_line(0, 3, 5+27+3, 3 , color_table.work_graph);
|
||
_ksys_draw_line(5+27+3, 3, 5+27+10, MENU_PANEL_HEIGHT, color_table.work_graph);
|
||
_ksys_draw_line(5+27+10, MENU_PANEL_HEIGHT, procinfo.clientwidth-1,
|
||
MENU_PANEL_HEIGHT , color_table.work_graph);
|
||
break;
|
||
case SCREEN_ABOUT:
|
||
_ksys_draw_line(procinfo.clientwidth-1, MENU_PANEL_HEIGHT,
|
||
procinfo.clientwidth-1, 3 , color_table.work_graph);
|
||
_ksys_draw_line(procinfo.clientwidth-1, 3,
|
||
procinfo.clientwidth-1 - (5+27+3), 3 , color_table.work_graph);
|
||
_ksys_draw_line(procinfo.clientwidth-1 - (5+27+3), 3,
|
||
procinfo.clientwidth-1 - (5+27+10), MENU_PANEL_HEIGHT, color_table.work_graph);
|
||
_ksys_draw_line(0, MENU_PANEL_HEIGHT, procinfo.clientwidth-1 - (5+27+10),
|
||
MENU_PANEL_HEIGHT , color_table.work_graph);
|
||
break;
|
||
default: {
|
||
_ksys_draw_line(0, MENU_PANEL_HEIGHT, procinfo.clientwidth-1,
|
||
MENU_PANEL_HEIGHT , color_table.work_graph);
|
||
};
|
||
};
|
||
draw_content();
|
||
return ;
|
||
}
|
||
|
||
void draw_window(){
|
||
// create window
|
||
_ksys_start_draw();
|
||
_ksys_create_window(100, 40, WND_W, WND_H + _ksys_get_skin_height(), "Table ", 0x00FFFFFF, 0x73);
|
||
_ksys_end_draw();
|
||
|
||
_ksys_get_system_colors(&color_table);
|
||
// get procinfo
|
||
_ksys_thread_info(&procinfo, KSYS_THIS_SLOT);
|
||
|
||
cWidth = procinfo.winx_size - 9;
|
||
cHeight = procinfo.winy_size - _ksys_get_skin_height() - 4;
|
||
|
||
// check rolled-up
|
||
if (procinfo.window_state & 0b100) return;
|
||
|
||
// check client x_size and y_size
|
||
if (cWidth < MIN_WIDTH) {
|
||
_ksys_change_window(-1,-1,MIN_WIDTH + 9,-1);
|
||
return;
|
||
};
|
||
if (cHeight < MIN_HEIGHT) {
|
||
_ksys_change_window(-1,-1,-1,MIN_HEIGHT + _ksys_get_skin_height() + 4);
|
||
return;
|
||
};
|
||
|
||
// update values in all structs: grid, scrollbar, editbox
|
||
table_grid.x = 0;
|
||
table_grid.y = MENU_PANEL_HEIGHT;
|
||
table_grid.w = procinfo.clientwidth -1;
|
||
table_grid.h = procinfo.clientheight - MENU_PANEL_HEIGHT -1;
|
||
table_grid.grid_color = color_table.work_graph;
|
||
|
||
// draw button bar
|
||
draw_toolbar();
|
||
return;
|
||
}
|
||
|
||
bool window_event_key(ksys_oskey_t key){
|
||
if (key.state != 1) {
|
||
// key buffer not clean
|
||
if ((selected_screen & SCREEN_ALL_TABS) == 0){
|
||
// event key for grid and editbox
|
||
if ((key.ctrl_key == KSYS_SCANCODE_ESC) && (table_grid.flags & GRID_FLAG_EDIT_DATA != 0)) {
|
||
table_grid.flags = table_grid.flags ^ GRID_FLAG_EDIT_DATA;
|
||
return 0;
|
||
};
|
||
grid_key(&table_grid, key);
|
||
} else {
|
||
switch (selected_screen) {
|
||
case SCREEN_GRAPH:
|
||
break;
|
||
case SCREEN_PRINT:
|
||
break;
|
||
}
|
||
if (key.ctrl_key == KSYS_SCANCODE_ESC) {
|
||
selected_screen = selected_screen & ~SCREEN_ALL_TABS;
|
||
draw_toolbar();
|
||
return 0;
|
||
};
|
||
}
|
||
if (key.ctrl_key == KSYS_SCANCODE_ESC) return true;
|
||
};
|
||
return 0;
|
||
}
|
||
|
||
bool window_event_mouse(){
|
||
if ((selected_screen & SCREEN_ALL_TABS) == 0){
|
||
// event for grid
|
||
grid_mouse(&table_grid);
|
||
} else {
|
||
switch (selected_screen) {
|
||
case SCREEN_GRAPH:
|
||
break;
|
||
case SCREEN_PRINT:
|
||
break;
|
||
};
|
||
};
|
||
return 0;
|
||
}
|
||
|
||
bool window_event_button(uint32_t pressed_button){
|
||
switch (pressed_button){ // Проверка какая кнопка была нажата
|
||
case BTN_LOAD:
|
||
dlg_open -> mode = PROC_LIB_OPEN;
|
||
OpenDialog_start(dlg_open);
|
||
if (dlg_open->status == PROC_LIB_SUCCESS) {
|
||
// probe file
|
||
//dlg_open->openfile_path
|
||
}
|
||
break;
|
||
case BTN_NEW:
|
||
//reinit();
|
||
//draw_grid();
|
||
break;
|
||
case BTN_SAVE:
|
||
// save
|
||
break;
|
||
case BTN_SAVE_AS:
|
||
dlg_open -> mode = PROC_LIB_SAVE;
|
||
OpenDialog_start(dlg_open);
|
||
if (dlg_open->status == PROC_LIB_SUCCESS) {
|
||
// probe file
|
||
// update file name
|
||
memmove(path_table_doc, dlg_open->openfile_path, 4096);
|
||
//save
|
||
}
|
||
break;
|
||
case BTN_OTHER:
|
||
selected_screen = (selected_screen & ~SCREEN_ABOUT) ^ SCREEN_INFO;
|
||
draw_toolbar();
|
||
break;
|
||
case BTN_ABOUT:
|
||
selected_screen = (selected_screen & ~SCREEN_INFO) ^ SCREEN_ABOUT;
|
||
draw_toolbar();
|
||
break;
|
||
case BTN_QUIT:
|
||
return true;
|
||
|
||
default:
|
||
// check all subwindows
|
||
if (selected_screen & SCREEN_INFO) {
|
||
|
||
// for menu list
|
||
switch (pressed_button) {
|
||
case BTN_OTHER_INFO:
|
||
selected_screen = SCREEN_INFO;
|
||
draw_menu_bar();
|
||
break;
|
||
case BTN_OTHER_GRAPH:
|
||
if (selected_screen != SCREEN_GRAPH){
|
||
// set subwindow
|
||
selected_screen = SCREEN_GRAPH;
|
||
draw_menu_bar();
|
||
};
|
||
break;
|
||
case BTN_OTHER_PRINT:
|
||
selected_screen = SCREEN_PRINT;
|
||
draw_menu_bar();
|
||
break;
|
||
case BTN_OTHER_SETTING:
|
||
selected_screen = SCREEN_SETTING;
|
||
draw_menu_bar();
|
||
break;
|
||
default:
|
||
switch (selected_screen) {
|
||
case SCREEN_INFO:
|
||
break;
|
||
case SCREEN_GRAPH:
|
||
switch (pressed_button) {
|
||
case BTN_OTHER_GRAPH_CREATE:
|
||
break;
|
||
case BTN_OTHER_GRAPH_ADD:
|
||
break;
|
||
case BTN_OTHER_GRAPH_DEL:
|
||
break;
|
||
};
|
||
break;
|
||
case SCREEN_PRINT:
|
||
break;
|
||
case SCREEN_SETTING:
|
||
break;
|
||
};
|
||
};
|
||
}else if (selected_screen & SCREEN_ABOUT) {
|
||
// check button for open docs
|
||
switch (pressed_button){
|
||
case BTN_ABOUT_FORMULS:
|
||
run_file(config_data.doc_formulas);
|
||
break;
|
||
case BTN_ABOUT_GRAPH:
|
||
run_file(config_data.doc_graph);
|
||
break;
|
||
case BTN_ABOUT_HOTKEYS:
|
||
run_file(config_data.doc_hotkeys);
|
||
break;
|
||
case BTN_ABOUT_DEVS:
|
||
run_file(config_data.doc_module_api);
|
||
break;
|
||
};
|
||
} else {
|
||
// check button main window(for tabs)
|
||
};
|
||
};
|
||
return 0;
|
||
}
|