[project @ 2006-03-20 10:56:54 by rjek]

Source cleanup and true/false to TRUE/FALSE conversion for GTK plotters

svn path=/import/netsurf/; revision=2142
This commit is contained in:
Rob Kendrick 2006-03-20 10:56:54 +00:00
parent f519569474
commit dd6bb64347
3 changed files with 53 additions and 53 deletions

View File

@ -71,12 +71,12 @@ bool nsgtk_plot_rectangle(int x0, int y0, int width, int height,
{ {
nsgtk_set_colour(c); nsgtk_set_colour(c);
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
if (line_width == 0) if (line_width == 0)
line_width = 1; line_width = 1;
cairo_set_line_width(current_cr, line_width); cairo_set_line_width(current_cr, line_width);
cairo_rectangle(current_cr, x0, y0, width, height); cairo_rectangle(current_cr, x0, y0, width, height);
cairo_stroke(current_cr); cairo_stroke(current_cr);
#else #else
gdk_draw_rectangle(current_drawable, current_gc, gdk_draw_rectangle(current_drawable, current_gc,
FALSE, x0, y0, width, height); FALSE, x0, y0, width, height);
@ -90,18 +90,18 @@ bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width,
{ {
nsgtk_set_colour(c); nsgtk_set_colour(c);
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
if (width == 0) if (width == 0)
width = 1; width = 1;
cairo_set_line_width(current_cr, width); cairo_set_line_width(current_cr, width);
cairo_move_to(current_cr, x0, y0); cairo_move_to(current_cr, x0, y0);
cairo_line_to(current_cr, x1, y1); cairo_line_to(current_cr, x1, y1);
cairo_stroke(current_cr); cairo_stroke(current_cr);
#else #else
gdk_draw_line(current_drawable, current_gc, gdk_draw_line(current_drawable, current_gc,
x0, y0, x1, y1); x0, y0, x1, y1);
#endif #endif
return true; return true;
} }
@ -109,16 +109,16 @@ bool nsgtk_plot_polygon(int *p, unsigned int n, colour fill)
{ {
unsigned int i; unsigned int i;
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
nsgtk_set_colour(fill); nsgtk_set_colour(fill);
cairo_set_line_width(current_cr, 0); cairo_set_line_width(current_cr, 0);
cairo_move_to(current_cr, p[0], p[1]); cairo_move_to(current_cr, p[0], p[1]);
for (i = 1; i != n; i++) { for (i = 1; i != n; i++) {
cairo_line_to(current_cr, p[i * 2], p[i * 2 + 1]); cairo_line_to(current_cr, p[i * 2], p[i * 2 + 1]);
} }
cairo_fill(current_cr); cairo_fill(current_cr);
cairo_stroke(current_cr); cairo_stroke(current_cr);
#else #else
GdkPoint q[n]; GdkPoint q[n];
for (i = 0; i != n; i++) { for (i = 0; i != n; i++) {
q[i].x = p[i * 2]; q[i].x = p[i * 2];
q[i].y = p[i * 2 + 1]; q[i].y = p[i * 2 + 1];
@ -135,15 +135,15 @@ bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, colour c)
{ {
nsgtk_set_colour(c); nsgtk_set_colour(c);
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
cairo_set_line_width(current_cr, 0); cairo_set_line_width(current_cr, 0);
cairo_rectangle(current_cr, x0, y0, x1 - x0, y1 - y0); cairo_rectangle(current_cr, x0, y0, x1 - x0, y1 - y0);
cairo_fill(current_cr); cairo_fill(current_cr);
cairo_stroke(current_cr); cairo_stroke(current_cr);
#else #else
gdk_draw_rectangle(current_drawable, current_gc, gdk_draw_rectangle(current_drawable, current_gc,
TRUE, x0, y0, x1 - x0, y1 - y0); TRUE, x0, y0, x1 - x0, y1 - y0);
#endif #endif
return true; return true;
} }
@ -151,12 +151,12 @@ bool nsgtk_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1) int clip_x1, int clip_y1)
{ {
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
cairo_reset_clip(current_cr); cairo_reset_clip(current_cr);
cairo_rectangle(current_cr, clip_x0 - 1, clip_y0 - 1, cairo_rectangle(current_cr, clip_x0 - 1, clip_y0 - 1,
clip_x1 - clip_x0 + 1, clip_y1 - clip_y0 + 1); clip_x1 - clip_x0 + 1, clip_y1 - clip_y0 + 1);
cairo_clip(current_cr); cairo_clip(current_cr);
#endif #endif
cliprect.x = clip_x0; cliprect.x = clip_x0;
cliprect.y = clip_y0; cliprect.y = clip_y0;
cliprect.width = clip_x1 - clip_x0 + 1; cliprect.width = clip_x1 - clip_x0 + 1;
cliprect.height = clip_y1 - clip_y0 + 1; cliprect.height = clip_y1 - clip_y0 + 1;
@ -174,25 +174,25 @@ bool nsgtk_plot_text(int x, int y, struct css_style *style,
bool nsgtk_plot_disc(int x, int y, int radius, colour c, bool filled) bool nsgtk_plot_disc(int x, int y, int radius, colour c, bool filled)
{ {
nsgtk_set_colour(c); nsgtk_set_colour(c);
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
if (filled) if (filled)
cairo_set_line_width(current_cr, 0); cairo_set_line_width(current_cr, 0);
else else
cairo_set_line_width(current_cr, 1); cairo_set_line_width(current_cr, 1);
cairo_arc(current_cr, x, y, radius, 0, M_PI * 2); cairo_arc(current_cr, x, y, radius, 0, M_PI * 2);
if (filled) if (filled)
cairo_fill(current_cr); cairo_fill(current_cr);
cairo_stroke(current_cr); cairo_stroke(current_cr);
#else #else
gdk_draw_arc(current_drawable, current_gc, gdk_draw_arc(current_drawable, current_gc,
filled, x - (radius), y - radius, filled ? TRUE : FALSE, x - (radius), y - radius,
radius * 2, radius * 2, radius * 2, radius * 2,
0, 0,
360 * 64); 360 * 64);
#endif #endif
return true; return true;
} }
@ -303,6 +303,6 @@ void nsgtk_set_colour(colour c)
&colour); &colour);
gdk_gc_set_foreground(current_gc, &colour); gdk_gc_set_foreground(current_gc, &colour);
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
gdk_cairo_set_source_color(current_cr, &colour); gdk_cairo_set_source_color(current_cr, &colour);
#endif #endif
} }

View File

@ -184,7 +184,7 @@ gboolean gui_window_expose_event(GtkWidget *widget,
current_drawable = widget->window; current_drawable = widget->window;
current_gc = gdk_gc_new(current_drawable); current_gc = gdk_gc_new(current_drawable);
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
current_cr = gdk_cairo_create(current_drawable); current_cr = gdk_cairo_create(current_drawable);
#endif #endif
plot = nsgtk_plotters; plot = nsgtk_plotters;
@ -200,7 +200,7 @@ gboolean gui_window_expose_event(GtkWidget *widget,
g_object_unref(current_gc); g_object_unref(current_gc);
#ifdef CAIRO_VERSION #ifdef CAIRO_VERSION
cairo_destroy(current_cr); cairo_destroy(current_cr);
#endif #endif
return FALSE; return FALSE;

View File

@ -927,15 +927,15 @@ bool html_redraw_checkbox(int x, int y, int width, int height,
bool html_redraw_radio(int x, int y, int width, int height, bool html_redraw_radio(int x, int y, int width, int height,
bool selected) bool selected)
{ {
if (!plot.disc(x + width * 0.5, y + height * 0.5,
width * 0.5 - 1, 0xffffff, TRUE))
return false;
if (!plot.disc(x + width * 0.5, y + height * 0.5, if (!plot.disc(x + width * 0.5, y + height * 0.5,
width * 0.5 - 1, 0x000000, FALSE)) width * 0.5 - 1, 0xffffff, true))
return false;
if (!plot.disc(x + width * 0.5, y + height * 0.5,
width * 0.5 - 1, 0x000000, false))
return false; return false;
if (selected) if (selected)
if (!plot.disc(x + width * 0.5, y + height * 0.5, if (!plot.disc(x + width * 0.5, y + height * 0.5,
width * 0.3 - 1, 0x0000ff, TRUE)) width * 0.3 - 1, 0x0000ff, true))
return false; return false;
return true; return true;