add modal show support on filelist view.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@173 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
8142c88001
commit
a55b0d6abe
|
@ -454,19 +454,19 @@ rt_bool_t filelist_view_event_handler(struct rtgui_widget* widget, struct rtgui_
|
|||
strncpy(new_path, view->current_directory, ptr - view->current_directory + 1);
|
||||
new_path[ptr - view->current_directory] = '\0';
|
||||
}
|
||||
rt_kprintf("new path: %s\n", new_path);
|
||||
}
|
||||
else if (view->current_item == 0 &&
|
||||
(view->current_directory[0] == '/') && (view->current_directory[1] == '\0'))
|
||||
{
|
||||
/* exit, close this view */
|
||||
rtgui_workbench_t* workbench;
|
||||
if (RTGUI_VIEW(view)->modal_show == RT_TRUE)
|
||||
{
|
||||
rtgui_view_end_modal(RTGUI_VIEW(view), RTGUI_MODAL_CANCEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
filelist_view_destroy(view);
|
||||
}
|
||||
|
||||
workbench = RTGUI_WORKBENCH(RTGUI_WIDGET(view)->parent);
|
||||
rtgui_workbench_remove_view(workbench, RTGUI_VIEW(view));
|
||||
filelist_view_destroy(view);
|
||||
|
||||
filelist_view = RT_NULL;
|
||||
return RT_FALSE;
|
||||
}
|
||||
else
|
||||
|
@ -482,20 +482,9 @@ rt_bool_t filelist_view_event_handler(struct rtgui_widget* widget, struct rtgui_
|
|||
}
|
||||
else
|
||||
{
|
||||
if (strstr(view->items[view->current_item].name, ".HDC") != RT_NULL ||
|
||||
strstr(view->items[view->current_item].name, ".hdc") != RT_NULL)
|
||||
if (RTGUI_VIEW(view)->modal_show == RT_TRUE)
|
||||
{
|
||||
char new_path[64];
|
||||
rtgui_workbench_t* workbench;
|
||||
|
||||
workbench = RTGUI_WORKBENCH(RTGUI_WIDGET(view)->parent);
|
||||
|
||||
if (view->current_directory[strlen(view->current_directory) - 1] != PATH_SEPARATOR)
|
||||
sprintf(new_path, "%s%c%s",view->current_directory, PATH_SEPARATOR,
|
||||
view->items[view->current_item].name);
|
||||
else
|
||||
sprintf(new_path, "%s%s",view->current_directory,
|
||||
view->items[view->current_item].name);
|
||||
rtgui_view_end_modal(RTGUI_VIEW(view), RTGUI_MODAL_OK);
|
||||
}
|
||||
}
|
||||
return RT_FALSE;
|
||||
|
|
|
@ -38,6 +38,7 @@ struct rtgui_view
|
|||
|
||||
/* private field */
|
||||
char* title;
|
||||
rt_bool_t modal_show;
|
||||
};
|
||||
typedef struct rtgui_view rtgui_view_t;
|
||||
|
||||
|
|
|
@ -22,11 +22,24 @@ static void _rtgui_view_constructor(rtgui_view_t *view)
|
|||
rtgui_widget_set_event_handler(RTGUI_WIDGET(view),
|
||||
rtgui_view_event_handler);
|
||||
|
||||
view->modal_show = RT_FALSE;
|
||||
view->title = RT_NULL;
|
||||
}
|
||||
|
||||
static void _rtgui_view_destructor(rtgui_view_t *view)
|
||||
{
|
||||
/* remove view from workbench */
|
||||
if (RTGUI_WIDGET(view)->parent != RT_NULL)
|
||||
{
|
||||
rtgui_workbench_t *workbench;
|
||||
|
||||
if (view->modal_show == RT_TRUE)
|
||||
rtgui_view_end_modal(view, RTGUI_MODAL_CANCEL);
|
||||
|
||||
workbench = RTGUI_WORKBENCH(RTGUI_WIDGET(view)->parent);
|
||||
rtgui_workbench_remove_view(workbench, view);
|
||||
}
|
||||
|
||||
if (view->title != RT_NULL)
|
||||
{
|
||||
rt_free(view->title);
|
||||
|
|
Loading…
Reference in New Issue