diff --git a/pandatool/src/gtk-stats/gtkStatsGuide.cxx b/pandatool/src/gtk-stats/gtkStatsGuide.cxx index 3b892fa092..8ed41f9ef6 100644 --- a/pandatool/src/gtk-stats/gtkStatsGuide.cxx +++ b/pandatool/src/gtk-stats/gtkStatsGuide.cxx @@ -33,10 +33,7 @@ GtkStatsGuide(PStatStripChart *chart) : // Choose a suitable minimum width. This requires knowing what the // font will be. - Gdk_GC fg_gc = - get_style()->gtkobj()->fg_gc[GTK_WIDGET_STATE (GTK_WIDGET(gtkobj()))]; - - Gdk_Font font = fg_gc.get_font(); + Gdk_Font font = get_style()->gtkobj()->font; int text_width = font.string_width("0000"); set_usize(text_width, 0); } @@ -67,21 +64,23 @@ expose_event_impl(GdkEventExpose *event) { Gdk_GC bg_gc = get_style()->gtkobj()->bg_gc[GTK_WIDGET_STATE (GTK_WIDGET(gtkobj()))]; - Gdk_Window window = get_window(); - window.draw_rectangle(bg_gc, true, 0, 0, width(), height()); - - Gdk_Font font = fg_gc.get_font(); - int text_ascent = font.ascent(); - - int num_guide_bars = _chart->get_num_guide_bars(); - for (int i = 0; i < num_guide_bars; i++) { - const PStatStripChart::GuideBar &bar = _chart->get_guide_bar(i); - int y = _chart->height_to_pixel(bar._height); - - if (y >= 5) { - // Only draw it if it's not too close to the top. - window.draw_string(font, fg_gc, 0, y + text_ascent / 2, - bar._label); + if (fg_gc && bg_gc) { + Gdk_Window window = get_window(); + window.draw_rectangle(bg_gc, true, 0, 0, width(), height()); + + Gdk_Font font = fg_gc.get_font(); + int text_ascent = font.ascent(); + + int num_guide_bars = _chart->get_num_guide_bars(); + for (int i = 0; i < num_guide_bars; i++) { + const PStatStripChart::GuideBar &bar = _chart->get_guide_bar(i); + int y = _chart->height_to_pixel(bar._height); + + if (y >= 5) { + // Only draw it if it's not too close to the top. + window.draw_string(font, fg_gc, 0, y + text_ascent / 2, + bar._label); + } } } diff --git a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx index ee3d100fe1..536f36fef9 100644 --- a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx +++ b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx @@ -119,9 +119,7 @@ void GtkStatsPianoRoll:: begin_draw() { _pixmap.draw_rectangle(_white_gc, true, 0, 0, get_xsize(), get_ysize()); - Gdk_GC fg_gc = - get_style()->gtkobj()->fg_gc[GTK_WIDGET_STATE (GTK_WIDGET(gtkobj()))]; - Gdk_Font font = fg_gc.get_font(); + Gdk_Font font = get_style()->gtkobj()->font; int text_height = font.height(); // Draw in the guide bars. @@ -167,9 +165,7 @@ end_draw() { // Draw in the labels for the guide bars. We do this in end_draw() // instead of in begin_draw() so the labels will appear on top of // any of the color bars. - Gdk_GC fg_gc = - get_style()->gtkobj()->fg_gc[GTK_WIDGET_STATE (GTK_WIDGET(gtkobj()))]; - Gdk_Font font = fg_gc.get_font(); + Gdk_Font font = get_style()->gtkobj()->font; int text_ascent = font.ascent(); int num_guide_bars = get_num_guide_bars(); @@ -277,10 +273,7 @@ pack_labels() { _label_box->show(); _label_align->add(*_label_box); - Gdk_GC window_gc = - get_style()->gtkobj()->fg_gc[GTK_WIDGET_STATE (GTK_WIDGET(gtkobj()))]; - Gdk_Font font = window_gc.get_font(); - + Gdk_Font font = get_style()->gtkobj()->font; int num_labels = get_num_labels(); while ((int)_y_positions.size() < num_labels) { diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx index e59089ebae..4d798ba2fe 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx @@ -374,9 +374,7 @@ pack_labels() { _label_box->show(); _label_align->add(*_label_box); - Gdk_GC window_gc = - get_style()->gtkobj()->fg_gc[GTK_WIDGET_STATE (GTK_WIDGET(gtkobj()))]; - Gdk_Font font = window_gc.get_font(); + Gdk_Font font = get_style()->gtkobj()->font; int num_labels = get_num_labels(); for (int i = 0; i < num_labels; i++) { @@ -384,12 +382,12 @@ pack_labels() { GtkStatsLabel *label = new GtkStatsLabel(get_monitor(), collector_index, font); label->show(); - + label->collector_picked.connect(collector_picked.slot()); - + _label_box->pack_end(*manage(label), false, false); } - + _labels_changed = false; }