From b54812a97e9cfe8aec3c2d6d6cc496395f33107f Mon Sep 17 00:00:00 2001 From: siemargl Date: Tue, 20 Sep 2016 00:42:12 +0000 Subject: [PATCH] fix bugs in pathview git-svn-id: svn://kolibrios.org@6526 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/C_Layer/ASM/loadboxlib.asm | 4 +-- .../C_Layer/EXAMPLE/libguic_kolibri/Makefile | 2 +- .../EXAMPLE/libguic_kolibri/dbutton_files.c | 33 ++++++++++++------- .../EXAMPLE/libguic_kolibri/scroll_progress.c | 2 +- .../C_Layer/INCLUDE/kolibri_gui_elements.h | 2 +- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/contrib/C_Layer/ASM/loadboxlib.asm b/contrib/C_Layer/ASM/loadboxlib.asm index 76aacb18b6..875216e43f 100644 --- a/contrib/C_Layer/ASM/loadboxlib.asm +++ b/contrib/C_Layer/ASM/loadboxlib.asm @@ -87,8 +87,8 @@ import lib_boxlib, \ tl_save_mem, 'tl_save_mem' , \ tl_load_mem, 'tl_load_mem' , \ tl_get_mem_size, 'tl_get_mem_size' , \ - path_show_prepare, 'pathshow_prepare' , \ - path_show_draw, 'pathshow_draw' , \ + path_show_prepare, 'PathShow_prepare' , \ + path_show_draw, 'PathShow_draw' , \ ted_but_sumb_upper, 'ted_but_sumb_upper' , \ ted_but_sumb_lover, 'ted_but_sumb_lover' , \ ted_but_convert_by_table, 'ted_but_convert_by_table' , \ diff --git a/contrib/C_Layer/EXAMPLE/libguic_kolibri/Makefile b/contrib/C_Layer/EXAMPLE/libguic_kolibri/Makefile index 4e12bc5aa2..015ffca4e5 100644 --- a/contrib/C_Layer/EXAMPLE/libguic_kolibri/Makefile +++ b/contrib/C_Layer/EXAMPLE/libguic_kolibri/Makefile @@ -36,7 +36,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) + $(LD) $(LIBPATH) --subsystem native -o $@ $^ $(OBJPATH)/loadboxlib.obj $(OBJPATH)/loadproclib.obj $(OBJPATH)/loadlibimg.obj $(LDFLAGS) -Map=dbutton_files.map kos32-objcopy $@ -O binary %.o : %.c Makefile diff --git a/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c b/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c index 45744568f4..308e35b969 100644 --- a/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c +++ b/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c @@ -22,8 +22,9 @@ #include "kolibri_libimg.h" char temp_path[4096]; +char** sys_path = (char**)0x20; // hack - get path from KOS header -int main() +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 @@ -44,9 +45,14 @@ int main() // load image for buttons const int icon_rgb_size = 16*16*3; // every icons 16x16 24bpp char *image_data_rgb = malloc(icon_rgb_size * 3), - *image_data; + *image_data, *pc; // make full path + argv - FILE *ficon = fopen("reload_16x16_8b.png", "rb"); + strcpy(temp_path, *sys_path); + pc = strrchr(temp_path, '/'); + if (pc) pc[1] = 0; + strcat(temp_path, "reload_16x16_8b.png"); + debug_board_write_str(temp_path); + FILE *ficon = fopen(temp_path, "rb"); if (!ficon) { debug_board_write_str("no icons file reload_16x16_8b.png "); @@ -72,19 +78,19 @@ int main() pict_button tbar[3]; gui_add_pict_button(main_window, kolibri_pict_button(&tbar[0], X_Y(10, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); - gui_add_pict_button(main_window, kolibri_pict_button(&tbar[1], X_Y(20, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); - gui_add_pict_button(main_window, kolibri_pict_button(&tbar[2], X_Y(30, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); + gui_add_pict_button(main_window, kolibri_pict_button(&tbar[1], X_Y(35, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); + gui_add_pict_button(main_window, kolibri_pict_button(&tbar[2], X_Y(60, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); statictext labels[3]; // tips gui_add_statictext(main_window, kolibri_statictext_def(&labels[0], X_Y(5, 28), "Open")); - gui_add_statictext(main_window, kolibri_statictext_def(&labels[1], X_Y(20, 28), "Save")); - gui_add_statictext(main_window, kolibri_statictext_def(&labels[2], X_Y(30, 28), "Select Dir")); + gui_add_statictext(main_window, kolibri_statictext_def(&labels[1], X_Y(35, 28), "Save")); + gui_add_statictext(main_window, kolibri_statictext_def(&labels[2], X_Y(65, 28), "Select Dir")); open_dialog *dlg_opensave = kolibri_new_open_dialog(OPEN, 10, 10, 420, 320); (*OpenDialog_init)(dlg_opensave); pathview pview; - gui_add_pathview(main_window, kolibri_pathview(&pview, X_Y(10, 40), 330, 0, 0, dlg_opensave->openfile_path, temp_path, 0, 0)); // black font, no background + gui_add_pathview(main_window, kolibri_pathview(&pview, X_Y(10, 50), 330, 1, 0, dlg_opensave->openfile_path, temp_path, 0, 0)); // black font, no background, font 1 do /* Start of main activity loop */ { @@ -118,16 +124,19 @@ int main() tbar[0].click = 0; dlg_opensave->mode = OPEN; (*OpenDialog_start)(dlg_opensave); - if (dlg_opensave->status != 2 && dlg_opensave->status != 1) // fail or cancel + //debug_board_printf("status == %d, buf = %s\n", dlg_opensave->status, dlg_opensave->openfile_path); + if (dlg_opensave->status != 2 && dlg_opensave->status != 0) // fail or cancel + { (*path_show_prepare)(&pview); - kolibri_handle_event_redraw(main_window); + (*path_show_draw)(&pview); + } } if(tbar[1].click) // save { tbar[1].click = 0; dlg_opensave->mode = SAVE; (*OpenDialog_start)(dlg_opensave); - if (dlg_opensave->status != 2 && dlg_opensave->status != 1) // fail or cancel + if (dlg_opensave->status != 2 && dlg_opensave->status != 0) // fail or cancel (*path_show_prepare)(&pview); kolibri_handle_event_redraw(main_window); } @@ -136,7 +145,7 @@ int main() tbar[2].click = 0; dlg_opensave->mode = SELECT; (*OpenDialog_start)(dlg_opensave); - if (dlg_opensave->status != 2 && dlg_opensave->status != 1) // fail or cancel + if (dlg_opensave->status != 2 && dlg_opensave->status != 0) // fail or cancel (*path_show_prepare)(&pview); kolibri_handle_event_redraw(main_window); } diff --git a/contrib/C_Layer/EXAMPLE/libguic_kolibri/scroll_progress.c b/contrib/C_Layer/EXAMPLE/libguic_kolibri/scroll_progress.c index a964e5b904..b43c6ae6dc 100644 --- a/contrib/C_Layer/EXAMPLE/libguic_kolibri/scroll_progress.c +++ b/contrib/C_Layer/EXAMPLE/libguic_kolibri/scroll_progress.c @@ -91,7 +91,7 @@ int main() statictext *txt = kolibri_new_statictext_def(X_Y(10, 20), "StaticText default 6x9. Use Arrows or PgUp/PgDn"); statictext *txt2 = kolibri_new_statictext(X_Y(10, 30), "StaticText 8x16 x2:", CP866, 1, kolibri_color_table.color_work_text, 0); staticnum *num = kolibri_new_staticnum_def(X_Y(10 + (strlen("StaticText 8x16 x2:") + 2) * 8 * 2, 30), 3, value); - scrollbar *sbh = kolibri_new_scrollbar(X_Y(30, 300), X_Y(370, 5), 15, 100, 10, value, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, 0); + scrollbar *sbh = kolibri_new_scrollbar(X_Y(30, 300), X_Y(350, 15), 15, 100, 10, value, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, 0); scrollbar *sbv = kolibri_new_scrollbar(X_Y(370, 15), X_Y(40, 300), 15, 100, 10, value, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, 0); progressbar *pg = kolibri_new_progressbar(0, 100, value, 10, 70, 200, 20); diff --git a/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h b/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h index a818689934..1e48e9c064 100644 --- a/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h +++ b/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h @@ -147,7 +147,7 @@ debug_board_printf("KOLIBRI_D_BUTTON (%x,%x,%x)\n", dynamic_button_draw, dynamic kolibri_gui_op_table[KOLIBRI_PATHSHOW].redraw_fn = (cb_elem_boxlib)path_show_draw; kolibri_gui_op_table[KOLIBRI_PATHSHOW].mouse_fn = NULL; kolibri_gui_op_table[KOLIBRI_PATHSHOW].key_fn = NULL; -debug_board_printf("KOLIBRI_PATHSHOW (%x,%x,%x)\n", path_show_draw, 0, 0); +debug_board_printf("KOLIBRI_PATHSHOW (%x,%x,%x)\n", path_show_draw, 0, path_show_prepare); } /* Create a new main GUI window for KolibriOS */