void GLUI_FileBrowser::dir_list_callback(GLUI_Control *glui_object) { GLUI_List *list = dynamic_cast<GLUI_List*>(glui_object); if (!list) return; GLUI_FileBrowser* me = dynamic_cast<GLUI_FileBrowser*>(list->associated_object); if (!me) return; int this_item; const char *selected; this_item = list->get_current_item(); if (this_item > 0) { /* file or directory selected */ selected = list->get_item_ptr( this_item )->text.c_str(); if (selected[0] == '/' || selected[0] == '\\') { if (me->allow_change_dir) { #ifdef __GNUC__ chdir(selected+1); #endif #ifdef _WIN32 SetCurrentDirectory(selected+1); #endif me->fbreaddir("."); } } else { me->file = selected; me->execute_callback(); } } }
void GLUI_List::scrollbar_callback(GLUI_Control *my_scrollbar) { GLUI_Scrollbar *sb = dynamic_cast<GLUI_Scrollbar*>(my_scrollbar); if (!sb) return; GLUI_List* me = (GLUI_List*) sb->associated_object; if (me->scrollbar == NULL) return; int new_start_line = sb->get_int_val(); // TODO!! me->start_line = new_start_line; if ( me->can_draw() ) me->update_and_draw_text(); }
void GLUI_FileBrowser::dir_list_callback(GLUI_Control *glui_object) { GLUI_List *list = dynamic_cast<GLUI_List*>(glui_object); if (!list) return; GLUI_FileBrowser* me = dynamic_cast<GLUI_FileBrowser*>(list->associated_object); if (!me) return; int this_item; const char *selected; this_item = list->get_current_item(); if (this_item > 0) { /* file or directory selected */ selected = list->get_item_ptr( this_item )->text.c_str(); //if (selected[0] == '/' || selected[0] == '\\') { //arreglo segun http://sourceforge.net/p/glui/patches/8/ int last=strlen(selected)-1; if (selected[last] == '/' || selected[last] == '\\') { if (me->allow_change_dir) { #ifdef _WIN32 SetCurrentDirectory(selected); //SetCurrentDirectory(selected+1); #else chdir(selected); //chdir(selected+1); #endif me->fbreaddir("."); } } else { me->file = selected; me->execute_callback(); } } }