Skip to content
Snippets Groups Projects
Commit 81fc468e authored by rds's avatar rds
Browse files

navigator packed into scrolled window

parent 9f7e91a3
No related branches found
No related tags found
No related merge requests found
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* *
* Exported functions: See zmapControl_P.h * Exported functions: See zmapControl_P.h
* HISTORY: * HISTORY:
* Last edited: Oct 18 16:48 2006 (rds) * Last edited: Nov 8 08:32 2006 (rds)
* Created: Thu Jul 8 12:54:27 2004 (edgrif) * Created: Thu Jul 8 12:54:27 2004 (edgrif)
* CVS info: $Id: zmapControlNavigator.c,v 1.26 2006-10-19 13:15:18 rds Exp $ * CVS info: $Id: zmapControlNavigator.c,v 1.27 2006-11-08 08:35:45 rds Exp $
*------------------------------------------------------------------- *-------------------------------------------------------------------
*/ */
...@@ -65,138 +65,88 @@ static void canvasValueCB(gpointer user_data, double top, double bottom) ...@@ -65,138 +65,88 @@ static void canvasValueCB(gpointer user_data, double top, double bottom)
ZMapNavigator zMapNavigatorCreate(GtkWidget **top_widg_out, GtkWidget **canvas_out) ZMapNavigator zMapNavigatorCreate(GtkWidget **top_widg_out, GtkWidget **canvas_out)
{ {
ZMapNavigator navigator ; ZMapNavigator navigator ;
GtkWidget *pane ;
GtkObject *adjustment ; GtkObject *adjustment ;
GtkWidget *label ; GtkWidget *pane, *label,
*locator_frame = NULL,
navigator = g_new0(ZMapNavStruct, 1); *locator_canvas = NULL,
*locator_vbox = NULL,
navigator->pane = pane = gtk_hpaned_new() ; *locator_label = NULL,
*locator_sw = NULL;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE ZMapWindowNavigatorCallbackStruct cbs = {NULL};
gtk_widget_set_size_request(pane, 100, -1) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ if((navigator = g_new0(ZMapNavStruct, 1)))
{
navigator->pane = pane = gtk_hpaned_new() ;
/* Construct the region locator. */
/* Construct the region locator. */
/* Need a vbox so we can add a label with sequence size at the bottom later,
* we set it to a fixed width so that the text is always visible. */ /* Need a vbox so we can add a label with sequence size at the bottom later,
navigator->navVBox = gtk_vbox_new(FALSE, 0); * we set it to a fixed width so that the text is always visible. */
gtk_paned_add1(GTK_PANED(pane), navigator->navVBox) ; navigator->navVBox = gtk_vbox_new(FALSE, 0);
gtk_paned_add1(GTK_PANED(pane), navigator->navVBox) ;
label = gtk_label_new("Region") ;
gtk_box_pack_start(GTK_BOX(navigator->navVBox), label, FALSE, TRUE, 0); label = gtk_label_new("Region") ;
gtk_box_pack_start(GTK_BOX(navigator->navVBox), label, FALSE, TRUE, 0);
navigator->topLabel = gtk_label_new(TOPTEXT_NO_SCALE) ;
gtk_box_pack_start(GTK_BOX(navigator->navVBox), navigator->topLabel, FALSE, TRUE, 0); navigator->topLabel = gtk_label_new(TOPTEXT_NO_SCALE) ;
gtk_box_pack_start(GTK_BOX(navigator->navVBox), navigator->topLabel, FALSE, TRUE, 0);
/* Make the navigator with a default, "blank" adjustment obj. */
adjustment = gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ; /* Make the navigator with a default, "blank" adjustment obj. */
adjustment = gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ;
navigator->navVScroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustment)) ;
gtk_box_pack_start(GTK_BOX(navigator->navVBox), navigator->navVScroll, TRUE, TRUE, 0) ; navigator->navVScroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustment)) ;
gtk_box_pack_start(GTK_BOX(navigator->navVBox), navigator->navVScroll, TRUE, TRUE, 0) ;
/* Note how we pack the label at the end of the vbox and set "expand" to FALSE so that it
* remains small and the vscale expands to fill the rest of the box. */ /* Note how we pack the label at the end of the vbox and set "expand" to FALSE so that it
navigator->botLabel = gtk_label_new(BOTTEXT_NO_SCALE) ; * remains small and the vscale expands to fill the rest of the box. */
gtk_box_pack_end(GTK_BOX(navigator->navVBox), navigator->botLabel, FALSE, TRUE, 0); navigator->botLabel = gtk_label_new(BOTTEXT_NO_SCALE) ;
gtk_box_pack_end(GTK_BOX(navigator->navVBox), navigator->botLabel, FALSE, TRUE, 0);
/* Construct the window locator. Note that we set the update policy to discontinuous so if
* user drags this scroll bar the position is only reported on button release. This is /* Construct the window locator ... */
* necessary because the underlying canvas window cannot be remapped rapidly. */ locator_vbox = gtk_vbox_new(FALSE, 0);
navigator->wind_vbox = gtk_vbox_new(FALSE, 0);
/* A label */
{ locator_label = gtk_label_new("Scroll Navigator") ;
GtkWidget *locator_frame = NULL, gtk_box_pack_start(GTK_BOX(locator_vbox), locator_label, FALSE, TRUE, 0);
*locator_canvas = NULL,
*locator_pane = NULL, /* A frame */
*locator_vbox = NULL, locator_frame = gtk_frame_new(NULL);
*locator_label = NULL, gtk_frame_set_shadow_type(GTK_FRAME(locator_frame), GTK_SHADOW_NONE);
*event_box = NULL, gtk_box_pack_start(GTK_BOX(locator_vbox), locator_frame, TRUE, TRUE, 0);
*event_label = NULL;
ZMapWindowNavigatorCallbackStruct cbs = {NULL}; /* A canvas */
cbs.valueCB = canvasValueCB;
#ifdef RDS_USE_SCROLL locator_canvas = navigator->locator_widget =
locator_pane = gtk_hpaned_new(); zMapWindowNavigatorCreateCanvas(&cbs, navigator);
gtk_paned_add2(GTK_PANED(pane), locator_pane) ; /* add this pane to main pane */
locator_sw = gtk_scrolled_window_new(NULL, NULL);
gtk_paned_add1(GTK_PANED(locator_pane), navigator->wind_vbox) ; /* add scroll to this pane */ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(locator_sw),
#endif /* RDS_USE_SCROLL */ GTK_POLICY_ALWAYS, GTK_POLICY_NEVER);
gtk_container_add(GTK_CONTAINER(locator_sw), locator_canvas);
locator_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(locator_frame), locator_sw);
gtk_container_set_border_width(GTK_CONTAINER(locator_frame), 2);
#ifdef RDS_USE_SCROLL
gtk_paned_add2(GTK_PANED(locator_pane), locator_vbox) ; /* add locusnav to this pane */ /* pack into the pane */
#else gtk_paned_add2(GTK_PANED(pane), locator_vbox) ;
gtk_paned_add2(GTK_PANED(pane), locator_vbox) ; /* add locusnav to this pane */
#endif /* RDS_USE_SCROLL */ #ifdef RDS_DONT_INCLUDE_UNUSED
g_object_connect(G_OBJECT(pane),
locator_label = gtk_label_new("Scroll Navigator") ; "signal::notify::position",
gtk_box_pack_start(GTK_BOX(locator_vbox), locator_label, FALSE, TRUE, 0); G_CALLBACK(paneNotifyPositionCB),
(gpointer)navigator,
locator_frame = gtk_frame_new(NULL); NULL);
gtk_frame_set_shadow_type(GTK_FRAME(locator_frame), GTK_SHADOW_NONE); #endif
gtk_box_pack_start(GTK_BOX(locator_vbox), locator_frame, TRUE, TRUE, 0);
/* Set left hand (region view) pane closed by default. */
cbs.valueCB = canvasValueCB; gtk_paned_set_position(GTK_PANED(pane), 0) ;
locator_canvas = navigator->locator_widget =
zMapWindowNavigatorCreateCanvas(&cbs, navigator); if(canvas_out)
*canvas_out = locator_canvas;
gtk_container_add(GTK_CONTAINER(locator_frame), locator_canvas); if(top_widg_out)
*top_widg_out = pane ;
event_box = gtk_event_box_new(); }
/* gtk_widget_set_name(event_box, "zmap-control-infopanel"); */
gtk_box_pack_start(GTK_BOX(locator_vbox), event_box, FALSE, FALSE, 2);
event_label = gtk_label_new("drag box to navigate");
gtk_label_set_selectable(GTK_LABEL(event_label), TRUE);
gtk_container_add(GTK_CONTAINER(event_box), event_label);
#ifdef RDS_USE_SCROLL
g_object_connect(G_OBJECT(pane),
"signal::notify::position",
G_CALLBACK(paneNotifyPositionCB),
(gpointer)navigator,
NULL);
#endif
if(canvas_out)
*canvas_out = locator_canvas;
}
#ifdef RDS_USE_SCROLL
label = gtk_label_new("Scroll") ;
gtk_box_pack_start(GTK_BOX(navigator->wind_vbox), label, FALSE, TRUE, 0);
navigator->wind_top_label = gtk_label_new(TOPTEXT_NO_SCALE) ;
gtk_box_pack_start(GTK_BOX(navigator->wind_vbox), navigator->wind_top_label, FALSE, TRUE, 0);
adjustment = gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ; /* "blank" adjustment obj. */
#ifdef RDS_DONT_INCLUDE_UNUSED
gtk_signal_connect(GTK_OBJECT(adjustment), "value-changed",
GTK_SIGNAL_FUNC(valueCB), (void *)navigator) ;
#endif /* RDS_DONT_INCLUDE_UNUSED */
navigator->wind_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustment)) ;
gtk_range_set_update_policy(GTK_RANGE(navigator->wind_scroll), GTK_UPDATE_DISCONTINUOUS) ;
gtk_box_pack_start(GTK_BOX(navigator->wind_vbox), navigator->wind_scroll, TRUE, TRUE, 0) ;
/* Note how we pack the label at the end of the vbox and set "expand" to FALSE so that it
* remains small and the vscale expands to fill the rest of the box. */
navigator->wind_bot_label = gtk_label_new(BOTTEXT_NO_SCALE) ;
gtk_box_pack_end(GTK_BOX(navigator->wind_vbox), navigator->wind_bot_label, FALSE, TRUE, 0);
#endif /* RDS_USE_SCROLL */
navigator->wind_top = navigator->wind_bot = 0.0 ;
/* Set left hand (region view) pane closed by default. */
gtk_paned_set_position(GTK_PANED(pane), 0) ;
*top_widg_out = pane ;
return navigator ; return navigator ;
} }
...@@ -225,38 +175,15 @@ void zMapNavigatorSetWindowCallback(ZMapNavigator navigator, ...@@ -225,38 +175,15 @@ void zMapNavigatorSetWindowCallback(ZMapNavigator navigator,
int zMapNavigatorSetWindowPos(ZMapNavigator navigator, double top_pos, double bot_pos) int zMapNavigatorSetWindowPos(ZMapNavigator navigator, double top_pos, double bot_pos)
{ {
int pane_width = 0 ; int pane_width = 0 ;
GtkAdjustment *window_adjuster ;
double w, h; double w, h;
enum {PANED_WINDOW_GUTTER_SIZE = 10} ; /* There is no simple way to get this. */ enum {PANED_WINDOW_GUTTER_SIZE = 10} ; /* There is no simple way to get this. */
#ifdef RDS_USE_SCROLL zMapWindowNavigatorPackDimensions(navigator->locator_widget, &w, &h);
/* Set the new scrollbar size. */
window_adjuster = (GtkAdjustment *)gtk_range_get_adjustment(GTK_RANGE(navigator->wind_scroll)) ;
window_adjuster->value = top_pos ; pane_width = (int)fabs(w);
window_adjuster->page_size = (gdouble)(fabs(bot_pos - top_pos) + 1) ; if(pane_width > 0)
pane_width += PANED_WINDOW_GUTTER_SIZE;
gtk_adjustment_changed(window_adjuster) ;
/* find out if page_size is smaller than max pane size....if so then return width of window
navigator box, otherwise return 0 so the window navigator will not be visible. */
// if (window_adjuster->page_size < (window_adjuster->upper - window_adjuster->lower + 1))
{
GtkRequisition box_size ;
gtk_widget_size_request(GTK_WIDGET(navigator->wind_vbox), &box_size) ;
pane_width = box_size.width + PANED_WINDOW_GUTTER_SIZE ;
}
#endif /* RDS_USE_SCROLL */
{
zMapWindowNavigatorPackDimensions(navigator->locator_widget, &w, &h);
pane_width = (int)fabs(w);
if(pane_width > 0)
pane_width += PANED_WINDOW_GUTTER_SIZE;
}
return pane_width; return pane_width;
} }
...@@ -269,9 +196,6 @@ void zMapNavigatorSetView(ZMapNavigator navigator, ZMapFeatureContext features, ...@@ -269,9 +196,6 @@ void zMapNavigatorSetView(ZMapNavigator navigator, ZMapFeatureContext features,
GtkObject *region_adjuster, *window_adjuster ; GtkObject *region_adjuster, *window_adjuster ;
gchar *region_top_str, *region_bot_str, *window_top_str, *window_bot_str ; gchar *region_top_str, *region_bot_str, *window_top_str, *window_bot_str ;
region_adjuster = (GtkObject *)gtk_range_get_adjustment(GTK_RANGE(navigator->navVScroll)) ; region_adjuster = (GtkObject *)gtk_range_get_adjustment(GTK_RANGE(navigator->navVScroll)) ;
#ifdef RDS_USE_SCROLL
window_adjuster = (GtkObject *)gtk_range_get_adjustment(GTK_RANGE(navigator->wind_scroll)) ;
#endif /* RDS_USE_SCROLL */
/* May be called with no sequence to parent mapping so must set default navigator for this. */ /* May be called with no sequence to parent mapping so must set default navigator for this. */
if (features) if (features)
...@@ -294,16 +218,6 @@ void zMapNavigatorSetView(ZMapNavigator navigator, ZMapFeatureContext features, ...@@ -294,16 +218,6 @@ void zMapNavigatorSetView(ZMapNavigator navigator, ZMapFeatureContext features,
window_top_str = g_strdup_printf("%d", navigator->sequence_to_parent.c1) ; window_top_str = g_strdup_printf("%d", navigator->sequence_to_parent.c1) ;
window_bot_str = g_strdup_printf("%d", navigator->sequence_to_parent.c2) ; window_bot_str = g_strdup_printf("%d", navigator->sequence_to_parent.c2) ;
#ifdef RDS_USE_SCROLL
/* I assume here that we start at the top. */
GTK_ADJUSTMENT(window_adjuster)->value = (0.0) ;
GTK_ADJUSTMENT(window_adjuster)->lower = (gdouble)navigator->sequence_to_parent.c1 ;
GTK_ADJUSTMENT(window_adjuster)->upper = (gdouble)navigator->sequence_to_parent.c2 ;
GTK_ADJUSTMENT(window_adjuster)->step_increment = 0.0 ;
GTK_ADJUSTMENT(window_adjuster)->page_increment = 0.0 ;
GTK_ADJUSTMENT(window_adjuster)->page_size = (gdouble)(fabs(navigator->sequence_to_parent.c2
- navigator->sequence_to_parent.c1) + 1) ;
#endif /* RDS_USE_SCROLL */
zMapNavigatorSetWindowPos(navigator, top, bottom) ; zMapNavigatorSetWindowPos(navigator, top, bottom) ;
} }
else else
...@@ -325,32 +239,16 @@ void zMapNavigatorSetView(ZMapNavigator navigator, ZMapFeatureContext features, ...@@ -325,32 +239,16 @@ void zMapNavigatorSetView(ZMapNavigator navigator, ZMapFeatureContext features,
window_top_str = g_strdup(TOPTEXT_NO_SCALE) ; window_top_str = g_strdup(TOPTEXT_NO_SCALE) ;
window_bot_str = g_strdup(BOTTEXT_NO_SCALE) ; window_bot_str = g_strdup(BOTTEXT_NO_SCALE) ;
#ifdef RDS_USE_SCROLL
GTK_ADJUSTMENT(window_adjuster)->value = 0.0 ;
GTK_ADJUSTMENT(window_adjuster)->lower = 0.0 ;
GTK_ADJUSTMENT(window_adjuster)->upper = 0.0 ;
GTK_ADJUSTMENT(window_adjuster)->step_increment = 0.0 ;
GTK_ADJUSTMENT(window_adjuster)->page_increment = 0.0 ;
GTK_ADJUSTMENT(window_adjuster)->page_size = 0.0 ;
#endif /* RDS_USE_SCROLL */
} }
gtk_adjustment_changed(GTK_ADJUSTMENT(region_adjuster)) ; gtk_adjustment_changed(GTK_ADJUSTMENT(region_adjuster)) ;
#ifdef RDS_USE_SCROLL
gtk_adjustment_changed(GTK_ADJUSTMENT(window_adjuster)) ;
#endif /* RDS_USE_SCROLL */
gtk_label_set_text(GTK_LABEL(navigator->topLabel), region_top_str) ; gtk_label_set_text(GTK_LABEL(navigator->topLabel), region_top_str) ;
gtk_label_set_text(GTK_LABEL(navigator->botLabel), region_bot_str) ; gtk_label_set_text(GTK_LABEL(navigator->botLabel), region_bot_str) ;
g_free(region_top_str) ; g_free(region_top_str) ;
g_free(region_bot_str) ; g_free(region_bot_str) ;
#ifdef RDS_USE_SCROLL
gtk_label_set_text(GTK_LABEL(navigator->wind_top_label), window_top_str) ;
gtk_label_set_text(GTK_LABEL(navigator->wind_bot_label), window_bot_str) ;
g_free(window_top_str) ;
g_free(window_bot_str) ;
#endif /* RDS_USE_SCROLL */
return ; return ;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment