forked from KolibriOS/kolibrios
editor, treelist, msgbox demo runs
git-svn-id: svn://kolibrios.org@6601 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
113ef158d8
commit
7bf14f7dc9
@ -183,3 +183,29 @@ 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'
|
||||
|
||||
public tl_data_init as '_tl_data_init_asm'
|
||||
public tl_data_clear as '_tl_data_clear_asm'
|
||||
public tl_info_clear as '_tl_info_clear_asm'
|
||||
public tl_key as '_tl_key_asm'
|
||||
public tl_mouse as '_tl_mouse'
|
||||
public tl_draw as '_tl_draw'
|
||||
public tl_info_undo as '_tl_info_undo_asm'
|
||||
public tl_info_redo as '_tl_info_redo_asm'
|
||||
public tl_node_add as '_tl_node_add_asm'
|
||||
public tl_node_set_data as '_tl_node_set_data_asm'
|
||||
public tl_node_get_data as '_tl_node_get_data_asm'
|
||||
public tl_node_delete as '_tl_node_delete_asm'
|
||||
public tl_cur_beg as '_tl_cur_beg_asm'
|
||||
public tl_cur_next as '_tl_cur_next_asm'
|
||||
public tl_cur_perv as '_tl_cur_perv_asm'
|
||||
public tl_node_close_open as '_tl_node_close_open_asm'
|
||||
public tl_node_lev_inc as '_tl_node_lev_inc_asm'
|
||||
public tl_node_lev_dec as '_tl_node_lev_dec_asm'
|
||||
public tl_node_move_up as '_tl_node_move_up'
|
||||
public tl_node_move_down as '_tl_node_move_down'
|
||||
public tl_node_poi_get_info as '_tl_node_poi_get_info_asm'
|
||||
public tl_node_poi_get_next_info as '_tl_node_poi_get_next_info_asm'
|
||||
public tl_node_poi_get_data as '_tl_node_poi_get_data_asm'
|
||||
public tl_save_mem as '_tl_save_mem_asm'
|
||||
public tl_load_mem as '_tl_load_mem_asm'
|
||||
public tl_get_mem_size as '_tl_get_mem_size_asm'
|
||||
|
@ -19,10 +19,13 @@ SOURCES = boardmsg.c option_menu.c
|
||||
|
||||
OBJECTS = $(patsubst %.c, %.o, $(SOURCES))
|
||||
|
||||
all: boardmsg option_menu scroll_progress dbutton_files
|
||||
all: boardmsg option_menu scroll_progress dbutton_files editor_tree_msgbox
|
||||
|
||||
editor_tree_msgbox: editor_tree_msgbox.o
|
||||
$(LD) $(LIBPATH) --subsystem windows -o $@ $^ $(OBJPATH)/loadboxlib.obj $(OBJPATH)/loadlibimg.obj $(OBJPATH)/loadmsgbox.obj $(LDFLAGS) -Map=editor_tree_msgbox.map
|
||||
kos32-objcopy $@ -O binary
|
||||
|
||||
scroll_progress: scroll_progress.o
|
||||
# $(LD) $(LIBPATH) --subsystem native -o $@ $^ $(OBJPATH)/loadboxlib.obj $(LDFLAGS)
|
||||
$(LD) $(LIBPATH) --subsystem windows -o $@ $^ $(OBJPATH)/loadboxlib.obj $(LDFLAGS)
|
||||
kos32-objcopy $@ -O binary
|
||||
|
||||
@ -36,7 +39,7 @@ boardmsg: boardmsg.o
|
||||
kos32-objcopy $@ -O binary
|
||||
|
||||
dbutton_files: dbutton_files.o
|
||||
$(LD) $(LIBPATH) --subsystem native -o $@ $^ $(OBJPATH)/loadboxlib.obj $(OBJPATH)/loadproclib.obj $(OBJPATH)/loadlibimg.obj $(LDFLAGS) -Map=dbutton_files.map
|
||||
$(LD) $(LIBPATH) --subsystem native -o $@ $^ $(OBJPATH)/loadboxlib.obj $(OBJPATH)/loadproclib.obj $(OBJPATH)/loadlibimg.obj $(LDFLAGS)
|
||||
kos32-objcopy $@ -O binary
|
||||
|
||||
%.o : %.c Makefile
|
||||
|
@ -22,9 +22,11 @@
|
||||
#include "kolibri_libimg.h"
|
||||
#include "kolibri_msgbox.h"
|
||||
|
||||
char temp_path[4096];
|
||||
char run_path[4096];
|
||||
char fname[4096];
|
||||
|
||||
char* load_file_inmem(char* fname, int32_t* read_sz); // see below
|
||||
char* load_image_file(char* fname); // see below
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@ -34,7 +36,7 @@ int main(int argc, char **argv)
|
||||
elements can be used after a successful call to this function
|
||||
*/
|
||||
kolibri_gui_init();
|
||||
kolibri_proclib_init(); // opensave && color dialogs
|
||||
// kolibri_proclib_init(); // opensave && color dialogs
|
||||
kolibri_libimg_init(); // png handling
|
||||
|
||||
int gui_event = KOLIBRI_EVENT_REDRAW;
|
||||
@ -43,53 +45,46 @@ int main(int argc, char **argv)
|
||||
// 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
|
||||
strcpy(run_path, argv[0]);
|
||||
char *pc = strrchr(run_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");
|
||||
kolibri_window *main_window = kolibri_new_window(50, 40, 490, 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));
|
||||
gui_add_editor(main_window, ed = kolibri_new_editor(X_Y(0, 440), X_Y(20, 150), 0x1001, 2048, &ed_lock));
|
||||
ed_lock = ed;
|
||||
|
||||
treelist *tl = kolibri_new_treelist(X_Y(0, 440), X_Y(200, 200), 16, X_Y(16, 16), 100, 50, 0, 0, TL_KEY_NO_EDIT | TL_DRAW_PAR_LINE, &ed_lock, 0x8080ff, 0x0000ff, 0xffffff);
|
||||
treelist_data_init(tl);
|
||||
|
||||
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);
|
||||
// ÷èòàåì ôàéë ñ êóðñîðàìè è ëèíèÿìè
|
||||
strcpy(fname, run_path);
|
||||
strcat(fname, "tl_sys_16.png");
|
||||
tl->data_img_sys = load_image_file(fname);
|
||||
|
||||
filedata = load_file_inmem("/rd/1/File managers/icons.ini", &read_bytes);
|
||||
// ÷èòàåì ôàéë ñ èêîíêàìè óçëîâ
|
||||
strcpy(fname, run_path);
|
||||
strcat(fname, "tl_nod_16.png");
|
||||
tl->data_img = load_image_file(fname);
|
||||
|
||||
treelist_node_add(tl, "node1", 1, 0, 0); // ãäå 1 íîìåð èêîíêè ñ êíèãîé
|
||||
treelist_cursor_next(tl);
|
||||
|
||||
treelist_node_add(tl, "node2", 1, 0, 0);
|
||||
treelist_cursor_next(tl);
|
||||
|
||||
treelist_node_add(tl, "node3", 1, 0, 0);
|
||||
treelist_cursor_next(tl);
|
||||
|
||||
treelist_cursor_begin(tl); //;ñòàâèì êóðñîð íà íà÷àëî ñïèñêà
|
||||
gui_add_treelist(main_window, tl);
|
||||
|
||||
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 */
|
||||
@ -97,7 +92,7 @@ int main(int argc, char **argv)
|
||||
switch(gui_event)
|
||||
{
|
||||
case KOLIBRI_EVENT_REDRAW:
|
||||
if (box->retval == 1 || box->retval == 2) return 0; // msgbox closes
|
||||
if (box->retval == 1 || box->retval == 2) goto clearing; // msgbox closes
|
||||
|
||||
kolibri_handle_event_redraw(main_window);
|
||||
break;
|
||||
@ -115,8 +110,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
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;
|
||||
kolibri_start_msgbox(box, NULL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -127,6 +121,60 @@ int main(int argc, char **argv)
|
||||
|
||||
gui_event = get_os_event();
|
||||
} while(1) ; /* End of main activity loop */
|
||||
|
||||
clearing:
|
||||
editor_delete(ed);
|
||||
treelist_data_clear(tl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char* load_file_inmem(char* fname, int32_t* read_sz)
|
||||
{
|
||||
FILE *f = fopen(fname, "rb");
|
||||
if (!f) {
|
||||
debug_board_printf("Can't open file: %s", fname);
|
||||
exit(1);
|
||||
}
|
||||
if (fseek(f, 0, SEEK_END)) {
|
||||
debug_board_printf("Can't SEEK_END file: %s", fname);
|
||||
exit(1);
|
||||
}
|
||||
int filesize = ftell(f);
|
||||
rewind(f);
|
||||
char* fdata = malloc(filesize);
|
||||
if(!fdata) {
|
||||
debug_board_printf("No memory for file %s", fname);
|
||||
exit(1);
|
||||
}
|
||||
*read_sz = fread(fdata, 1, filesize, f);
|
||||
if (ferror(f)) {
|
||||
debug_board_printf("Error reading file %s", fname);
|
||||
exit(1);
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
return fdata;
|
||||
}
|
||||
|
||||
char* load_image_file(char* fname)
|
||||
{
|
||||
int32_t read_bytes = -1, w, h;
|
||||
char *image_data = 0, *image_data_rgb = 0, *filedata = 0;
|
||||
|
||||
filedata = load_file_inmem(fname, &read_bytes);
|
||||
// îïðåäåëÿåì âèä èçîáðàæåíèÿ è ïåðåâîäèì åãî âî âðåìåííûé áóôåð image_data
|
||||
image_data = (*img_decode)(filedata, read_bytes, 0);
|
||||
w = *(int*)(image_data +4);
|
||||
h = *(int*)(image_data +8);
|
||||
image_data_rgb = malloc(w * h * 3);
|
||||
// ïðåîáðàçóåì èçîáðàæåíèå ê ôîðìàòó rgb
|
||||
(*img_to_rgb2)(image_data, image_data_rgb);
|
||||
// óäàëÿåì âðåìåííûé áóôåð image_data
|
||||
(*img_destroy)(image_data);
|
||||
free(filedata);
|
||||
|
||||
return image_data_rgb;
|
||||
}
|
||||
|
||||
|
BIN
contrib/C_Layer/EXAMPLE/libguic_kolibri/tl_nod_16.png
Normal file
BIN
contrib/C_Layer/EXAMPLE/libguic_kolibri/tl_nod_16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 699 B |
BIN
contrib/C_Layer/EXAMPLE/libguic_kolibri/tl_sys_16.png
Normal file
BIN
contrib/C_Layer/EXAMPLE/libguic_kolibri/tl_sys_16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -120,7 +120,7 @@ struct editor_syntax_file
|
||||
|
||||
static struct editor_syntax_file default_syntax = {
|
||||
10, //count_colors_text
|
||||
0, // count_key_words dd (f1-text)/48
|
||||
1, // count_key_words dd (f1-text)/48, minimum 1
|
||||
0xf1fcd0, //color_cursor dd 0xf1fcd0
|
||||
0x080808, //color_wnd_capt dd 0x080808
|
||||
0x1C1C1C, //color_wnd_work dd 0x1C1C1C
|
||||
@ -165,28 +165,28 @@ 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":::);
|
||||
"push %%edi \n\t"
|
||||
"push %%esi \n\t":::);
|
||||
|
||||
(*ted_but_sumb_upper_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop esi \n\t"
|
||||
"pop edi \n\t":::);
|
||||
"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":::);
|
||||
"push %%edi \n\t"
|
||||
"push %%esi \n\t":::);
|
||||
|
||||
(*ted_but_sumb_lover_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop esi \n\t"
|
||||
"pop edi \n\t":::);
|
||||
"pop %%esi \n\t"
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
|
||||
@ -194,28 +194,28 @@ extern void (*ted_but_convert_by_table_asm)(editor *, char* table) __attribute__
|
||||
static inline void editor_convert_by_table(editor *ed, char* table)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t"
|
||||
"push esi \n\t":::);
|
||||
"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":::);
|
||||
"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
|
||||
/// return 1 if need to be saved (has changes), 0 otherwise
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*ted_can_save_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":"=a"(ret)::);
|
||||
"pop %%edi \n\t":"=a"(ret)::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -224,12 +224,12 @@ static inline void editor_clear(editor *ed, int all)
|
||||
/// all==1 - clear all memory
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*ted_clear_asm)(ed, all);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*ted_delete_asm)(editor *) __attribute__((__stdcall__));
|
||||
@ -237,12 +237,12 @@ static inline void editor_delete(editor *ed)
|
||||
/// frees all memory (destroy)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*ted_delete_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
"pop %%edi \n\t":::);
|
||||
free(ed->scr_w);
|
||||
free(ed->scr_h);
|
||||
free(ed->buffer);
|
||||
@ -254,12 +254,12 @@ static inline void editor_init(editor *ed)
|
||||
/// allocate memory
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*ted_init_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern int (*ted_is_select)(editor *) __attribute__((__stdcall__));
|
||||
@ -268,12 +268,12 @@ static inline int editor_is_select(editor *ed)
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__ (
|
||||
"push ebx \n\t":::);
|
||||
"push %%ebx \n\t":::);
|
||||
|
||||
(*ted_is_select)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop ebx \n\t":"=a"(ret)::);
|
||||
"pop %%ebx \n\t":"=a"(ret)::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -303,12 +303,12 @@ static inline int editor_openfile(editor *ed, char *fname, int *readbytes)
|
||||
int ret;
|
||||
struct fs_dirinfo di;
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*ted_open_file_asm)(ed, &di, fname);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":"=b"(*readbytes), "=a"(ret)::);
|
||||
"pop %%edi \n\t":"=b"(*readbytes), "=a"(ret)::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -327,50 +327,50 @@ extern void (*ted_but_cut)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_cut(editor *ed)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*ted_but_cut)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
"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":::);
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*ted_but_undo)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
"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":::);
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*ted_but_redo)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
"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":::);
|
||||
"push %%edi \n\t"
|
||||
"push %%ebx\n\t":::);
|
||||
|
||||
(*ted_but_reverse)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop ebx \n\t"
|
||||
"pop edi \n\t":::);
|
||||
"pop %%ebx \n\t"
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*ted_text_colored_asm)() __attribute__((__stdcall__));
|
||||
@ -428,7 +428,7 @@ static void editor_key(editor* ed)
|
||||
editor_keyboard(ed, conv_table, ed_ctrl, get_key().val);
|
||||
}
|
||||
|
||||
inline void gui_add_editor(kolibri_window *wnd, editor* e)
|
||||
static inline void gui_add_editor(kolibri_window *wnd, editor* e)
|
||||
{
|
||||
kolibri_window_add_element(wnd, KOLIBRI_EDITOR, e);
|
||||
}
|
||||
@ -472,8 +472,8 @@ static inline editor* kolibri_new_editor(uint32_t x_w, uint32_t y_h, uint32_t fo
|
||||
*/
|
||||
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->scr_w = kolibri_new_scrollbar_def(X_Y(50, 16), X_Y(50, 300), 100, 30, 0);
|
||||
ed->scr_h = kolibri_new_scrollbar_def(X_Y(0, 150), X_Y(50, 16), 100, 30, 0);
|
||||
|
||||
ed->buffer_size = TE_BUF_SIZE;
|
||||
ed->buffer = malloc(TE_BUF_SIZE);
|
||||
|
@ -26,6 +26,7 @@ enum KOLIBRI_GUI_ELEMENT_TYPE {
|
||||
KOLIBRI_PATHSHOW,
|
||||
KOLIBRI_FILEBROWSE,
|
||||
KOLIBRI_EDITOR,
|
||||
KOLIBRI_TREELIST,
|
||||
|
||||
/* Add elements above this element in order to let KOLIBRI_NUM_GUI_ELEMENTS */
|
||||
/* stay at correct value */
|
||||
@ -81,6 +82,7 @@ void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_EL
|
||||
#include "kolibri_statictext.h"
|
||||
#include "kolibri_filebrowse.h"
|
||||
#include "kolibri_editor.h"
|
||||
#include "kolibri_treelist.h"
|
||||
|
||||
|
||||
/*---------------------Define various functions for initializing GUI-------*/
|
||||
@ -156,6 +158,11 @@ 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);
|
||||
|
||||
kolibri_gui_op_table[KOLIBRI_TREELIST].redraw_fn = (cb_elem_boxlib)tl_draw;
|
||||
kolibri_gui_op_table[KOLIBRI_TREELIST].mouse_fn = (cb_elem_boxlib)tl_mouse;
|
||||
kolibri_gui_op_table[KOLIBRI_TREELIST].key_fn = (cb_elem_boxlib)treelist_key;
|
||||
debug_board_printf("KOLIBRI_TREELIST (%x,%x,%x)\n", tl_draw, tl_mouse, treelist_key);
|
||||
}
|
||||
|
||||
/* Create a new main GUI window for KolibriOS */
|
||||
|
@ -29,16 +29,19 @@ static inline msgbox* kolibri_new_msgbox(char* title, char* text, int def_but, .
|
||||
|
||||
msgbox* box = calloc(sizeof(msgbox), 1);
|
||||
box->retval = (uint8_t)def_but;
|
||||
char *pc = box->texts,
|
||||
*but_text = va_arg(vl, char*);
|
||||
char *pc = box->texts;
|
||||
strcpy(pc, title);
|
||||
pc += strlen(title) + 1;
|
||||
strcpy(pc, text);
|
||||
pc += strlen(text) + 1;
|
||||
|
||||
char *but_text = va_arg(vl, char*);
|
||||
while (but_text)
|
||||
{
|
||||
strcpy(pc, but_text);
|
||||
pc += strlen(but_text) + 1;
|
||||
// assert(pc - box->texts < sizeof box->texts);
|
||||
but_text = va_arg(vl, char*);
|
||||
}
|
||||
|
||||
va_end(vl);
|
||||
|
@ -1,71 +1,32 @@
|
||||
#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 все одного уровня)
|
||||
};
|
||||
|
||||
/// êîíñòàíòû äëÿ ôóíêöèé
|
||||
enum tl_err {
|
||||
TL_ERR_LOAD_CAPTION = 1, //â ïàìÿòè íåò çàãîëîâêà 'tree'
|
||||
TL_ERR_SAVE_MEMOTY_SIZE = 2, //íå õâàòàåò ïàìÿòè äëÿ ñîõðàíåíèÿ ýëåìåíòà
|
||||
TL_ERR_LOAD_INFO_SIZE = 4, //íå ñîâïàäàåò ðàçìåð èíôîðìàöèîííîé ñòðóêòóðû ïðè îòêðûòèè
|
||||
};
|
||||
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
uint16_t type; //òèï ýëåìåíòà, èëè èíäåêñ èêîíêè äëÿ óçëà
|
||||
uint8_t lev; //óðîâåíü ýëåìåíòà
|
||||
uint8_t clo; //ôëàã çàêðûòèÿ, èëè îòêðûòèÿ (èìååò ñìûñë äëÿ ðîäèòåëüñêîãî óçëà)
|
||||
uint32_t prev; //èíäåêñ ïðåäûäóùåãî ýëåìåíòà
|
||||
uint32_t next; //èíäåêñ ïîñëåäóþùåãî ýëåìåíòà
|
||||
uint32_t tcreat; //âðåì. ñîçäàíèÿ
|
||||
uint32_t tdel; //âðåì. óäàëåíèÿ
|
||||
} treelist_node;
|
||||
|
||||
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
uint32_t left;
|
||||
uint32_t top;
|
||||
@ -75,7 +36,7 @@ typedef struct __attribute__ ((__packed__)) {
|
||||
uint16_t info_size; // размер данных выделяемых для каждого узла (пользовательськие данные + текст для подписи)
|
||||
uint32_t info_max_count; // максимальное количество узлов, которые можно добавить в элемент
|
||||
uint32_t style; // стили элемента
|
||||
void *data_nodes; // óêàçàòåëü íà ñòðóêòóðû óçëîâ
|
||||
treelist_node *data_nodes; // óêàçàòåëü íà ñòðóêòóðû óçëîâ
|
||||
void *data_img; // указатель на изображения с иконками узлов
|
||||
uint16_t img_cx; // ширина иконок
|
||||
uint16_t img_cy; // высота иконок
|
||||
@ -84,23 +45,428 @@ typedef struct __attribute__ ((__packed__)) {
|
||||
uint32_t tim_undo; // количество отмененных действий
|
||||
uint32_t cur_pos; // позиция курсора
|
||||
color_t col_bkg; // цвет фона
|
||||
color_t tl_col_zag; // öâåò çàãîëîâêà
|
||||
color_t tl_col_txt; // öâåò òåêñòà
|
||||
color_t col_zag; // öâåò çàãîëîâêà
|
||||
color_t col_txt; // öâåò òåêñòà
|
||||
uint16_t capt_cy; // высота подписи
|
||||
uint16_t info_capt_offs;//сдвиг для начала текста (подписи узла)
|
||||
uint16_t info_capt_len;//длина текста подписи узла (если = 0 то до конца структуры)
|
||||
void *el_focus; // указатель на структуру элемента в фокусе
|
||||
void *p_scroll; // óêàçàòåëü íà ñòðóêòóðó ñêðîëëèíãà
|
||||
scrollbar *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 ;ðàçìåð çàãîëîâêà äëÿ çàïèñè/÷òåíèÿ ýëåìåíòîâ
|
||||
*/
|
||||
static inline treelist* kolibri_new_treelist( uint32_t x_w, uint32_t y_h, uint16_t capt_cy, uint32_t icon_size_xy, uint16_t info_size, uint32_t info_max_count,
|
||||
uint16_t info_capt_len, uint16_t info_capt_offs, enum tl_style style, void *el_focus, color_t back, color_t title, color_t txt)
|
||||
{
|
||||
treelist *tl = (treelist *)calloc(1, sizeof(treelist));
|
||||
tl->left= x_w >> 16;
|
||||
tl->width = x_w & 0xFFFF;
|
||||
tl->top = y_h >> 16;
|
||||
tl->height = y_h & 0xFFFF;
|
||||
tl->info_size = info_size;
|
||||
tl->info_max_count = info_max_count;
|
||||
tl->style = style;
|
||||
tl->img_cx = icon_size_xy >> 16;
|
||||
tl->img_cy = icon_size_xy & 0xFFFF;
|
||||
tl->col_bkg = back;
|
||||
tl->col_zag = title;
|
||||
tl->col_txt = txt;
|
||||
tl->info_capt_len = info_capt_len;
|
||||
tl->info_capt_offs = info_capt_offs;
|
||||
tl->el_focus = el_focus;
|
||||
tl->p_scroll = kolibri_new_scrollbar_def(X_Y(0, 16), X_Y(70, 30), 100, 30, 0);
|
||||
return tl;
|
||||
}
|
||||
|
||||
static inline void gui_add_treelist(kolibri_window *wnd, treelist* tl)
|
||||
{
|
||||
kolibri_window_add_element(wnd, KOLIBRI_TREELIST, tl);
|
||||
}
|
||||
|
||||
|
||||
///ðåàêöèÿ íà ìûøü
|
||||
extern void (*tl_mouse)(treelist *) __attribute__((__stdcall__));
|
||||
|
||||
///âûâîä ñïèñêà íà ýêðàí
|
||||
extern void (*tl_draw)(treelist *) __attribute__((__stdcall__));
|
||||
|
||||
///ïåðåìåùàåì óçåë ââåðõ
|
||||
extern void (*tl_node_move_up)(treelist *) __attribute__((__stdcall__));
|
||||
|
||||
///ïåðåìåùàåì óçåë âíèç
|
||||
extern void (*tl_node_move_down)(treelist *) __attribute__((__stdcall__));
|
||||
|
||||
extern void (*tl_data_init_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///âûäåëåíèå ïàìÿòè äëÿ ñòðóêòóð ñïèñêà è îñíîâíîé èíôîðìàöèè (êîíñòðóêòîð)
|
||||
static inline void treelist_data_init(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_data_init_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_data_clear_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///î÷èñòêà ïàìÿòè ýëåìåíòà (äåñòðóêòîð)
|
||||
static inline void treelist_data_clear(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_data_clear_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_info_clear_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///î÷èñòêà ñïèñêà (èíôîðìàöèè)
|
||||
static inline void treelist_info_clear(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_info_clear_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_key_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///ðåàêöèÿ íà êëàâèàòóðó
|
||||
static inline void treelist_key(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_key_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_info_undo_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///îòìåíà äåéñòâèÿ
|
||||
static inline void treelist_undo(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_info_undo_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_info_redo_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///ïîâòîð äåéñòâèÿ
|
||||
static inline void treelist_redo(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_info_redo_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_node_add_asm)(treelist *, uint32_t n_opt, void *n_info) __attribute__((__stdcall__));
|
||||
///äîáàâèòü óçåë
|
||||
///input:
|
||||
/// tlist - óêàçàòåëü íà ñòðóêòóðó ëèñòà
|
||||
/// n_opt - îïöèè äîáàâëåíèÿ
|
||||
/// n_info - óêàçàòåëü íà äîáàâëÿåìûå äàííûå
|
||||
static inline void treelist_node_add(treelist *tl, void *n_info, uint16_t type, uint8_t clos, uint8_t lev)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
uint32_t n_opt = (type << 16) | (clos << 8) | lev;
|
||||
(*tl_node_add_asm)(tl, n_opt, n_info);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_node_set_data_asm)(treelist *, void *n_info) __attribute__((__stdcall__));
|
||||
///çàïèñàòü â òåêóùèé óçåë
|
||||
///input:
|
||||
/// tlist - óêàçàòåëü íà ñòðóêòóðó ëèñòà
|
||||
/// n_info - óêàçàòåëü íà äàííûå
|
||||
static inline void treelist_node_setdata(treelist *tl, void *n_info)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%esi \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_node_set_data_asm)(tl, n_info);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%esi \n\t":::);
|
||||
}
|
||||
|
||||
extern void* (*tl_node_get_data_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///âçÿòü óêàçàòåëü íà äàííûå óçëà ïîä êóðñîðîì
|
||||
static inline void* treelist_getdata(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
void *res =
|
||||
(*tl_node_get_data_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
return res;
|
||||
}
|
||||
|
||||
extern void (*tl_node_delete_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///óäàëèòü óçåë ïîä êóðñîðîì
|
||||
static inline void treelist_node_delete(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_node_delete_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_cur_beg_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///ïîñòàâèòü êóðñîð íà ïåðâûé óçåë
|
||||
static inline void treelist_cursor_begin(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_cur_beg_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_cur_next_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///ïåðåíåñòè êóðñîð íà 1 ïîçèöèþ íèæå
|
||||
static inline void treelist_cursor_next(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%esi \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_cur_next_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%esi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_cur_perv_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///ïåðåíåñòè êóðñîð íà 1 ïîçèöèþ âûøå
|
||||
static inline void treelist_cursor_prev(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%esi \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_cur_perv_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%esi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_node_close_open_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///îòêðûòü/çàêðûòü óçåë (ðàáîòàåò ñ óçëàìè êîòîðûå èìåþò äî÷åðíèå óçëû)
|
||||
static inline void treelist_close_open(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_node_close_open_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_node_lev_inc_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///óâåëè÷èòü óðîâåíü
|
||||
static inline void treelist_level_inc(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_node_lev_inc_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*tl_node_lev_dec_asm)(treelist *) __attribute__((__stdcall__));
|
||||
///óìåíüøèòü óðîâåíü
|
||||
static inline void treelist_level_dec(treelist *tl)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
(*tl_node_lev_dec_asm)(tl);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
}
|
||||
|
||||
extern treelist_node* (*tl_node_poi_get_info_asm)(treelist *, int node_ind) __attribute__((__stdcall__));
|
||||
///âçÿòü óêàçàòåëü íà ñòðóêòóðó óçëà â óêàçàííîé ïîçèöèè
|
||||
///input:
|
||||
/// tlist - pointer to 'TreeList' struct
|
||||
/// node_ind - node index
|
||||
///output - pointer to node info or NULL
|
||||
static inline treelist_node* treelist_getnode(treelist *tl, int node_ind)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
treelist_node *ret =
|
||||
(*tl_node_poi_get_info_asm)(tl, node_ind);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern treelist_node* (*tl_node_poi_get_next_info_asm)(treelist *, treelist_node*) __attribute__((__stdcall__));
|
||||
///âçÿòü óêàçàòåëü íà ñëåäóùóþ ñòðóêòóðó óçëà
|
||||
///input:
|
||||
/// tlist - pointer to 'TreeList' struct
|
||||
/// node_p - node param struct
|
||||
///output - pointer to next node struct or NULL
|
||||
static inline treelist_node* treelist_getnode_next(treelist *tl, treelist_node* node)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
treelist_node *ret =
|
||||
(*tl_node_poi_get_next_info_asm)(tl, node);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void* (*_tl_node_poi_get_data_asm)(treelist *, treelist_node*) __attribute__((__stdcall__));
|
||||
///;âçÿòü óêàçàòåëü íà äàííûå óçëà
|
||||
///input:
|
||||
/// tlist - pointer to 'TreeList' struct
|
||||
/// node_p - node param struct
|
||||
///output - pointer
|
||||
static inline void* treelist_getnode_data(treelist *tl, treelist_node *node)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
void *ret =
|
||||
(*_tl_node_poi_get_data_asm)(tl, node);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t":::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern int (*tl_save_mem_asm)(treelist *, int opt, void *h_mem, int mem_size) __attribute__((__stdcall__));
|
||||
/// tlist - pointer to 'TreeList' struct
|
||||
/// opt - options: 0 - first element, 1 - add next element
|
||||
/// h_mem - pointer to memory
|
||||
/// mem_size - memory size
|
||||
///output - error code
|
||||
static inline int treelist_save2mem(treelist *tl, int opt, void *h_mem, int mem_size)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%esi \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
int ret =
|
||||
(*tl_save_mem_asm)(tl, opt, h_mem, mem_size);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%esi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern int (*_tl_load_mem_asm)(treelist *, int opt, void *h_mem, int mem_size) __attribute__((__stdcall__));
|
||||
/**input:
|
||||
; tlist - pointer to 'TreeList' struct
|
||||
; opt - options: element index + (2*(add mode)+(init mode)) shl 16, tl_load_mode_add equ 0x20000 ;îïöèÿ ñ÷èòûâàíèÿ â ðåæèìå äîáàâëåíèÿ èíôîðìàöèè
|
||||
; h_mem - pointer to memory
|
||||
; mem_size - memory size
|
||||
; ðàçìåð ïàìÿòè, ïîêà íå èñïîëüçóåòñÿ (íàçíà÷àëñÿ äëÿ êîíòðîëÿ)
|
||||
; äëÿ åãî èñïîëüçîâàíèÿ íóæíî äîðàáîòàòü ôóíêöèþ
|
||||
;output:
|
||||
; eax - error code
|
||||
;memory header format:
|
||||
; +0 - (4) 'tree'
|
||||
; +4 - (2) info size
|
||||
; +6 - (4) count nodes
|
||||
; +10 - (4) tlist style
|
||||
; +14 - (4) cursor pos
|
||||
; +18 - (2) info capt offs
|
||||
; +20 - (2) info capt len
|
||||
; +22 - (4) scroll pos
|
||||
;memory data format:
|
||||
; +26 - (info size + 8) * count nodes */
|
||||
static inline int treelist_load4mem(treelist *tl, int opt, void *h_mem, int mem_size)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%esi \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
int ret =
|
||||
(*_tl_load_mem_asm)(tl, opt, h_mem, mem_size);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%esi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern int (*tl_get_mem_size_asm)(treelist *, void *h_mem) __attribute__((__stdcall__));
|
||||
/// ;áåðåò ðàçìåð ïàìÿòè çàíÿòîé ôóíêöèåé tl_save_mem ïðè ñîõðàíåíèè ýëåìåíòîâ
|
||||
/// tlist - pointer to 'TreeList' struct
|
||||
/// h_mem - pointer to saved memory
|
||||
static inline int treelist_get_memsize(treelist *tl, void *h_mem)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push %%ebx \n\t"
|
||||
"push %%edi \n\t":::);
|
||||
|
||||
int ret =
|
||||
(*tl_get_mem_size_asm)(tl, h_mem);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop %%edi \n\t"
|
||||
"pop %%ebx \n\t":::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif //KOLIBRI_TREELIST_H
|
||||
|
Loading…
Reference in New Issue
Block a user