From 58eecf4a1081e153d03f3a1bbff956f477a5b735 Mon Sep 17 00:00:00 2001 From: yangxx Date: Fri, 9 Jan 2004 21:06:45 +0000 Subject: [PATCH] main window resize and scroll bar function git-svn-id: http://ltt.polymtl.ca/svn@366 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/include/lttv/mainWindow.h | 1 + .../lttv/modules/gui/mainWin/src/callbacks.c | 36 ++++++++++++++++++- .../lttv/modules/gui/mainWin/src/callbacks.h | 4 +++ .../modules/gui/mainWin/src/gtkmultivpaned.c | 26 ++++++++++++-- .../lttv/modules/gui/mainWin/src/interface.c | 3 ++ 5 files changed, 66 insertions(+), 4 deletions(-) diff --git a/ltt/branches/poly/include/lttv/mainWindow.h b/ltt/branches/poly/include/lttv/mainWindow.h index 01bbb9de..4103f726 100644 --- a/ltt/branches/poly/include/lttv/mainWindow.h +++ b/ltt/branches/poly/include/lttv/mainWindow.h @@ -28,6 +28,7 @@ typedef struct _TracesetInfo { struct _MainWindow{ GtkWidget* mwindow; /* Main Window */ + int window_width; /* Status bar information */ // guint MainSBarContextID; /* Context ID of main status bar */ diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c index cce4dc42..000efdf0 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c @@ -134,7 +134,7 @@ void insert_viewer(GtkWidget* widget, view_constructor constructor) GtkWidget * viewer; LttvTracesetSelector * s; TimeInterval * time_interval; - TimeWindow time_window; + TimeWindow time_window, t; mw_data = get_window_data_struct(widget); if(!mw_data->current_tab) return; @@ -151,12 +151,16 @@ void insert_viewer(GtkWidget* widget, view_constructor constructor) time_window = mw_data->current_tab->time_window; time_interval = (TimeInterval*)g_object_get_data(G_OBJECT(viewer), TRACESET_TIME_SPAN); if(time_interval){ + t = time_window; time_window.start_time = time_interval->startTime; time_window.time_width = ltt_time_sub(time_interval->endTime,time_interval->startTime); } redraw_viewer(mw_data,&time_window); set_current_time(mw_data,&(mw_data->current_tab->current_time)); + if(time_interval){ + set_time_window(mw_data,&t); + } } } @@ -1108,6 +1112,36 @@ on_MWindow_destroy (GtkObject *object, gtk_main_quit (); } +gboolean +on_MWindow_configure (GtkWidget *widget, + GdkEventConfigure *event, + gpointer user_data) +{ + MainWindow * mw_data = get_window_data_struct((GtkWidget*)widget); + float width = event->width; + Tab * tab = mw_data->tab; + TimeWindow time_win; + double ratio; + TimeInterval *time_span; + LttTime time; + + while(tab){ + if(mw_data->window_width){ + time_span = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->Time_Span ; + time_win = tab->time_window; + ratio = width / mw_data->window_width; + tab->time_window.time_width = ltt_time_mul(time_win.time_width,ratio); + time = ltt_time_sub(time_span->endTime, time_win.start_time); + if(ltt_time_compare(time, tab->time_window.time_width) < 0){ + tab->time_window.time_width = time; + } + } + tab = tab->next; + } + + mw_data->window_width = (int)width; + return FALSE; +} void on_MNotebook_switch_page (GtkNotebook *notebook, diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.h b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.h index 6efc450f..c170ace1 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.h +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.h @@ -204,6 +204,10 @@ void on_MWindow_destroy (GtkObject *object, gpointer user_data); +gboolean +on_MWindow_configure (GtkWidget *widget, + GdkEventConfigure *event, + gpointer user_data); void on_insert_viewer_test_activate (GtkMenuItem *menuitem, diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkmultivpaned.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkmultivpaned.c index 454351ed..10ca915f 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkmultivpaned.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkmultivpaned.c @@ -366,12 +366,32 @@ void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned) void gtk_multi_vpaned_scroll_value_changed(GtkRange *range, gpointer multi_vpaned_arg) { + TimeWindow time_window; + TimeInterval *time_span; LttTime time; GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*)multi_vpaned_arg; gdouble value = gtk_range_get_value(range); - time = ltt_time_from_double(value / NANOSECONDS_PER_SECOND); - set_current_time(multi_vpaned->mw, &time); - g_warning("The current time is second :%d, nanosecond : %d\n", time.tv_sec, time.tv_nsec); + gdouble upper, lower, ratio; + + time_window = multi_vpaned->mw->current_tab->time_window; + + time_span = LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->traceset_info-> + traceset_context)->Time_Span ; + lower = multi_vpaned->hadjust->lower; + upper = multi_vpaned->hadjust->upper; + ratio = (value - lower) / (upper - lower); + + time = ltt_time_sub(time_span->endTime, time_span->startTime); + time = ltt_time_mul(time, (float)ratio); + time = ltt_time_add(time_span->startTime, time); + + time_window.start_time = time; + + time = ltt_time_sub(time_span->endTime, time); + if(ltt_time_compare(time,time_window.time_width) < 0){ + time_window.time_width = time; + } + set_time_window(multi_vpaned->mw, &time_window); } diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c index a749a721..c9e4f040 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c @@ -560,6 +560,9 @@ create_MWindow (void) g_signal_connect ((gpointer) MWindow, "destroy", G_CALLBACK (on_MWindow_destroy), NULL); + g_signal_connect ((gpointer) MWindow, "configure-event", + G_CALLBACK (on_MWindow_configure), + NULL); // g_signal_connect ((gpointer) EmptyTraceset, "activate", // G_CALLBACK (on_empty_traceset_activate), // NULL); -- 2.34.1