Skip to content

Commit

Permalink
Work on example test programs. Adding migration to gtk+3.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchilds committed Jul 22, 2012
1 parent aabe2cf commit cb30972
Show file tree
Hide file tree
Showing 14 changed files with 11,745 additions and 126 deletions.
2 changes: 0 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ MAINTAINERCLEANFILES=Makefile.in configure =
pkgconfigdir=$(libdir)/pkgconfig
pkgconfig_DATA=gtkplot-${PLOT_API_VERSION}.pc

##notrans_dist_man3_MANS=plot:linear.3 plot:polar.3



3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ AC_SUBST([LT_CURRENT], [gtkplot_lt_current])
AC_SUBST([LT_REVISION], [gtkplot_lt_revision])
AC_SUBST([LT_AGE], [gtkplot_lt_age])
AC_SUBST([PLOT_API_VERSION], [gtk_major_dependency.gtk_api_revision])
AC_SUBST([PLOT_GTK_MAJOR], [gtk_major_dependency])
AC_SUBST([PLOT_GTK_VERSION], [gtk_req])
AC_SUBST([PLOT_SDIR], [sdir])
lt_enable_auto_import=""
Expand All @@ -35,5 +36,5 @@ case "$host_os" in
esac
AC_SUBST([lt_enable_auto_import])
PKG_CHECK_MODULES([PLOT], [gtk_req])
AC_CONFIG_FILES([Makefile ${PLOT_SDIR}/Makefile gtkplot-${PLOT_API_VERSION}.pc])
AC_CONFIG_FILES([Makefile ${PLOT_SDIR}/Makefile gtkplot-${PLOT_API_VERSION}.pc:gtkplot.pc.in])
AC_OUTPUT()
38 changes: 26 additions & 12 deletions gtk2plot/gtkplotlinear.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ static void drawz(GtkWidget *widget, cairo_t *cr)
{
gint xw;
gdouble dt;
GtkAllocation alloc;
GtkPlotLinear *plot;

xw=(widget->allocation.width);
gtk_widget_get_allocation(widget, &alloc);
xw=alloc.width;
plot=GTK_PLOT_LINEAR(widget);
cairo_set_source_rgba(cr, 0, 0, 0, 1);
cairo_set_line_width(cr, 1);
Expand Down Expand Up @@ -157,6 +159,7 @@ static void draw(GtkWidget *widget, cairo_t *cr)
{
GtkPlotLinearPrivate *priv;
GtkPlotLinear *plot;
GtkAllocation alloc;
gint j, k, xw, yw, xr, xr2, yr, yr2, xa, ya, xl, yl, xu, yu, tf, tz, to, tn, tnn, xv, yv, xvn, yvn, dtt, tx, wd, hg, ft, lt, xt;
gdouble vv, wv, zv, av, dt, lr1, lr2, delx, dely;
guint lr3;
Expand All @@ -168,8 +171,9 @@ static void draw(GtkWidget *widget, cairo_t *cr)
{mtr2.xx=0; mtr2.xy=1; mtr2.yx=-1; mtr2.yy=0; mtr2.x0=0; mtr2.y0=0;}/* initialise */
{mtr3.xx=0; mtr3.xy=-1; mtr3.yx=1; mtr3.yy=0; mtr3.x0=0; mtr3.y0=0;}
plot=GTK_PLOT_LINEAR(widget);
xw=(widget->allocation.width);
yw=(widget->allocation.height);
gtk_widget_get_allocation(widget, &alloc);
xw=alloc.width;
yw=(alloc.height);
priv=GTK_PLOT_LINEAR_GET_PRIVATE(plot);
(priv->flaga)&=(GTK_PLOT_LINEAR_AXES_LT|GTK_PLOT_LINEAR_AXES_LR);
delx=((priv->bounds.xmax)-(priv->bounds.xmin))/(priv->ticks.xj);
Expand Down Expand Up @@ -3564,11 +3568,13 @@ static void draw(GtkWidget *widget, cairo_t *cr)
static void gtk_plot_linear_redraw(GtkWidget *widget)
{
GdkRegion *region;
GdkWindow *wdw;

if (!(widget->window)) return;
region=gdk_drawable_get_clip_region(widget->window);
gdk_window_invalidate_region((widget->window), region, TRUE);
gdk_window_process_updates((widget->window), TRUE);
wdw=gtk_widget_get_window(widget);
if (!wdw) return;
region=gdk_drawable_get_clip_region(wdw);
gdk_window_invalidate_region(wdw, region, TRUE);
gdk_window_process_updates(wdw, TRUE);
gdk_region_destroy(region);
}

Expand Down Expand Up @@ -3813,8 +3819,10 @@ gboolean gtk_plot_linear_print_eps(GtkWidget *plot, gchar* fout)
{
cairo_t *cr;
cairo_surface_t *surface;
GtkAllocation alloc;

surface=cairo_ps_surface_create(fout, (gdouble) (plot->allocation.width), (gdouble) (plot->allocation.height));
gtk_widget_get_allocation(plot, &alloc);
surface=cairo_ps_surface_create(fout, (gdouble) (alloc.width), (gdouble) (alloc.height));
cairo_ps_surface_set_eps(surface, TRUE);
cairo_ps_surface_restrict_to_level(surface, CAIRO_PS_LEVEL_2);
cr=cairo_create(surface);
Expand All @@ -3830,8 +3838,10 @@ gboolean gtk_plot_linear_print_png(GtkWidget *plot, gchar* fout)
{
cairo_t *cr;
cairo_surface_t *surface;
GtkAllocation alloc;

surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, (gdouble) (plot->allocation.width), (gdouble) (plot->allocation.height));
gtk_widget_get_allocation(plot, &alloc);
surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, (gdouble) (alloc.width), (gdouble) (alloc.height));
cr=cairo_create(surface);
draw(plot, cr);
cairo_surface_write_to_png(surface, fout);
Expand All @@ -3844,8 +3854,10 @@ gboolean gtk_plot_linear_print_svg(GtkWidget *plot, gchar* fout)
{
cairo_t *cr;
cairo_surface_t *surface;
GtkAllocation alloc;

surface=cairo_svg_surface_create(fout, (gdouble) (plot->allocation.width), (gdouble) (plot->allocation.height));
gtk_widget_get_allocation(plot, &alloc);
surface=cairo_svg_surface_create(fout, (gdouble) (alloc.width), (gdouble) (alloc.height));
cr=cairo_create(surface);
draw(plot, cr);
cairo_destroy(cr);
Expand Down Expand Up @@ -3910,6 +3922,7 @@ static gboolean gtk_plot_linear_button_release(GtkWidget *widget, GdkEventButton
{
GtkPlotLinearPrivate *priv;
GtkPlotLinear *plot;
GtkAllocation alloc;
gint d, xw;
gdouble xn, xx, yn, yx, s;

Expand Down Expand Up @@ -4026,7 +4039,8 @@ static gboolean gtk_plot_linear_button_release(GtkWidget *widget, GdkEventButton
}
else if ((event->y)<=11)
{
xw=(widget->allocation.width);
gtk_widget_get_allocation(widget, &alloc);
xw=(alloc.width);
if ((event->x)>=xw-22)
{
if ((event->x)>=xw-11)
Expand Down Expand Up @@ -4192,7 +4206,7 @@ static gboolean gtk_plot_linear_expose(GtkWidget *widget, GdkEventExpose *event)
{
cairo_t *cr;

cr=gdk_cairo_create(widget->window);
cr=gdk_cairo_create(gtk_widget_get_window(widget));
cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, event->area.height);
cairo_clip(cr);
draw(widget, cr);
Expand Down
44 changes: 30 additions & 14 deletions gtk2plot/gtkplotpolar.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ struct _GtkPlotPolarPrivate {struct xs bounds, rescale; struct pt centre; struct
static void drawz(GtkWidget *widget, cairo_t *cr)
{
GtkPlotPolar *plot;
GtkAllocation alloc;
gint xw;
gdouble dt;

xw=(widget->allocation.width);
gtk_widget_get_allocation(widget, &alloc);
xw=alloc.width;
plot=GTK_PLOT_POLAR(widget);
cairo_set_source_rgba(cr, 0, 0, 0, 1);
cairo_set_line_width(cr, 1);
Expand Down Expand Up @@ -181,15 +183,17 @@ static void draw(GtkWidget *widget, cairo_t *cr)
{
GtkPlotPolarPrivate *priv;
GtkPlotPolar *plot;
GtkAllocation alloc;
gint j, k, xw, yw, kx, j0, jl, xt, wd, hg, ft, lt;
gdouble dtt, tt, dtr, thx, thn, dt, sx, csx, ssx, dr1, drs, drc, dz, rt, dwr, rl, ctx, ctn, stx, stn, r, th, rn, tn, x, y, vv, wv, xv, yv;
gchar lbl[10];
gchar *str1=NULL, *str2=NULL, *str3;
PangoLayout *lyt;
cairo_matrix_t mtr;

xw=(widget->allocation.width);
yw=(widget->allocation.height);
gtk_widget_get_allocation(widget, &alloc);
xw=alloc.width;
yw=alloc.height;
plot=GTK_PLOT_POLAR(widget);
priv=GTK_PLOT_POLAR_GET_PRIVATE(plot);/* determine scale and fit for graph */
if ((priv->bounds.rmax)<0) {(priv->bounds.rmax)=-(priv->bounds.rmax); (priv->bounds.rmin)=-(priv->bounds.rmin);}
Expand Down Expand Up @@ -4941,11 +4945,13 @@ static void draw(GtkWidget *widget, cairo_t *cr)
static void gtk_plot_polar_redraw(GtkWidget *widget)
{
GdkRegion *region;
GdkWindow *wdw;

if (!widget->window) return;
region=gdk_drawable_get_clip_region(widget->window);
gdk_window_invalidate_region(widget->window, region, TRUE);
gdk_window_process_updates(widget->window, TRUE);
wdw=gtk_widget_get_window(widget);
if (!wdw) return;
region=gdk_drawable_get_clip_region(wdw);
gdk_window_invalidate_region(wdw, region, TRUE);
gdk_window_process_updates(wdw, TRUE);
gdk_region_destroy(region);
}

Expand Down Expand Up @@ -5298,8 +5304,10 @@ gboolean gtk_plot_polar_print_eps(GtkWidget *plot, gchar* fout)
{
cairo_t *cr;
cairo_surface_t *surface;
GtkAllocation alloc;

surface=cairo_ps_surface_create(fout, (gdouble) (plot->allocation.width), (gdouble) (plot->allocation.height));
gtk_widget_get_allocation(plot, &alloc);
surface=cairo_ps_surface_create(fout, (gdouble) (alloc.width), (gdouble) (alloc.height));
cairo_ps_surface_set_eps(surface, TRUE);
cairo_ps_surface_restrict_to_level(surface, CAIRO_PS_LEVEL_2);
cr=cairo_create(surface);
Expand All @@ -5315,8 +5323,10 @@ gboolean gtk_plot_polar_print_png(GtkWidget *plot, gchar* fout)
{
cairo_t *cr;
cairo_surface_t *surface;
GtkAllocation alloc;

surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, (gdouble) (plot->allocation.width), (gdouble) (plot->allocation.height));
gtk_widget_get_allocation(plot, &alloc);
surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, (gdouble) (alloc.width), (gdouble) (alloc.height));
cr=cairo_create(surface);
draw(plot, cr);
cairo_surface_write_to_png(surface, fout);
Expand All @@ -5329,8 +5339,10 @@ gboolean gtk_plot_polar_print_svg(GtkWidget *plot, gchar* fout)
{
cairo_t *cr;
cairo_surface_t *surface;
GtkAllocation alloc;

surface=cairo_svg_surface_create(fout, (gdouble) (plot->allocation.width), (gdouble) (plot->allocation.height));
gtk_widget_get_allocation(plot, &alloc);
surface=cairo_svg_surface_create(fout, (gdouble) (alloc.width), (gdouble) (alloc.height));
cr=cairo_create(surface);
draw(plot, cr);
cairo_destroy(cr);
Expand All @@ -5342,12 +5354,14 @@ static gboolean gtk_plot_polar_button_press(GtkWidget *widget, GdkEventButton *e
{
GtkPlotPolarPrivate *priv;
GtkPlotPolar *plot;
GtkAllocation alloc;
gdouble dy, dx, dt;
gint xw;


gtk_widget_get_allocation(widget, &alloc);
priv=GTK_PLOT_POLAR_GET_PRIVATE(widget);
plot=GTK_PLOT_POLAR(widget);
xw=(widget->allocation.width);
xw=(alloc.width);
if (((priv->flagr)==0)&&(((event->x)<xw-22)||((event->y)>11)))
{
(priv->rescale.rmax)=(priv->bounds.rmax);
Expand Down Expand Up @@ -5423,6 +5437,7 @@ static gboolean gtk_plot_polar_button_release(GtkWidget *widget, GdkEventButton
{
GtkPlotPolarPrivate *priv;
GtkPlotPolar *plot;
GtkAllocation alloc;
gint xw;
gdouble dy, dx, dt, xn, xx, yn, yx, s;

Expand Down Expand Up @@ -5502,7 +5517,8 @@ static gboolean gtk_plot_polar_button_release(GtkWidget *widget, GdkEventButton
}
else if ((event->y)<=11)
{
xw=(widget->allocation.width);
gtk_widget_get_allocation(widget, &alloc);
xw=(alloc.width);
if ((event->x)>=xw-22)
{
if ((event->x)>=xw-11) (plot->zmode)^=GTK_PLOT_POLAR_ZOOM_OUT;
Expand Down Expand Up @@ -5583,7 +5599,7 @@ static gboolean gtk_plot_polar_expose(GtkWidget *widget, GdkEventExpose *event)
{
cairo_t *cr;

cr=gdk_cairo_create(widget->window);
cr=gdk_cairo_create(gtk_widget_get_window(widget));
cairo_rectangle(cr, (event->area.x), (event->area.y), (event->area.width), (event->area.height));
cairo_clip(cr);
drawz(widget, cr);
Expand Down
Loading

0 comments on commit cb30972

Please sign in to comment.