main window resize and scroll bar function
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 9 Jan 2004 21:06:45 +0000 (21:06 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 9 Jan 2004 21:06:45 +0000 (21:06 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@366 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/include/lttv/mainWindow.h
ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.h
ltt/branches/poly/lttv/modules/gui/mainWin/src/gtkmultivpaned.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c

index 01bbb9de3c41820a17881fe8758708745588d276..4103f72698076f49b0d47dd2ab8b6d9e50b956e5 100644 (file)
@@ -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 */
index cce4dc4283c83196ca2d14c2241ddbd58a71c0fe..000efdf017fe4b87acb3129e9fb99d1e3fe1bdd1 100644 (file)
@@ -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,
index 6efc450f10422ce8cf994916d09270806e580224..c170ace16960b51edea3a93aef62eae47685ed06 100644 (file)
@@ -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,
index 454351ed90170da701131607aaa730db545b5296..10ca915fab88684426dbd66841d68aec00760eb2 100644 (file)
@@ -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); 
 }
 
 
index a749a721fbcd4809e516dc0017336bd14e68c77b..c9e4f040edb8034450e25717c0c71747e2ae24a2 100644 (file)
@@ -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);
This page took 0.029938 seconds and 4 git commands to generate.