From 59d92b4ec3f8682833d1cc68a236e31488f9c0a4 Mon Sep 17 00:00:00 2001 From: siemargl Date: Wed, 12 Oct 2016 23:28:04 +0000 Subject: [PATCH] editor, treelist, msgbox initial git-svn-id: svn://kolibrios.org@6589 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/C_Layer/ASM/loadboxlib.asm | 51 +- contrib/C_Layer/ASM/loadmsgbox.asm | 34 ++ .../EXAMPLE/libguic_kolibri/boardmsg.c | 2 +- .../EXAMPLE/libguic_kolibri/dbutton_files.c | 10 - .../libguic_kolibri/editor_tree_msgbox.c | 132 +++++ contrib/C_Layer/INCLUDE/kolibri_buf2d.h | 18 +- contrib/C_Layer/INCLUDE/kolibri_colordialog.h | 2 +- contrib/C_Layer/INCLUDE/kolibri_editor.h | 497 ++++++++++++++++++ contrib/C_Layer/INCLUDE/kolibri_filebrowse.h | 9 +- contrib/C_Layer/INCLUDE/kolibri_frame.h | 40 +- .../C_Layer/INCLUDE/kolibri_gui_elements.h | 9 +- contrib/C_Layer/INCLUDE/kolibri_kmenu.h | 28 +- contrib/C_Layer/INCLUDE/kolibri_msgbox.h | 60 +++ contrib/C_Layer/INCLUDE/kolibri_opendialog.h | 4 +- contrib/C_Layer/INCLUDE/kolibri_optionbox.h | 2 +- contrib/C_Layer/INCLUDE/kolibri_pathshow.h | 2 +- contrib/C_Layer/INCLUDE/kolibri_scrollbar.h | 4 +- contrib/C_Layer/INCLUDE/kolibri_treelist.h | 106 ++++ 18 files changed, 938 insertions(+), 72 deletions(-) create mode 100644 contrib/C_Layer/ASM/loadmsgbox.asm create mode 100644 contrib/C_Layer/EXAMPLE/libguic_kolibri/editor_tree_msgbox.c create mode 100644 contrib/C_Layer/INCLUDE/kolibri_editor.h create mode 100644 contrib/C_Layer/INCLUDE/kolibri_msgbox.h create mode 100644 contrib/C_Layer/INCLUDE/kolibri_treelist.h diff --git a/contrib/C_Layer/ASM/loadboxlib.asm b/contrib/C_Layer/ASM/loadboxlib.asm index 099349ced8..4be627eedc 100644 --- a/contrib/C_Layer/ASM/loadboxlib.asm +++ b/contrib/C_Layer/ASM/loadboxlib.asm @@ -6,11 +6,11 @@ section '.init' code ; Keep this line before includes or GCC messes up call ad include '../../../programs/proc32.inc' include '../../../programs/macros.inc' purge section,mov,add,sub - + include '../../../programs/develop/libraries/box_lib/trunk/box_lib.mac' include '../../../programs/system/run/trunk/txtbut.inc' include '../../../programs/dll.inc' - + public init_boxlib as '_kolibri_boxlib_init' public editbox_key_thunk as '_editbox_key@4' ; renamed due to ambiguity public press_key as '_press_key' @@ -22,8 +22,8 @@ proc init_boxlib stdcall dll.Load, @IMPORT popa ret -endp - +endp + ;; Wrapper to handle edit_box_key function for editboxes. ;; Call this baby from C (refer kolibri_editbox.h for details) editbox_key_thunk: @@ -34,7 +34,7 @@ editbox_key_thunk: push ebp ;push the return address back to stack mov ebp, [oldebp] ret - + oldebp dd ? press_key dd ? @@ -104,7 +104,7 @@ import lib_boxlib, \ ted_is_select, 'ted_is_select' , \ ted_key, 'ted_key' , \ ted_mouse, 'ted_mouse' , \ - ted_open_file, 'ted_open_file' , \ + ted_open_file, 'ted_open_file_asm' , \ ted_save_file, 'ted_save_file' , \ ted_text_add, 'ted_text_add' , \ ted_but_select_word, 'ted_but_select_word' , \ @@ -120,11 +120,11 @@ import lib_boxlib, \ progressbar_draw,'progressbar_draw' , \ progressbar_progress, 'progressbar_progress' - + public edit_box_draw as '_edit_box_draw' public edit_box_key as '_edit_box_key' public edit_box_mouse as '_edit_box_mouse' -public edit_box_set_text as '_edit_box_set_text' +public edit_box_set_text as '_edit_box_set_text' public check_box_draw2 as '_check_box_draw2' public check_box_mouse2 as '_check_box_mouse2' @@ -143,9 +143,9 @@ public scrollbar_h_mouse as '_scrollbar_h_mouse' public option_box_draw as '_option_box_draw' public option_box_mouse as '_option_box_mouse' -public menu_bar_draw as '_menu_bar_draw' -public menu_bar_mouse as '_menu_bar_mouse' -public menu_bar_activate as '_menu_bar_activate' +public menu_bar_draw as '_menu_bar_draw' +public menu_bar_mouse as '_menu_bar_mouse' +public menu_bar_activate as '_menu_bar_activate' public dynamic_button_draw as '_dynamic_button_draw' public dynamic_button_mouse as '_dynamic_button_mouse' @@ -155,4 +155,31 @@ public path_show_draw as '_path_show_draw' public fb_draw_panel as '_filebrowse_draw' public fb_mouse as '_filebrowse_mouse' -public fb_key as '_filebrowse_key' +public fb_key as '_filebrowse_key' + +public ted_but_sumb_upper as '_ted_but_sumb_upper_asm' +public ted_but_sumb_lover as '_ted_but_sumb_lover_asm' +public ted_but_convert_by_table as '_ted_but_convert_by_table_asm' +public ted_can_save as '_ted_can_save_asm' +public ted_clear as '_ted_clear_asm' +public ted_delete as '_ted_delete_asm' +public ted_draw as '_ted_draw' +public ted_init as '_ted_init_asm' +public ted_init_scroll_bars as '_ted_init_scroll_bars' +public ted_init_syntax_file as '_ted_init_syntax_file' +public ted_is_select as '_ted_is_select_asm' +public ted_key as '_ted_key_asm' +public ted_mouse as '_ted_mouse' +public ted_open_file as '_ted_open_file_asm' +public ted_save_file as '_ted_save_file_asm' +public ted_text_add as '_ted_text_add' +public ted_but_select_word as '_ted_but_select_word' +public ted_but_cut as '_ted_but_cut_asm' +public ted_but_copy as '_ted_but_copy' +public ted_but_paste as '_ted_but_paste' +public ted_but_undo as '_ted_but_undo_asm' +public ted_but_redo as '_ted_but_redo_asm' +public ted_but_reverse as '_ted_but_reverse_asm' +public ted_but_find_next as '_ted_but_find_next' +public ted_text_colored as 'ted_text_colored_asm' + diff --git a/contrib/C_Layer/ASM/loadmsgbox.asm b/contrib/C_Layer/ASM/loadmsgbox.asm new file mode 100644 index 0000000000..648decdf6d --- /dev/null +++ b/contrib/C_Layer/ASM/loadmsgbox.asm @@ -0,0 +1,34 @@ + +format coff +use32 ; Tell compiler to use 32 bit instructions + +section '.init' code ; Keep this line before includes or GCC messes up call addresses + +include '../../../programs/proc32.inc' +include '../../../programs/macros.inc' +purge section,mov,add,sub + +include '../../../programs/dll.inc' + +public init_msgbox as '_kolibri_msgbox_init' +;;; Returns 0 on success. -1 on failure. + +proc init_msgbox + pusha + mcall 68,11 + stdcall dll.Load, @IMPORT + popa + ret +endp + +@IMPORT: +library lib_boxlib, 'msgbox.obj' + +import lib_boxlib, \ + mb_create, 'mb_create' , \ + mb_reinit, 'mb_reinit' , \ + mb_setfunctions, 'mb_setfunctions' + +public mb_create as '_msgbox_create' +public mb_reinit as '_msgbox_reinit' +public mb_setfunctions as '_msgbox_setfunctions' diff --git a/contrib/C_Layer/EXAMPLE/libguic_kolibri/boardmsg.c b/contrib/C_Layer/EXAMPLE/libguic_kolibri/boardmsg.c index fe5729bf4c..688385afd9 100644 --- a/contrib/C_Layer/EXAMPLE/libguic_kolibri/boardmsg.c +++ b/contrib/C_Layer/EXAMPLE/libguic_kolibri/boardmsg.c @@ -38,7 +38,7 @@ int main() edit_box *textbox = kolibri_new_edit_box(20, 30, 40, &editbox_interlock); edit_box *textbox2 = kolibri_new_edit_box(20, 50, 30, &editbox_interlock); kolibri_button *button = kolibri_new_button(310, 30, 24, 14, 0x21, kolibri_color_table.color_work_button); - frame *fr = kolibri_new_frame(X_Y(12, 350), X_Y(5, 70), 0x00FCFCFC, 0x00DCDCDC, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area); + frame *fr = kolibri_new_frame(X_Y(12, 350), X_Y(5, 70), 0x00FCFCFC, 0x00DCDCDC, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0); kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox); kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox2); diff --git a/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c b/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c index 2fc33218dd..342b48d0f3 100644 --- a/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c +++ b/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c @@ -41,7 +41,6 @@ int main(int argc, char **argv) kolibri_proclib_init(); // opensave && color dialogs kolibri_libimg_init(); // png handling - int gui_event = KOLIBRI_EVENT_REDRAW; uint32_t pressed_button = 0; // uint32_t mouse_button; @@ -110,21 +109,12 @@ int main(int argc, char **argv) brows.folder_data = read_folderdata("/rd/1"); brows.select_panel_counter = 1; // if want to show selection -kolibri_handle_event_redraw(main_window); -brows.all_redraw = 1; -(*filebrowse_draw)(&brows); - - -//??? set_os_keyb_mode(1); // needed for keyboard use in menu - int extended_key = 0, act = 0; do /* Start of main activity loop */ { switch(gui_event) { case KOLIBRI_EVENT_REDRAW: -//???? start red -//brows.marked_file = 1; control_minimal_window_size(430, 500); brows.all_redraw = 1; kolibri_handle_event_redraw(main_window); diff --git a/contrib/C_Layer/EXAMPLE/libguic_kolibri/editor_tree_msgbox.c b/contrib/C_Layer/EXAMPLE/libguic_kolibri/editor_tree_msgbox.c new file mode 100644 index 0000000000..a69678995f --- /dev/null +++ b/contrib/C_Layer/EXAMPLE/libguic_kolibri/editor_tree_msgbox.c @@ -0,0 +1,132 @@ + +/* + KolibriGUI demobox + -Editor (multiline edit) + -TreeView + -MsgBox Dialog + + Free for all + + Initially written by Siemargl, 2016 + + + ToDo +*/ + +#include +#include +#include +#include +#include "kos32sys.h" +#include "kolibri_gui.h" +#include "kolibri_libimg.h" +#include "kolibri_msgbox.h" + +char temp_path[4096]; + +char* load_file_inmem(char* fname, int32_t* read_sz); // see below + +int main(int argc, char **argv) +{ + /* Load all libraries, initialize global tables like system color table and + operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails + to do it's job. This is all you need to call and all libraries and GUI + elements can be used after a successful call to this function + */ + kolibri_gui_init(); + kolibri_proclib_init(); // opensave && color dialogs + kolibri_libimg_init(); // png handling + + int gui_event = KOLIBRI_EVENT_REDRAW; + uint32_t pressed_button = 0; +// uint32_t mouse_button; +// pos_t mouse_pos; + oskey_t keypress; + + // load image for buttons + const int icon_rgb_size = 16*16*3; // every icons 16x16 24bpp + char *image_data_rgb, + *image_data, + *filedata; + // make full path + argv + strcpy(temp_path, argv[0]); + char *pc = strrchr(temp_path, '/'); // this fails if has params with '/' within. use argv[0] instead + if (pc) pc[1] = 0; + strcat(temp_path, "reload_16x16_8b.png"); +// debug_board_write_str(temp_path); + + int32_t read_bytes; + filedata = load_file_inmem(temp_path, &read_bytes); + image_data_rgb = malloc(icon_rgb_size * 3); // we know size + // определяем вид изображения и переводим его во временный буфер image_data + image_data = (*img_decode)(filedata, read_bytes, 0); + // преобразуем изображение к формату rgb + (*img_to_rgb2)(image_data, image_data_rgb); + // удаляем временный буфер image_data + (*img_destroy)(image_data); + free(filedata); + + // creating GUI using library functions + kolibri_window *main_window = kolibri_new_window(50, 40, 470, 500, "Editor, TreeView and MsgBox demo"); + + editor *ed; + editor *ed_lock; + + gui_add_editor(main_window, ed = kolibri_new_editor(X_Y(10, 440), X_Y(20, 150), 0x1001, 2048, &ed_lock)); + ed_lock = ed; + + + filedata = load_file_inmem("/rd/1/File managers/z_icons.png", &read_bytes); + image_data_rgb = malloc(icon_rgb_size * 20); // we know size + // определяем вид изображения и переводим его во временный буфер image_data + image_data = (*img_decode)(filedata, read_bytes, 0); + // преобразуем изображение к формату rgb + (*img_to_rgb2)(image_data, image_data_rgb); + // удаляем временный буфер image_data + (*img_destroy)(image_data); + free(filedata); + + filedata = load_file_inmem("/rd/1/File managers/icons.ini", &read_bytes); + + + int extended_key = 0, act = 0; + msgbox* box = kolibri_new_msgbox("Exit", "Are\rYOU\rSure?", 3, "YES", "Absolute", "Not Yet", NULL); // default NOT + + do /* Start of main activity loop */ + { + switch(gui_event) + { + case KOLIBRI_EVENT_REDRAW: + if (box->retval == 1 || box->retval == 2) return 0; // msgbox closes + + kolibri_handle_event_redraw(main_window); + break; + case KOLIBRI_EVENT_NONE: + break; + case KOLIBRI_EVENT_KEY: + if (ed_lock == ed) + editor_key(ed); + else + kolibri_handle_event_key(main_window); + break; + case KOLIBRI_EVENT_BUTTON: + pressed_button = get_os_button(); + switch (pressed_button) + { + case BTN_QUIT: + if (box->retval == 3 || box->retval == 0) // not started or cancelled, analyze when redraw after closing msgbox + kolibri_start_msgbox(box, NULL); + return 0; + break; + } + break; + case KOLIBRI_EVENT_MOUSE: + kolibri_handle_event_mouse(main_window); + break; + } + + gui_event = get_os_event(); + } while(1) ; /* End of main activity loop */ + + return 0; +} diff --git a/contrib/C_Layer/INCLUDE/kolibri_buf2d.h b/contrib/C_Layer/INCLUDE/kolibri_buf2d.h index b7d4b1dd66..6b8fd9d545 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_buf2d.h +++ b/contrib/C_Layer/INCLUDE/kolibri_buf2d.h @@ -7,15 +7,15 @@ extern int kolibri_buf2d_init(void); -typedef struct { +typedef struct __attribute__ ((__packed__)) { unsigned int *buf_pointer; - uint16_t left; - uint16_t top; - unsigned int width; - unsigned int height; - unsigned int bgcolor; - uint8_t color_bit; -}buf2d_struct; + uint16_t left; + uint16_t top; + unsigned int width; + unsigned int height; + unsigned int bgcolor; + uint8_t color_bit; +}buf2d_struct; enum BUF2D_ALGORITM_FILTR { SIERRA_LITE, @@ -39,7 +39,7 @@ buf2d_struct* buf2d_create(uint16_t tlx, uint16_t tly, unsigned int sizex, unsig { buf2d_struct *new_buf2d_struct = (buf2d_struct *)malloc(sizeof(buf2d_struct)); new_buf2d_struct -> left = tlx; - new_buf2d_struct -> top = tly; + new_buf2d_struct -> top = tly; new_buf2d_struct -> width = sizex; new_buf2d_struct -> height = sizey; new_buf2d_struct -> bgcolor = font_bgcolor; diff --git a/contrib/C_Layer/INCLUDE/kolibri_colordialog.h b/contrib/C_Layer/INCLUDE/kolibri_colordialog.h index c8e8bddd18..3418d76206 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_colordialog.h +++ b/contrib/C_Layer/INCLUDE/kolibri_colordialog.h @@ -4,7 +4,7 @@ char cd_com_area_name[] = "FFFFFFFF_color_dialog"; char cd_start_path[] = "/rd/1/colrdial"; -typedef struct { +typedef struct __attribute__ ((__packed__)) { unsigned int type; unsigned int procinfo; unsigned int com_area_name; diff --git a/contrib/C_Layer/INCLUDE/kolibri_editor.h b/contrib/C_Layer/INCLUDE/kolibri_editor.h new file mode 100644 index 0000000000..bf8f3a9e4e --- /dev/null +++ b/contrib/C_Layer/INCLUDE/kolibri_editor.h @@ -0,0 +1,497 @@ +#ifndef KOLIBRI_EDITOR_H +#define KOLIBRI_EDITOR_H + +// (количество символов в новом документе + 2) +#define TE_MAXCHARS 100002 +// максимальный размер файла синтаксиса +#define TE_MAX_SYNTAX_FILESIZE 410000 +// buffer for copy|paste +#define TE_BUF_SIZE 4096 +typedef void (*editor_callback)(void); + +struct __attribute__ ((__packed__)) editor_symbol { + uint8_t c; // +0 символ + uint8_t col; // +1 цвет + struct editor_symbol *prev; // +2 + struct editor_symbol *next; // +6 указатели + uint32_t tc; // +10 врем. создания + uint32_t td; // +14 врем. удаления +}; + +/// структура текстового редактора +typedef struct __attribute__ ((__packed__)) { + uint32_t x_pos; //0 + uint32_t y_pos; //50 + uint32_t width; //440 + uint32_t hight; //150 + uint32_t w_pane; //30 ширина панели в окне + uint32_t h_pane; //25 высота панели в окне + uint32_t width_sym; //9 ширина символа (знакоместа) в окне + uint32_t hight_sym; //16 высота символа (знакоместа) в окне + uint8_t drag_m; // выделение от мыши + uint8_t drag_k; // выделение от клавиатуры + uint32_t sel_x0; // структура выделения + uint32_t sel_y0; + uint32_t sel_x1; + uint32_t sel_y1; + uint32_t seln_x0; //дополнительная структура выделения + uint32_t seln_y0; + uint32_t seln_x1; + uint32_t seln_y1; + struct editor_symbol *tex; // text memory pointer + struct editor_symbol *tex_1; // text first symbol pointer + struct editor_symbol *tex_end;// text end memory pointer + uint32_t cur_x; //координата x курсора + uint32_t cur_y; //координата y курсора + uint32_t max_chars; // TE_MAXCHARS ;+86 максимальное число символов в одном документе + uint32_t count_colors_text; // 1 ;+90 количество цветов текста + uint32_t count_key_words; //+94 колличество ключевых слов + color_t color_cursor; // 0x808080 ;+98 цвет курсора + color_t color_wnd_capt; // 0x80 ;+102 цвет полей вокруг окна + color_t color_wnd_work; // 0x0 ;+106 цвет фона окна + color_t color_wnd_bord; //0xd0d0d0 ;+110 цвет текста на полях + color_t color_select; // 0x208080 ;+114 цвет выделения + color_t color_cur_text; // 0xff0000 ;+118 цвет символа под курсором + color_t color_wnd_text; // 0xffff00 ;+122 цвет текста в окне + char *syntax_file; // указатель на начало файла синтаксиса + uint32_t syntax_file_size; // TE_MAX_SYNTAX_FILESIZE ;+130 максимальный размер файла синтаксиса + void *text_colors; // указатель на массив цветов текста + char *help_text_f1; // указатель на текст справки (по нажатии F1) + int help_id; // -1 ;+142 идентификатор для справки + void *key_words_data; // указатель на структуры ключевых слов TexColViv + uint32_t tim_ch; // количество изменений в файле + uint32_t tim_undo; // количество отмененных действий + uint32_t tim_ls; // время последнего сохранения + uint32_t tim_co; // время последней цветовой разметки + void *el_focus; // указатель на переменную элемента в фокусе pointer to pointer** + uint8_t err_save; // ошибка сохранения файла + uint8_t panel_id; // номер открытой панели + uint8_t key_new; // символ, который будет добавлятся с клавиатуры + uint8_t symbol_new_line; // ascii 20 символ завершения строки + scrollbar *scr_w; // вертикальный скроллинг != NULL + scrollbar *scr_h; // горизонтальный скроллинг != NULL + char *arr_key_pos;// указатель на массив позиций ключевых слов + char *buffer; // указатель на буфер копирования/вставки != NULL, also size + char *buffer_find;// указатель на буфер для поиска (sized 302) + uint8_t cur_ins; // 1 режим работы курсора (обычный или замена) + uint8_t mode_color; // 1 режим выделения слов цветом (0-выкл. 1-вкл.) + uint8_t mode_invis; // 0 режим показа непечатаемых символов + uint8_t gp_opt; // 0 опции возвращаемые функцией ted_get_pos_by_cursor + editor_callback fun_on_key_ctrl_o; // указатель на функцию вызываемую при нажатии Ctrl+O (открытие файла), can be NULL + editor_callback fun_on_key_ctrl_f; // ... Ctrl+F (вызова/скрытия панели поиска) + editor_callback fun_on_key_ctrl_n; // ... Ctrl+N (создание нового документа) + editor_callback fun_on_key_ctrl_s; // ... Ctrl+S + uint32_t buffer_size;// BUF_SIZE размер буфера копирования/вставки + editor_callback fun_find_err; // указатель на функцию вызываемую если поиск закончился неудачно + editor_callback fun_init_synt_err; // unused указатель на функцию вызываемую при ошибочном открытии файла синтаксиса + editor_callback fun_draw_panel_buttons; // указатель на функцию рисования панели с кнопками + editor_callback fun_draw_panel_find; // указатель на функцию рисования панели поиска + editor_callback fun_draw_panel_syntax; // указатель на функцию рисования панели синтаксиса + editor_callback fun_save_err; // указатель на функцию вызываемую если сохранение файла закончилось неудачно + uint32_t increase_size; //200 число символов на которые будет увечиваться память при нехватке + void *ptr_free_symb; // используется внутри элемента для ускорения вставки текста + uint32_t font_size; // ;+250 множитель для размера шрифта // binary OR mask for ECX SysFn4 +} editor; + +struct __attribute__ ((__packed__)) editor_color_item +{ + char word[40]; // слово для подсветки + uint32_t f1_offset; // смещение в таблице F1 подсказок + uint8_t flags; // флаги используемые при выделении + uint8_t endc; // символ конца выделения (используется при flags&4) + uint8_t escc; // экранирующий символ (используется при flags&4) ascii(34) примеры экранирования \r \n \t + uint8_t color; // цвет по таблице цветов +}; + +struct editor_syntax_file +{ + uint32_t count_colors_text; // кол-во цветов текста dd (text-color_wnd_text)/4 + uint32_t count_key_words; // кол-во ключевых слов dd (f1-text)/48 + color_t color_cursor; // dd 0xf1fcd0 + color_t color_wnd_capt; // dd 0x080808 + color_t color_wnd_work; // dd 0x1C1C1C + color_t color_wnd_bord; // dd 0xc0c0c0 + color_t color_select; // dd 0x3E3D32 + color_t color_cur_text; // dd 0x808080 + color_t color_wnd_text[]; // таблица цветов размером count_colors_text + // editor_color_item[]; // таблица ключевых подсвеченных слов размером count_key_words +}; + + +static struct editor_syntax_file default_syntax = { + 10, //count_colors_text + 0, // count_key_words dd (f1-text)/48 + 0xf1fcd0, //color_cursor dd 0xf1fcd0 + 0x080808, //color_wnd_capt dd 0x080808 + 0x1C1C1C, //color_wnd_work dd 0x1C1C1C + 0xc0c0c0, //color_wnd_bord dd 0xc0c0c0 + 0x3E3D32, //color_select dd 0x3E3D32 + 0x808080, //color_cur_text dd 0x808080 + {0xD0D0D0, 0xffff00, 0x00ff00, 0x00ffff, 0x808080, 0xff40ff, 0x4080ff, 0xff0000, 0x8080ff, 0x00ccff} +}; +// next structure must follow syntax definition, at least has 1 element !!! +static struct editor_color_item word1 = { + "siemargl", 1, 0, 0, 1 // test word colored as 1st in table +}; +// next structure preferably follow syntax definition, at least has 1 element !!! +static char f1_table[] = { + "\0" + "First\0" + "Last\0" +}; + + +extern void (*ted_draw)(editor *) __attribute__((__stdcall__)); +extern void (*ted_init_scroll_bars)(editor *, int opt) __attribute__((__stdcall__)); +/// opt bits = 1 - менять цвет скроллингов, 2 - изменились размеры окна, 4 - изменились размеры документа +extern void (*ted_init_syntax_file)(editor *) __attribute__((__stdcall__)); +extern void (*ted_mouse)(editor *) __attribute__((__stdcall__)); +extern void (*ted_text_add)(editor *, char *text, int textlen, int opt) __attribute__((__stdcall__)); +/// add text to cursor pos +/// opt == ted_opt_ed_change_time, ted_opt_ed_move_cursor +///ted_opt_ed_move_cursor equ 1 ;двигать курсор после добавления текста +///ted_opt_ed_change_time equ 2 ;добавлять изменения при редактировании текста +extern void (*ted_but_select_word)(editor *) __attribute__((__stdcall__)); +/// select word under cursor +extern void (*ted_but_copy)(editor *) __attribute__((__stdcall__)); +extern void (*ted_but_paste)(editor *) __attribute__((__stdcall__)); + +extern void (*ted_but_find_next)(editor *) __attribute__((__stdcall__)); +///move cursor to , calls ted_fun_find_err() if exist + + + +extern void (*ted_but_sumb_upper_asm)(editor *) __attribute__((__stdcall__)); +static inline void editor_selected_toupper(editor *ed) +{ + __asm__ __volatile__ ( + "push edi \n\t" + "push esi \n\t":::); + + (*ted_but_sumb_upper_asm)(ed); + + __asm__ __volatile__ ( + "pop esi \n\t" + "pop edi \n\t":::); +} + +extern void (*ted_but_sumb_lover_asm)(editor *) __attribute__((__stdcall__)); +static inline void editor_selected_tolower(editor *ed) +{ + __asm__ __volatile__ ( + "push edi \n\t" + "push esi \n\t":::); + + (*ted_but_sumb_lover_asm)(ed); + + __asm__ __volatile__ ( + "pop esi \n\t" + "pop edi \n\t":::); +} + + +extern void (*ted_but_convert_by_table_asm)(editor *, char* table) __attribute__((__stdcall__)); +static inline void editor_convert_by_table(editor *ed, char* table) +{ + __asm__ __volatile__ ( + "push edi \n\t" + "push esi \n\t":::); + + (*ted_but_convert_by_table_asm)(ed, table); + + __asm__ __volatile__ ( + "pop esi \n\t" + "pop edi \n\t":::); +} + +extern int (*ted_can_save_asm)(editor *) __attribute__((__stdcall__)); +static inline int editor_can_save(editor *ed) +/// return 1 if can be saved +{ + int ret; + __asm__ __volatile__ ( + "push edi \n\t":::); + + (*ted_can_save_asm)(ed); + + __asm__ __volatile__ ( + "pop edi \n\t":"=a"(ret)::); + return ret; +} + +extern void (*ted_clear_asm)(editor *, int) __attribute__((__stdcall__)); +static inline void editor_clear(editor *ed, int all) +/// all==1 - clear all memory +{ + __asm__ __volatile__ ( + "push edi \n\t":::); + + (*ted_clear_asm)(ed, all); + + __asm__ __volatile__ ( + "pop edi \n\t":::); +} + +extern void (*ted_delete_asm)(editor *) __attribute__((__stdcall__)); +static inline void editor_delete(editor *ed) +/// frees all memory (destroy) +{ + __asm__ __volatile__ ( + "push edi \n\t":::); + + (*ted_delete_asm)(ed); + + __asm__ __volatile__ ( + "pop edi \n\t":::); + free(ed->scr_w); + free(ed->scr_h); + free(ed->buffer); + free(ed->buffer_find); +} + +extern void (*ted_init_asm)(editor *) __attribute__((__stdcall__)); +static inline void editor_init(editor *ed) +/// allocate memory +{ + __asm__ __volatile__ ( + "push edi \n\t":::); + + (*ted_init_asm)(ed); + + __asm__ __volatile__ ( + "pop edi \n\t":::); +} + +extern int (*ted_is_select)(editor *) __attribute__((__stdcall__)); +static inline int editor_is_select(editor *ed) +/// return 1 if have selection +{ + int ret; + __asm__ __volatile__ ( + "push ebx \n\t":::); + + (*ted_is_select)(ed); + + __asm__ __volatile__ ( + "pop ebx \n\t":"=a"(ret)::); + return ret; +} + +enum control_keys { + KM_SHIFT = 0x00010000, + KM_CTRL = 0x00020000, + KM_ALT = 0x00040000, + KM_NUMLOCK = 0x00080000 +}; + +extern void (*ted_key_asm)(editor *, char* table, int control) __attribute__((__stdcall__)); +static inline void editor_keyboard(editor *ed, char* table, enum control_keys control, int ch) +/// control is KM_SHIFT, KM_ALT, KM_CTRL, KM_NUMLOCK, +/// ch = GET_KEY +/// table = SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT +{ + __asm__ __volatile__ ( + "nop \n\t"::"a"(ch):); + + (*ted_key_asm)(ed, table, control); +} + +extern void (*ted_open_file_asm)(editor *, struct fs_dirinfo*, char *fname) __attribute__((__stdcall__)); +static inline int editor_openfile(editor *ed, char *fname, int *readbytes) +/// returns errcode as SysFn70 +{ + int ret; + struct fs_dirinfo di; + __asm__ __volatile__ ( + "push edi \n\t":::); + + (*ted_open_file_asm)(ed, &di, fname); + + __asm__ __volatile__ ( + "pop edi \n\t":"=b"(*readbytes), "=a"(ret)::); + return ret; +} + +extern void (*ted_save_file_asm)(editor *, struct fs_dirinfo*, char *fname) __attribute__((__stdcall__)); +static inline int editor_savefile(editor *ed, char *fname) +/// returns errcode, calls fun_save_err() if exists +{ + struct fs_dirinfo di; + + (*ted_save_file_asm)(ed, &di, fname); + + return ed->err_save; +} + +extern void (*ted_but_cut)(editor *) __attribute__((__stdcall__)); +static inline void editor_cut(editor *ed) +{ + __asm__ __volatile__ ( + "push edi \n\t":::); + + (*ted_but_cut)(ed); + + __asm__ __volatile__ ( + "pop edi \n\t":::); +} + +extern void (*ted_but_undo)(editor *) __attribute__((__stdcall__)); +static inline void editor_undo(editor *ed) +{ + __asm__ __volatile__ ( + "push edi \n\t":::); + + (*ted_but_undo)(ed); + + __asm__ __volatile__ ( + "pop edi \n\t":::); +} + +extern void (*ted_but_redo)(editor *) __attribute__((__stdcall__)); +static inline void editor_redo(editor *ed) +{ + __asm__ __volatile__ ( + "push edi \n\t":::); + + (*ted_but_redo)(ed); + + __asm__ __volatile__ ( + "pop edi \n\t":::); +} + +extern void (*ted_but_reverse)(editor *) __attribute__((__stdcall__)); +static inline void editor_reverse(editor *ed) +{ + __asm__ __volatile__ ( + "push edi \n\t" + "push ebx\n\t":::); + + (*ted_but_reverse)(ed); + + __asm__ __volatile__ ( + "pop ebx \n\t" + "pop edi \n\t":::); +} + +extern void (*ted_text_colored_asm)() __attribute__((__stdcall__)); +static inline void editor_text_colored(editor *ed) +{ + __asm__ __volatile__ ( + "nop \n\t"::"D"(ed):); + + (*ted_text_colored_asm)(); +} + +static inline +uint32_t get_control_keys(void) +{ + uint32_t ctrl; + + __asm__ __volatile__( + "int $0x40 \n\t" + :"=a"(ctrl) + :"a"(66),"b"(3)); + + return ctrl; +}; + +static inline +int get_keyboard_layout(int opt, char* buf) +/// 128 byte buffer +/// opt: 1 - normal, 2 - shifted, 3 - alted, or 9 - return language +{ + uint32_t lang; + + __asm__ __volatile__( + "int $0x40 \n\t" + :"=a"(lang) + :"a"(26),"b"(2), "c"(opt), "d"(buf)); + + return lang; +}; + + +static void editor_key(editor* ed) +// callback for gui +{ + uint32_t control = get_control_keys(); + enum control_keys ed_ctrl = 0; + int ly_opt = 1; + if (control & 3) { ed_ctrl |= KM_SHIFT; ly_opt = 2; } + if (control & 0xC) ed_ctrl |= KM_CTRL; + if (control & 0x30){ ed_ctrl |= KM_ALT; ly_opt = 3; } + if (control & 0x80) ed_ctrl |= KM_NUMLOCK; + + char conv_table[128]; + get_keyboard_layout(ly_opt, conv_table); + + editor_keyboard(ed, conv_table, ed_ctrl, get_key().val); +} + +inline void gui_add_editor(kolibri_window *wnd, editor* e) +{ + kolibri_window_add_element(wnd, KOLIBRI_EDITOR, e); +} + +static inline editor* kolibri_new_editor(uint32_t x_w, uint32_t y_h, uint32_t font, uint32_t max_chars, editor **editor_interlock) +/// font - 0b10SSS 8x16 size multiply (SSS+1), 0xSSS - 6x9 multiply (SSS+1) + +{ + editor *ed = (editor *)calloc(1, sizeof(editor)); + ed->x_pos = x_w >> 16; + ed->width = x_w & 0xFFFF; + ed->y_pos = y_h >> 16; + ed->hight = y_h & 0xFFFF; + + // no panel, w_pane, h_pane == 0 + // font + if (font == 0) font = 0x10; // default 16 = 8x16 + int font_multipl = (font & 7) + 1; + ed->font_size = font << 24; + if (font & 0x10) // 8x16 + { + ed->width_sym = 8 * font_multipl; + ed->hight_sym = 16 * font_multipl; + } else // 6x9 + { + ed->width_sym = 6 * font_multipl; + ed->hight_sym = 9 * font_multipl; + } + // memory sizing for text & syntax + ed->max_chars = max_chars; + ed->increase_size = max_chars / 2; + ed->syntax_file_size = sizeof (default_syntax); + +/* // loaded auto from syntax + ed->color_cursor = 0x808080; + ed->color_wnd_capt = 0x80; + ed->color_wnd_bord = 0xd0d0d0; + ed->color_select = 0x208080; + ed->color_cur_text = 0xff0000; + ed->color_wnd_text = 0xffff00; +*/ + ed->symbol_new_line = 20; // ascii(20) + + ed->scr_w = kolibri_new_scrollbar_def(0, 0, 100, 30, 0); + ed->scr_h = kolibri_new_scrollbar_def(0, 0, 100, 30, 0); + + ed->buffer_size = TE_BUF_SIZE; + ed->buffer = malloc(TE_BUF_SIZE); + ed->buffer_find = malloc(TE_BUF_SIZE / 8); //where to store text to search + + ed->cur_ins = 1; // insert mode default + ed->mode_color = 1; // can select text + ed->mode_invis = 1; // show nonprinted symbols + + // ??? saveregs ax,cx,di + editor_init(ed); // memory allocation, cleaning + ed->syntax_file = (char*)&default_syntax; + (*ted_init_syntax_file)(ed); // load colors and syntax highlight + ed->help_text_f1 = f1_table; // override if not aligned immediately after syntax words + ed->key_words_data = &word1; + + return ed; +} + + +#endif // KOLIBRI_EDITOR_H diff --git a/contrib/C_Layer/INCLUDE/kolibri_filebrowse.h b/contrib/C_Layer/INCLUDE/kolibri_filebrowse.h index fefce557e3..fc77f3ee8a 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_filebrowse.h +++ b/contrib/C_Layer/INCLUDE/kolibri_filebrowse.h @@ -112,7 +112,7 @@ typedef struct __attribute__ ((__packed__)) { uint32_t select_flag; // widget have focus, set auto on mouseclick, but need to reset before mouse() color_t background_color; // self explained, 0xffffff color_t select_color; // self explained, 0xbbddff - color_t select_text_color; // self explained - have a bug - newer used + color_t select_text_color; // self explained - have a bug - never really used color_t text_color; // self explained color_t reduct_text_color; // 0xff0000 - spec color for cutted filenames color_t marked_text_color; // not used @@ -216,12 +216,7 @@ inline filebrowser* kolibri_filebrowser_def(filebrowser* fb, uint32_t x_w, uint3 0x000000, 0xbbddff, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0xff0000); } */ -/* -inline frame* kolibri_new_frame_def(uint32_t x_w, uint32_t y_h, char *text) -{ - return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area); -} -*/ + inline void gui_add_filebrowser(kolibri_window *wnd, filebrowser* f) { kolibri_window_add_element(wnd, KOLIBRI_FILEBROWSE, f); diff --git a/contrib/C_Layer/INCLUDE/kolibri_frame.h b/contrib/C_Layer/INCLUDE/kolibri_frame.h index 6765b4920a..bd43bb70c1 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_frame.h +++ b/contrib/C_Layer/INCLUDE/kolibri_frame.h @@ -1,10 +1,26 @@ #ifndef KOLIBRI_FRAME_H #define KOLIBRI_FRAME_H -enum { - TOP, - BOTTON +enum fr_text_position_t { + FR_TOP, + FR_BOTTON }; + +/* +; FR_FLAGS = [x][yyy][z] +; z - Caption +; yyy - BorderStyle +; x - BackStyle +*/ +enum fr_flags_t { + FR_CAPTION = 1, // if text != null set auto + FR_DOUBLE = 0, // default + FR_RAISED = 2, + FR_SUNKEN = 4, + FR_ETCHED = 6, + FR_RINGED = 8, + FR_FILLED = 0x10 +}; typedef struct { uint32_t type; @@ -12,7 +28,7 @@ typedef struct { uint32_t y_h; color_t ext_col; color_t int_col; - uint32_t draw_text_flag; + uint32_t flags; char *text_pointer; uint32_t text_position; uint32_t font_number; @@ -21,14 +37,16 @@ typedef struct { color_t font_bg_color; }frame; -inline frame* kolibri_frame(frame* f, uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, uint32_t text_position, color_t font_color, color_t font_bgcolor) +inline frame* kolibri_frame(frame* f, uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, enum fr_text_position_t text_position, + color_t font_color, color_t font_bgcolor, enum fr_flags_t flags) { f->type = 0; f->x_w = x_w; f->y_h = y_h; f->ext_col = ext_col; f->int_col = int_col; - f->draw_text_flag = text != NULL; + f->flags = flags; + if (text) f->flags |= FR_CAPTION; f->text_pointer = text; f->text_position = text_position; f->font_number = 0; // 0 == font 6x9, 1==8x16 @@ -36,23 +54,25 @@ inline frame* kolibri_frame(frame* f, uint32_t x_w, uint32_t y_h, color_t ext_co f->font_color = font_color | 0x80000000; f->font_bg_color = font_bgcolor; + return f; } -inline frame* kolibri_new_frame(uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, uint32_t text_position, color_t font_color, color_t font_bgcolor) +inline frame* kolibri_new_frame(uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, enum fr_text_position_t text_position, + color_t font_color, color_t font_bgcolor, enum fr_flags_t flags) { frame *new_frame = (frame *)malloc(sizeof(frame)); - return kolibri_frame(new_frame, x_w, y_h, ext_col, int_col, text, text_position, font_color, font_bgcolor); + return kolibri_frame(new_frame, x_w, y_h, ext_col, int_col, text, text_position, font_color, font_bgcolor, flags); } inline frame* kolibri_frame_def(frame* f, uint32_t x_w, uint32_t y_h, char *text) { - return kolibri_frame(f, x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area); + return kolibri_frame(f, x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, FR_TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0); } inline frame* kolibri_new_frame_def(uint32_t x_w, uint32_t y_h, char *text) { - return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area); + return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, FR_TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0); } inline void gui_add_frame(kolibri_window *wnd, frame* f) diff --git a/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h b/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h index 1679c42a81..ee10205f45 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h +++ b/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h @@ -25,6 +25,7 @@ enum KOLIBRI_GUI_ELEMENT_TYPE { KOLIBRI_D_BUTTON, KOLIBRI_PATHSHOW, KOLIBRI_FILEBROWSE, + KOLIBRI_EDITOR, /* Add elements above this element in order to let KOLIBRI_NUM_GUI_ELEMENTS */ /* stay at correct value */ @@ -79,7 +80,7 @@ void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_EL #include "kolibri_scrollbar.h" #include "kolibri_statictext.h" #include "kolibri_filebrowse.h" - +#include "kolibri_editor.h" /*---------------------Define various functions for initializing GUI-------*/ @@ -150,7 +151,11 @@ kolibri_gui_op_table[KOLIBRI_PATHSHOW].key_fn = NULL; kolibri_gui_op_table[KOLIBRI_FILEBROWSE].redraw_fn = (cb_elem_boxlib)filebrowse_draw; kolibri_gui_op_table[KOLIBRI_FILEBROWSE].mouse_fn = (cb_elem_boxlib)filebrowse_mouse; kolibri_gui_op_table[KOLIBRI_FILEBROWSE].key_fn = (cb_elem_boxlib)filebrowse_key; -debug_board_printf("KOLIBRI_FILEBROWSE (%x,%x,%x)\n", filebrowse_draw, filebrowse_mouse, filebrowse_key); + +kolibri_gui_op_table[KOLIBRI_EDITOR].redraw_fn = (cb_elem_boxlib)ted_draw; +kolibri_gui_op_table[KOLIBRI_EDITOR].mouse_fn = (cb_elem_boxlib)ted_mouse; +kolibri_gui_op_table[KOLIBRI_EDITOR].key_fn = (cb_elem_boxlib)editor_key; +debug_board_printf("KOLIBRI_EDITOR (%x,%x,%x)\n", ted_draw, ted_mouse, editor_key); } /* Create a new main GUI window for KolibriOS */ diff --git a/contrib/C_Layer/INCLUDE/kolibri_kmenu.h b/contrib/C_Layer/INCLUDE/kolibri_kmenu.h index a5c51d6518..45765b33ea 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_kmenu.h +++ b/contrib/C_Layer/INCLUDE/kolibri_kmenu.h @@ -22,7 +22,7 @@ typedef struct { }; } t_font; -typedef struct { +typedef struct __attribute__ ((__packed__)) { uint16_t left, top, right, bottom; } t_rect; @@ -30,13 +30,13 @@ typedef struct kmenuitem_t{ int type; char *text; union { - void *submenu; + void *submenu; //kmenuitem_callback_t callback; size_t btnid; }; - + void (*paint)(struct kmenuitem_t *item, t_rect *rc) __attribute__((__stdcall__)); - + int is_focused; int is_enabled; int is_visible; @@ -44,7 +44,7 @@ typedef struct kmenuitem_t{ int font_width, font_height; t_font font; - + size_t left, top; size_t width, height, pref_width, pref_height; size_t margin_left, margin_right, margin_top, margin_bottom; @@ -54,41 +54,41 @@ typedef struct kmenuitem_t{ typedef struct ksubmenu_t{ kmenuitem_t **items; int count; - + void (*paint)(struct ksubmenu_t *menu) __attribute__((__stdcall__)); - + int is_opened; int focus_idx; - + size_t width, height; size_t left, top; int tid; int parent_wnd, parent_tid, submenu_tid, self_wnd; int level; size_t return_btnid; - + int set_new_padding, set_new_margin; t_rect items_padding; t_rect items_margin; - + struct ksubmenu_t *parent; } ksubmenu_t; typedef struct { kmenuitem_t **submenu; int count; - + size_t width, height; size_t left, top; - + int line_height; - + int focus_idx; int submenu_tid; } kmenu_t; -extern int kolibri_kmenu_init(void); +extern int kolibri_kmenu_init(void); extern void (*kmainmenu_draw)(ksubmenu_t *) __attribute__((__stdcall__)); extern void (*kmainmenu_dispatch_cursorevent)(ksubmenu_t *) __attribute__((__stdcall__)); diff --git a/contrib/C_Layer/INCLUDE/kolibri_msgbox.h b/contrib/C_Layer/INCLUDE/kolibri_msgbox.h new file mode 100644 index 0000000000..918de6988c --- /dev/null +++ b/contrib/C_Layer/INCLUDE/kolibri_msgbox.h @@ -0,0 +1,60 @@ +#ifndef KOLIBRI_MSGBOX_H +#define KOLIBRI_MSGBOX_H +#include + +typedef struct __attribute__ ((__packed__)) { + uint8_t retval; // 0 - win closed, 1 to n - button num, also default button on start + uint8_t reserv; + char texts[2048]; // mus be enough ;-) + char msgbox_stack[1024]; + uint32_t top_stack; +} msgbox; + + +typedef void (*msgbox_callback)(void); + +static int msgbox_inited; +extern void kolibri_msgbox_init(); +extern void (*msgbox_create)(msgbox *, void *thread) __attribute__((__stdcall__)); // clears callbacks, ! if fix lib, we can return eax as of Fn51 +extern void (*msgbox_setfunctions)(msgbox_callback*) __attribute__((__stdcall__)); // must be called immediately after create, zero-ended array +extern void (*msgbox_reinit)(msgbox *) __attribute__((__stdcall__)); // recalc sizes when structure changes, called auto when MsgBoxCreate + +static inline msgbox* kolibri_new_msgbox(char* title, char* text, int def_but, ...) +/// text can be multilined by code 13 = "\r" +/// def_but - highlighted and used on Enter (if zero - default is [X]), user may use Tabs or Arrows +/// last params are buttons text, max 8. last must set as NULL +{ + va_list vl; + va_start(vl, def_but); + + msgbox* box = calloc(sizeof(msgbox), 1); + box->retval = (uint8_t)def_but; + char *pc = box->texts, + *but_text = va_arg(vl, char*); + strcpy(pc, title); + pc += strlen(title) + 1; + + while (but_text) + { + strcpy(pc, but_text); + pc += strlen(but_text) + 1; + // assert(pc - box->texts < sizeof box->texts); + } + + va_end(vl); + + return box; +} + +void kolibri_start_msgbox(msgbox* box, msgbox_callback cb[]) +{ + if (!msgbox_inited) + { + kolibri_msgbox_init(); + msgbox_inited++; + } + (*msgbox_create)(box, &box->top_stack); + if (cb) (*msgbox_setfunctions)(cb); +} + +#endif diff --git a/contrib/C_Layer/INCLUDE/kolibri_opendialog.h b/contrib/C_Layer/INCLUDE/kolibri_opendialog.h index 7d3a7f6301..aae01d4aa8 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_opendialog.h +++ b/contrib/C_Layer/INCLUDE/kolibri_opendialog.h @@ -11,12 +11,12 @@ enum open_dialog_mode { SELECT }; -typedef struct { +typedef struct __attribute__ ((__packed__)) { unsigned int size; unsigned char end; }od_filter; -typedef struct { +typedef struct __attribute__ ((__packed__)) { unsigned int mode; char* procinfo; char* com_area_name; diff --git a/contrib/C_Layer/INCLUDE/kolibri_optionbox.h b/contrib/C_Layer/INCLUDE/kolibri_optionbox.h index e536ff76bd..7189216201 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_optionbox.h +++ b/contrib/C_Layer/INCLUDE/kolibri_optionbox.h @@ -1,7 +1,7 @@ #ifndef KOLIBRI_OPTIONBOX_H #define KOLIBRI_OPTIONBOX_H -typedef struct option_box_t{ +typedef struct __attribute__ ((__packed__)) option_box_t { struct option_box_t **selected; uint16_t posx; uint16_t posy; diff --git a/contrib/C_Layer/INCLUDE/kolibri_pathshow.h b/contrib/C_Layer/INCLUDE/kolibri_pathshow.h index c41e1102e4..5ab1c26939 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_pathshow.h +++ b/contrib/C_Layer/INCLUDE/kolibri_pathshow.h @@ -1,7 +1,7 @@ #ifndef KOLIBRI_PATHSHOW_H #define KOLIBRI_PATHSHOW_H -typedef struct { +typedef struct __attribute__ ((__packed__)) { uint32_t type; uint32_t x_y; uint16_t font_size_x; // 6 - for font 0, 8 - for font 1 diff --git a/contrib/C_Layer/INCLUDE/kolibri_scrollbar.h b/contrib/C_Layer/INCLUDE/kolibri_scrollbar.h index 4ad25ef6a1..201f59e488 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_scrollbar.h +++ b/contrib/C_Layer/INCLUDE/kolibri_scrollbar.h @@ -1,7 +1,7 @@ #ifndef KOLIBRI_SCROLLBAR_H #define KOLIBRI_SCROLLBAR_H -typedef struct { +typedef struct __attribute__ ((__packed__)) { // uint16_t xsize; // uint16_t xpos; // uint16_t ysize; @@ -9,7 +9,7 @@ typedef struct { uint32_t x_w; uint32_t y_h; uint32_t btn_height; - uint32_t type; + uint32_t type; // type 1 - stylish frame, type 2 - ?, type 0 - ? uint32_t max_area; uint32_t cur_area; uint32_t position; diff --git a/contrib/C_Layer/INCLUDE/kolibri_treelist.h b/contrib/C_Layer/INCLUDE/kolibri_treelist.h new file mode 100644 index 0000000000..c36ba90877 --- /dev/null +++ b/contrib/C_Layer/INCLUDE/kolibri_treelist.h @@ -0,0 +1,106 @@ +#ifndef KOLIBRI_TREELIST_H +#define KOLIBRI_TREELIST_H + +/* +el_focus dd tedit0 +mouse_dd dd 0 +tree1 tree_list 264,count_of_dir_list_files+2, tl_key_no_edit+tl_draw_par_line+tl_list_box_mode,\ + 16,16, 0x8080ff,0x0000ff,0xffffff, 0,70,TED_PANEL_WIDTH-17,120, 0,0,0, el_focus,\ + ws_dir_lbox,0 + +tree3 tree_list MAX_COLOR_WORD_LEN,3,tl_key_no_edit,\ + 16,16, 0x8080ff,0x0000ff,0xffffff, 5,30,300,160, 16, 0,0, el_focus, w_scr_t3,0 + +tree_file_struct: + dd 1 + dd 0,0,count_of_dir_list_files + dd dir_mem + db 0 + dd file_name ;sys_path +*/ +/* +;struct TreeList +; type dw ? ;+ 0 тип элемента, или индекс иконки для узла +; lev db ? ;+ 2 уровень элемента +; clo db ? ;+ 3 флаг закрытия, или открытия (имеет смысл для родительского узла) +; perv dd ? ;+ 4 индекс предыдущего элемента +; next dd ? ;+ 8 индекс последующего элемента +; tc dd ? ;+12 врем. создания +; td dd ? ;+16 врем. удаления +;ends + +struc tree_list info_size,info_max_count,style, img_cx,img_cy,\ + col_bkg,col_zag,col_txt, box_l,box_t,box_w,box_h, capt_cy,info_capt_offs,\ + info_capt_len,el_focus, p_scroll,on_press { +.box_left dd box_l +.box_top dd box_t +.box_width dd box_w +.box_height dd box_h +.data_info dd 0 +.info_size dw info_size +.info_max_count dd info_max_count +.style dd style +.data_nodes dd 0 +.data_img dd 0 +.img_cx dw img_cx +.img_cy dw img_cy +.data_img_sys dd 0 +.ch_tim dd 0 +.tim_undo dd 0 +.cur_pos dd 0 +.col_bkg dd col_bkg +.col_zag dd col_zag +.col_txt dd col_txt +.capt_cy dw capt_cy +.info_capt_offs dw info_capt_offs +.info_capt_len dw info_capt_len +.el_focus dd el_focus +.p_scroll dd p_scroll +.on_press dd on_press +} +*/ +// константы стиля +enum tl_style { + TL_KEY_NO_EDIT = 1, // элемент нельзя редактировать на клавиатуре (изменять уровни, удалять) + TL_DRAW_PAR_LINE = 2, // рисовать линии к родительскому узлу + TL_LISTBOX_MODE = 4 //стиль не отображает уровни (как в ListBox все одного уровня) +}; + +typedef struct __attribute__ ((__packed__)) { + uint32_t left; + uint32_t top; + uint32_t width; + uint32_t height; + void *data_info; // указатель на основные даные + uint16_t info_size; // размер данных выделяемых для каждого узла (пользовательськие данные + текст для подписи) + uint32_t info_max_count; // максимальное количество узлов, которые можно добавить в элемент + uint32_t style; // стили элемента + void *data_nodes; // указатель на структуры узлов + void *data_img; // указатель на изображения с иконками узлов + uint16_t img_cx; // ширина иконок + uint16_t img_cy; // высота иконок + void *data_img_sys;//указатель на системные изображения (стрелки, плюсики) + uint32_t ch_tim; // количество изменений в файле + uint32_t tim_undo; // количество отмененных действий + uint32_t cur_pos; // позиция курсора + color_t col_bkg; // цвет фона + color_t tl_col_zag; // цвет заголовка + color_t tl_col_txt; // цвет текста + uint16_t capt_cy; // высота подписи + uint16_t info_capt_offs;//сдвиг для начала текста (подписи узла) + uint16_t info_capt_len;//длина текста подписи узла (если = 0 то до конца структуры) + void *el_focus; // указатель на структуру элемента в фокусе + void *p_scroll; // указатель на структуру скроллинга + void *on_press; // +84 указатель на функцию, которая вызывается при нажатии Enter +} treelist; + +/* +;константы для функций +tl_err_save_memory_size equ 10b ;не хватает памяти для сохранения элемента +tl_err_load_caption equ 1b ;в памяти нет заголовка 'tree' +tl_err_load_info_size equ 100b ;не совпадает размер информационной структуры при открытии +tl_load_mode_add equ 0x20000 ;опция считывания в режиме добавления информации +tl_save_load_heder_size equ 26 ;размер заголовка для записи/чтения элементов +*/ + +#endif //KOLIBRI_TREELIST_H