|
@@ -33,8 +33,6 @@ GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index,
|
|
|
default_strip_chart_height),
|
|
default_strip_chart_height),
|
|
|
GtkStatsGraph(monitor)
|
|
GtkStatsGraph(monitor)
|
|
|
{
|
|
{
|
|
|
- _brush_origin = 0;
|
|
|
|
|
-
|
|
|
|
|
if (show_level) {
|
|
if (show_level) {
|
|
|
// If it's a level-type graph, show the appropriate units.
|
|
// If it's a level-type graph, show the appropriate units.
|
|
|
if (_unit_name.empty()) {
|
|
if (_unit_name.empty()) {
|
|
@@ -49,7 +47,7 @@ GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Put some stuff on top of the graph.
|
|
// Put some stuff on top of the graph.
|
|
|
- _top_hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
|
|
|
+ _top_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
|
|
gtk_box_pack_start(GTK_BOX(_graph_vbox), _top_hbox,
|
|
gtk_box_pack_start(GTK_BOX(_graph_vbox), _top_hbox,
|
|
|
FALSE, FALSE, 0);
|
|
FALSE, FALSE, 0);
|
|
|
|
|
|
|
@@ -66,12 +64,19 @@ GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index,
|
|
|
// Add a DrawingArea widget to the right of the graph, to display all of the
|
|
// Add a DrawingArea widget to the right of the graph, to display all of the
|
|
|
// scale units.
|
|
// scale units.
|
|
|
_scale_area = gtk_drawing_area_new();
|
|
_scale_area = gtk_drawing_area_new();
|
|
|
- g_signal_connect(G_OBJECT(_scale_area), "expose_event",
|
|
|
|
|
- G_CALLBACK(expose_event_callback), this);
|
|
|
|
|
|
|
+ g_signal_connect(G_OBJECT(_scale_area), "draw",
|
|
|
|
|
+ G_CALLBACK(draw_callback), this);
|
|
|
gtk_box_pack_start(GTK_BOX(_graph_hbox), _scale_area,
|
|
gtk_box_pack_start(GTK_BOX(_graph_hbox), _scale_area,
|
|
|
FALSE, FALSE, 0);
|
|
FALSE, FALSE, 0);
|
|
|
- gtk_widget_set_size_request(_scale_area, 40, 0);
|
|
|
|
|
|
|
|
|
|
|
|
+ // Make it wide enough to display a typical label.
|
|
|
|
|
+ {
|
|
|
|
|
+ PangoLayout *layout = gtk_widget_create_pango_layout(_window, "99 ms");
|
|
|
|
|
+ int width, height;
|
|
|
|
|
+ pango_layout_get_pixel_size(layout, &width, &height);
|
|
|
|
|
+ gtk_widget_set_size_request(_scale_area, width, 0);
|
|
|
|
|
+ g_object_unref(layout);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
gtk_widget_set_size_request(_graph_window, default_strip_chart_width,
|
|
gtk_widget_set_size_request(_graph_window, default_strip_chart_width,
|
|
|
default_strip_chart_height);
|
|
default_strip_chart_height);
|
|
@@ -177,7 +182,7 @@ set_scroll_speed(double scroll_speed) {
|
|
|
* Called when the user single-clicks on a label.
|
|
* Called when the user single-clicks on a label.
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
-clicked_label(int collector_index) {
|
|
|
|
|
|
|
+on_click_label(int collector_index) {
|
|
|
if (collector_index < 0) {
|
|
if (collector_index < 0) {
|
|
|
// Clicking on whitespace in the graph is the same as clicking on the top
|
|
// Clicking on whitespace in the graph is the same as clicking on the top
|
|
|
// label.
|
|
// label.
|
|
@@ -204,6 +209,15 @@ clicked_label(int collector_index) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Called when the mouse hovers over a label, and should return the text that
|
|
|
|
|
+ * should appear on the tooltip.
|
|
|
|
|
+ */
|
|
|
|
|
+std::string GtkStatsStripChart::
|
|
|
|
|
+get_label_tooltip(int collector_index) const {
|
|
|
|
|
+ return PStatStripChart::get_label_tooltip(collector_index);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Changes the value the height of the vertical axis represents. This may
|
|
* Changes the value the height of the vertical axis represents. This may
|
|
|
* force a redraw.
|
|
* force a redraw.
|
|
@@ -236,9 +250,8 @@ update_labels() {
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
clear_region() {
|
|
clear_region() {
|
|
|
- gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white);
|
|
|
|
|
- gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, 0, 0,
|
|
|
|
|
- get_xsize(), get_ysize());
|
|
|
|
|
|
|
+ cairo_set_source_rgb(_cr, 1.0, 1.0, 1.0);
|
|
|
|
|
+ cairo_paint(_cr);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -247,18 +260,29 @@ clear_region() {
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
copy_region(int start_x, int end_x, int dest_x) {
|
|
copy_region(int start_x, int end_x, int dest_x) {
|
|
|
- gdk_draw_drawable(_pixmap, _pixmap_gc, _pixmap,
|
|
|
|
|
- start_x, 0, dest_x, 0,
|
|
|
|
|
- end_x - start_x, get_ysize());
|
|
|
|
|
|
|
+ // We are not allowed to copy a surface onto itself, so we have to create a
|
|
|
|
|
+ // temporary surface to copy to.
|
|
|
|
|
+ end_x = std::min(end_x, get_xsize());
|
|
|
|
|
+ cairo_surface_t *temp_surface =
|
|
|
|
|
+ cairo_image_surface_create(CAIRO_FORMAT_RGB24, end_x - start_x, get_ysize());
|
|
|
|
|
+ {
|
|
|
|
|
+ cairo_t *temp_cr = cairo_create(temp_surface);
|
|
|
|
|
+ cairo_set_source_surface(temp_cr, _cr_surface, -start_x, 0);
|
|
|
|
|
+ cairo_paint(temp_cr);
|
|
|
|
|
+ cairo_destroy(temp_cr);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ cairo_set_source_surface(_cr, temp_surface, 0, 0);
|
|
|
|
|
+ cairo_rectangle(_cr, dest_x, 0, end_x - start_x, get_ysize());
|
|
|
|
|
+ cairo_fill(_cr);
|
|
|
|
|
|
|
|
- // Also shift the brush origin over, so we still get proper dithering.
|
|
|
|
|
- _brush_origin += (dest_x - start_x);
|
|
|
|
|
- // SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, NULL);
|
|
|
|
|
|
|
+ cairo_surface_destroy(temp_surface);
|
|
|
|
|
|
|
|
|
|
+ GdkWindow *window = gtk_widget_get_window(_graph_window);
|
|
|
GdkRectangle rect = {
|
|
GdkRectangle rect = {
|
|
|
dest_x, 0, end_x - start_x, get_ysize()
|
|
dest_x, 0, end_x - start_x, get_ysize()
|
|
|
};
|
|
};
|
|
|
- gdk_window_invalidate_rect(_graph_window->window, &rect, FALSE);
|
|
|
|
|
|
|
+ gdk_window_invalidate_rect(window, &rect, FALSE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -268,9 +292,9 @@ copy_region(int start_x, int end_x, int dest_x) {
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) {
|
|
draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) {
|
|
|
// Start by clearing the band first.
|
|
// Start by clearing the band first.
|
|
|
- gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white);
|
|
|
|
|
- gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0,
|
|
|
|
|
- w + 1, get_ysize());
|
|
|
|
|
|
|
+ cairo_set_source_rgb(_cr, 1.0, 1.0, 1.0);
|
|
|
|
|
+ cairo_rectangle(_cr, x, 0, w, get_ysize());
|
|
|
|
|
+ cairo_fill(_cr);
|
|
|
|
|
|
|
|
double overall_time = 0.0;
|
|
double overall_time = 0.0;
|
|
|
int y = get_ysize();
|
|
int y = get_ysize();
|
|
@@ -279,18 +303,21 @@ draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) {
|
|
|
for (fi = fdata.begin(); fi != fdata.end(); ++fi) {
|
|
for (fi = fdata.begin(); fi != fdata.end(); ++fi) {
|
|
|
const ColorData &cd = (*fi);
|
|
const ColorData &cd = (*fi);
|
|
|
overall_time += cd._net_value;
|
|
overall_time += cd._net_value;
|
|
|
- GdkGC *gc = get_collector_gc(cd._collector_index);
|
|
|
|
|
|
|
+ cairo_set_source(_cr, get_collector_pattern(cd._collector_index,
|
|
|
|
|
+ _highlighted_index == cd._collector_index));
|
|
|
|
|
|
|
|
if (overall_time > get_vertical_scale()) {
|
|
if (overall_time > get_vertical_scale()) {
|
|
|
// Off the top. Go ahead and clamp it by hand, in case it's so far off
|
|
// Off the top. Go ahead and clamp it by hand, in case it's so far off
|
|
|
// the top we'd overflow the 16-bit pixel value.
|
|
// the top we'd overflow the 16-bit pixel value.
|
|
|
- gdk_draw_rectangle(_pixmap, gc, TRUE, x, 0, w, y);
|
|
|
|
|
|
|
+ cairo_rectangle(_cr, x, 0, w, y);
|
|
|
|
|
+ cairo_fill(_cr);
|
|
|
// And we can consider ourselves done now.
|
|
// And we can consider ourselves done now.
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int top_y = height_to_pixel(overall_time);
|
|
int top_y = height_to_pixel(overall_time);
|
|
|
- gdk_draw_rectangle(_pixmap, gc, TRUE, x, top_y, w, y - top_y);
|
|
|
|
|
|
|
+ cairo_rectangle(_cr, x, top_y, w, y - top_y);
|
|
|
|
|
+ cairo_fill(_cr);
|
|
|
y = top_y;
|
|
y = top_y;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -300,9 +327,8 @@ draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) {
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
draw_empty(int x, int w) {
|
|
draw_empty(int x, int w) {
|
|
|
- gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white);
|
|
|
|
|
- gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0,
|
|
|
|
|
- w + 1, get_ysize());
|
|
|
|
|
|
|
+ cairo_set_source_rgb(_cr, 1.0, 1.0, 1.0);
|
|
|
|
|
+ cairo_rectangle(_cr, x, 0, w, get_ysize());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -310,8 +336,10 @@ draw_empty(int x, int w) {
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
draw_cursor(int x) {
|
|
draw_cursor(int x) {
|
|
|
- gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_black);
|
|
|
|
|
- gdk_draw_line(_pixmap, _pixmap_gc, x, 0, x, get_ysize());
|
|
|
|
|
|
|
+ cairo_set_source_rgb(_cr, 0.0, 0.0, 0.0);
|
|
|
|
|
+ cairo_move_to(_cr, x, 0);
|
|
|
|
|
+ cairo_line_to(_cr, x, get_ysize());
|
|
|
|
|
+ cairo_stroke(_cr);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -324,24 +352,25 @@ end_draw(int from_x, int to_x) {
|
|
|
// Draw in the guide bars.
|
|
// Draw in the guide bars.
|
|
|
int num_guide_bars = get_num_guide_bars();
|
|
int num_guide_bars = get_num_guide_bars();
|
|
|
for (int i = 0; i < num_guide_bars; i++) {
|
|
for (int i = 0; i < num_guide_bars; i++) {
|
|
|
- draw_guide_bar(_pixmap, from_x, to_x, get_guide_bar(i));
|
|
|
|
|
|
|
+ draw_guide_bar(_cr, from_x, to_x, get_guide_bar(i));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ GdkWindow *window = gtk_widget_get_window(_graph_window);
|
|
|
GdkRectangle rect = {
|
|
GdkRectangle rect = {
|
|
|
- from_x, 0, to_x - from_x + 1, get_ysize()
|
|
|
|
|
|
|
+ from_x, 0, to_x - from_x, get_ysize()
|
|
|
};
|
|
};
|
|
|
- gdk_window_invalidate_rect(_graph_window->window, &rect, FALSE);
|
|
|
|
|
|
|
+ gdk_window_invalidate_rect(window, &rect, FALSE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * This is called during the servicing of expose_event; it gives a derived
|
|
|
|
|
|
|
+ * This is called during the servicing of the draw event; it gives a derived
|
|
|
* class opportunity to do some further painting into the graph window.
|
|
* class opportunity to do some further painting into the graph window.
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
-additional_graph_window_paint() {
|
|
|
|
|
|
|
+additional_graph_window_paint(cairo_t *cr) {
|
|
|
int num_user_guide_bars = get_num_user_guide_bars();
|
|
int num_user_guide_bars = get_num_user_guide_bars();
|
|
|
for (int i = 0; i < num_user_guide_bars; i++) {
|
|
for (int i = 0; i < num_user_guide_bars; i++) {
|
|
|
- draw_guide_bar(_graph_window->window, 0, get_xsize(), get_user_guide_bar(i));
|
|
|
|
|
|
|
+ draw_guide_bar(cr, 0, get_xsize(), get_user_guide_bar(i));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -402,20 +431,23 @@ set_drag_mode(GtkStatsGraph::DragMode drag_mode) {
|
|
|
gboolean GtkStatsStripChart::
|
|
gboolean GtkStatsStripChart::
|
|
|
handle_button_press(GtkWidget *widget, int graph_x, int graph_y,
|
|
handle_button_press(GtkWidget *widget, int graph_x, int graph_y,
|
|
|
bool double_click) {
|
|
bool double_click) {
|
|
|
- if (double_click) {
|
|
|
|
|
- // Double-clicking on a color bar in the graph is the same as double-
|
|
|
|
|
- // clicking on the corresponding label.
|
|
|
|
|
- clicked_label(get_collector_under_pixel(graph_x, graph_y));
|
|
|
|
|
- return TRUE;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (graph_x >= 0 && graph_y >= 0 && graph_x < get_xsize() && graph_y < get_ysize()) {
|
|
|
|
|
+ if (double_click) {
|
|
|
|
|
+ // Double-clicking on a color bar in the graph is the same as double-
|
|
|
|
|
+ // clicking on the corresponding label.
|
|
|
|
|
+ on_click_label(get_collector_under_pixel(graph_x, graph_y));
|
|
|
|
|
+ return TRUE;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (_potential_drag_mode == DM_none) {
|
|
|
|
|
- set_drag_mode(DM_scale);
|
|
|
|
|
- _drag_scale_start = pixel_to_height(graph_y);
|
|
|
|
|
- // SetCapture(_graph_window);
|
|
|
|
|
- return TRUE;
|
|
|
|
|
|
|
+ if (_potential_drag_mode == DM_none) {
|
|
|
|
|
+ set_drag_mode(DM_scale);
|
|
|
|
|
+ _drag_scale_start = pixel_to_height(graph_y);
|
|
|
|
|
+ // SetCapture(_graph_window);
|
|
|
|
|
+ return TRUE;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- } else if (_potential_drag_mode == DM_guide_bar && _drag_guide_bar >= 0) {
|
|
|
|
|
|
|
+ if (_potential_drag_mode == DM_guide_bar && _drag_guide_bar >= 0) {
|
|
|
set_drag_mode(DM_guide_bar);
|
|
set_drag_mode(DM_guide_bar);
|
|
|
_drag_start_y = graph_y;
|
|
_drag_start_y = graph_y;
|
|
|
// SetCapture(_graph_window);
|
|
// SetCapture(_graph_window);
|
|
@@ -455,25 +487,17 @@ handle_button_release(GtkWidget *widget, int graph_x, int graph_y) {
|
|
|
*/
|
|
*/
|
|
|
gboolean GtkStatsStripChart::
|
|
gboolean GtkStatsStripChart::
|
|
|
handle_motion(GtkWidget *widget, int graph_x, int graph_y) {
|
|
handle_motion(GtkWidget *widget, int graph_x, int graph_y) {
|
|
|
- if (_drag_mode == DM_none && _potential_drag_mode == DM_none) {
|
|
|
|
|
|
|
+ if (_drag_mode == DM_none && _potential_drag_mode == DM_none &&
|
|
|
|
|
+ graph_x >= 0 && graph_y >= 0 && graph_x < get_xsize() && graph_y < get_ysize()) {
|
|
|
// When the mouse is over a color bar, highlight it.
|
|
// When the mouse is over a color bar, highlight it.
|
|
|
- _label_stack.highlight_label(get_collector_under_pixel(graph_x, graph_y));
|
|
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
- // Now we want to get a WM_MOUSELEAVE when the mouse leaves the graph
|
|
|
|
|
- // window.
|
|
|
|
|
- TRACKMOUSEEVENT tme = {
|
|
|
|
|
- sizeof(TRACKMOUSEEVENT),
|
|
|
|
|
- TME_LEAVE,
|
|
|
|
|
- _graph_window,
|
|
|
|
|
- 0
|
|
|
|
|
- };
|
|
|
|
|
- TrackMouseEvent(&tme);
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ int collector_index = get_collector_under_pixel(graph_x, graph_y);
|
|
|
|
|
+ _label_stack.highlight_label(collector_index);
|
|
|
|
|
+ on_enter_label(collector_index);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
// If the mouse is in some drag mode, stop highlighting.
|
|
// If the mouse is in some drag mode, stop highlighting.
|
|
|
_label_stack.highlight_label(-1);
|
|
_label_stack.highlight_label(-1);
|
|
|
|
|
+ on_leave_label(_highlighted_index);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (_drag_mode == DM_scale) {
|
|
if (_drag_mode == DM_scale) {
|
|
@@ -504,7 +528,7 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) {
|
|
|
* Draws the line for the indicated guide bar on the graph.
|
|
* Draws the line for the indicated guide bar on the graph.
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
-draw_guide_bar(GdkDrawable *surface, int from_x, int to_x,
|
|
|
|
|
|
|
+draw_guide_bar(cairo_t *cr, int from_x, int to_x,
|
|
|
const PStatGraph::GuideBar &bar) {
|
|
const PStatGraph::GuideBar &bar) {
|
|
|
int y = height_to_pixel(bar._height);
|
|
int y = height_to_pixel(bar._height);
|
|
|
|
|
|
|
@@ -512,42 +536,44 @@ draw_guide_bar(GdkDrawable *surface, int from_x, int to_x,
|
|
|
// Only draw it if it's not too close to the top.
|
|
// Only draw it if it's not too close to the top.
|
|
|
switch (bar._style) {
|
|
switch (bar._style) {
|
|
|
case GBS_target:
|
|
case GBS_target:
|
|
|
- gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_light_gray);
|
|
|
|
|
|
|
+ cairo_set_source_rgb(cr, rgb_light_gray[0], rgb_light_gray[1], rgb_light_gray[2]);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case GBS_user:
|
|
case GBS_user:
|
|
|
- gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_user_guide_bar);
|
|
|
|
|
|
|
+ cairo_set_source_rgb(cr, rgb_user_guide_bar[0], rgb_user_guide_bar[1], rgb_user_guide_bar[2]);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case GBS_normal:
|
|
case GBS_normal:
|
|
|
- gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_dark_gray);
|
|
|
|
|
|
|
+ cairo_set_source_rgb(cr, rgb_dark_gray[0], rgb_dark_gray[1], rgb_dark_gray[2]);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- gdk_draw_line(surface, _pixmap_gc, from_x, y, to_x, y);
|
|
|
|
|
|
|
+ cairo_move_to(cr, from_x, y);
|
|
|
|
|
+ cairo_line_to(cr, to_x, y);
|
|
|
|
|
+ cairo_stroke(cr);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * This is called during the servicing of expose_event.
|
|
|
|
|
|
|
+ * This is called during the servicing of the draw event.
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsStripChart::
|
|
void GtkStatsStripChart::
|
|
|
-draw_guide_labels() {
|
|
|
|
|
|
|
+draw_guide_labels(cairo_t *cr) {
|
|
|
// Draw in the labels for the guide bars.
|
|
// Draw in the labels for the guide bars.
|
|
|
int last_y = -100;
|
|
int last_y = -100;
|
|
|
|
|
|
|
|
int i;
|
|
int i;
|
|
|
int num_guide_bars = get_num_guide_bars();
|
|
int num_guide_bars = get_num_guide_bars();
|
|
|
for (i = 0; i < num_guide_bars; i++) {
|
|
for (i = 0; i < num_guide_bars; i++) {
|
|
|
- last_y = draw_guide_label(get_guide_bar(i), last_y);
|
|
|
|
|
|
|
+ last_y = draw_guide_label(cr, get_guide_bar(i), last_y);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
GuideBar top_value = make_guide_bar(get_vertical_scale());
|
|
GuideBar top_value = make_guide_bar(get_vertical_scale());
|
|
|
- draw_guide_label(top_value, last_y);
|
|
|
|
|
|
|
+ draw_guide_label(cr, top_value, last_y);
|
|
|
|
|
|
|
|
last_y = -100;
|
|
last_y = -100;
|
|
|
int num_user_guide_bars = get_num_user_guide_bars();
|
|
int num_user_guide_bars = get_num_user_guide_bars();
|
|
|
for (i = 0; i < num_user_guide_bars; i++) {
|
|
for (i = 0; i < num_user_guide_bars; i++) {
|
|
|
- last_y = draw_guide_label(get_user_guide_bar(i), last_y);
|
|
|
|
|
|
|
+ last_y = draw_guide_label(cr, get_user_guide_bar(i), last_y);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -557,20 +583,18 @@ draw_guide_labels() {
|
|
|
* value is given. Returns the top pixel value of the new label.
|
|
* value is given. Returns the top pixel value of the new label.
|
|
|
*/
|
|
*/
|
|
|
int GtkStatsStripChart::
|
|
int GtkStatsStripChart::
|
|
|
-draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) {
|
|
|
|
|
- GdkGC *gc = gdk_gc_new(_scale_area->window);
|
|
|
|
|
-
|
|
|
|
|
|
|
+draw_guide_label(cairo_t *cr, const PStatGraph::GuideBar &bar, int last_y) {
|
|
|
switch (bar._style) {
|
|
switch (bar._style) {
|
|
|
case GBS_target:
|
|
case GBS_target:
|
|
|
- gdk_gc_set_rgb_fg_color(gc, &rgb_light_gray);
|
|
|
|
|
|
|
+ cairo_set_source_rgb(cr, rgb_light_gray[0], rgb_light_gray[1], rgb_light_gray[2]);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case GBS_user:
|
|
case GBS_user:
|
|
|
- gdk_gc_set_rgb_fg_color(gc, &rgb_user_guide_bar);
|
|
|
|
|
|
|
+ cairo_set_source_rgb(cr, rgb_user_guide_bar[0], rgb_user_guide_bar[1], rgb_user_guide_bar[2]);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case GBS_normal:
|
|
case GBS_normal:
|
|
|
- gdk_gc_set_rgb_fg_color(gc, &rgb_dark_gray);
|
|
|
|
|
|
|
+ cairo_set_source_rgb(cr, rgb_dark_gray[0], rgb_dark_gray[1], rgb_dark_gray[2]);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -587,7 +611,6 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) {
|
|
|
if (find_user_guide_bar(from_height, to_height) >= 0) {
|
|
if (find_user_guide_bar(from_height, to_height) >= 0) {
|
|
|
// Omit the label: there's a user-defined guide bar in the same space.
|
|
// Omit the label: there's a user-defined guide bar in the same space.
|
|
|
g_object_unref(layout);
|
|
g_object_unref(layout);
|
|
|
- g_object_unref(gc);
|
|
|
|
|
return last_y;
|
|
return last_y;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -603,13 +626,13 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) {
|
|
|
|
|
|
|
|
int this_y = y - height / 2;
|
|
int this_y = y - height / 2;
|
|
|
if (last_y < this_y || last_y > this_y + height) {
|
|
if (last_y < this_y || last_y > this_y + height) {
|
|
|
- gdk_draw_layout(_scale_area->window, gc, 0, this_y, layout);
|
|
|
|
|
|
|
+ cairo_move_to(cr, 0, this_y);
|
|
|
|
|
+ pango_cairo_show_layout(cr, layout);
|
|
|
last_y = this_y;
|
|
last_y = this_y;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
g_object_unref(layout);
|
|
g_object_unref(layout);
|
|
|
- g_object_unref(gc);
|
|
|
|
|
return last_y;
|
|
return last_y;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -628,9 +651,9 @@ toggled_callback(GtkToggleButton *button, gpointer data) {
|
|
|
* Draws in the scale labels.
|
|
* Draws in the scale labels.
|
|
|
*/
|
|
*/
|
|
|
gboolean GtkStatsStripChart::
|
|
gboolean GtkStatsStripChart::
|
|
|
-expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
|
|
|
|
|
|
|
+draw_callback(GtkWidget *widget, cairo_t *cr, gpointer data) {
|
|
|
GtkStatsStripChart *self = (GtkStatsStripChart *)data;
|
|
GtkStatsStripChart *self = (GtkStatsStripChart *)data;
|
|
|
- self->draw_guide_labels();
|
|
|
|
|
|
|
+ self->draw_guide_labels(cr);
|
|
|
|
|
|
|
|
return TRUE;
|
|
return TRUE;
|
|
|
}
|
|
}
|