Closes #143: DrawSelection -> src/, Chart.selection_style.

This commit is contained in:
Kolan Sh 2017-12-17 01:20:07 +03:00
parent a8d5b1658a
commit 5402757336
2 changed files with 12 additions and 12 deletions

View File

@ -18,8 +18,6 @@ namespace Gtk.CairoChart {
public Series[] series = {};
protected LineStyle selection_style = LineStyle ();
public Chart () {
bg_color = Color (1, 1, 1);
}
@ -463,6 +461,14 @@ namespace Gtk.CairoChart {
process_legend (LegendProcessType.DRAW);
}
public LineStyle selection_style = LineStyle ();
public virtual void draw_selection (double x0, double y0, double x1, double y1) {
set_line_style (selection_style);
context.rectangle (x0, y0, x1 - x0, y1 - y0);
context.stroke();
}
protected int axis_rec_npoints = 128;
protected virtual void calc_axis_rec_sizes (Axis axis, out double max_rec_width, out double max_rec_height, bool is_horizontal = true) {

View File

@ -244,6 +244,8 @@ int main (string[] args) {
plot_chart3 (chart3);
plot_chart4 (chart4);
chart1.selection_style = LineStyle(Color(0.3, 0.3, 0.3, 0.7), 1);
var da = new DrawingArea();
da.set_events ( Gdk.EventMask.BUTTON_PRESS_MASK
|Gdk.EventMask.BUTTON_RELEASE_MASK
@ -418,16 +420,8 @@ int main (string[] args) {
/*var ret = */chart.draw();
// user's post draw operations here...
if (mouse_state == MouseState.DRAW_SELECTION) {
context.set_source_rgba (0.5, 0.5, 0.5, 0.7);
context.set_line_join(Cairo.LineJoin.MITER);
context.set_line_cap(Cairo.LineCap.ROUND);
context.set_line_width(1);
//context.set_dash(null, 0);
context.rectangle (sel_x0, sel_y0, sel_x1 - sel_x0, sel_y1 - sel_y0);
//context.fill();
context.stroke();
}
if (mouse_state == MouseState.DRAW_SELECTION)
chart.draw_selection (sel_x0, sel_y0, sel_x1, sel_y1);
return true;//ret;
});