UNCOMP = gzip -df
STRIP = strip
-#CFLAGS = $(OBJOPT) $(IPATH) `pkg-config --cflags gtk+-2.0` -DAPISTRING=FOO
-CFLAGS = $(OBJOPT) $(IPATH) `pkg-config --cflags gtk+-2.0` -DAPISTRING=`if [ ! -e api-horkfile ]; then mktemp -u aXXXXXXXXXXXXXX > api-horkfile; fi; head -n1 api-horkfile`
+CFLAGS = $(OBJOPT) $(IPATH) `pkg-config --cflags gtk+-2.0`
LDFLAGS = $(EXEOPT) $(LPATH) `pkg-config --libs gtk+-2.0`
.SUFFIXES: .h.Z .c.Z .h.gz .c.gz .c.z .h.z
##############################
all: $(NAME)
- rm -f api-horkfile
$(NAME): $(OBJS) $(SRC) $(INCL)
$(CC) $(OBJS) $(LDFLAGS) -o $(NAME)
# $(STRIP) ./$(NAME) # if you debug ,don't strip ...
depend:
gcc $(IPATH) -MM $(SRC)
clean:
- -$(RM) $(NAME) $(OBJS) api-horkfile *~
+ -$(RM) $(NAME) $(OBJS)
fclean:
-$(RM) $(NAME)
comp: clean
** Login <solarion@johnathan>
**
-Copyright (C) 2008 Joseph Pingenot
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+ Copyright (C) 2008 Joseph Pingenot
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
-You should have received a copy of the GNU Lesser General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
**Many thanks to Davyd Madeley for the excellent Cairo Tutorial
** at http://gnomejournal.org/article/34/writing-a--using-cairo-and-gtk28
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/
-#include "graph.h"
+#include <graph.h>
+#include <stdlib.h>
G_DEFINE_TYPE(Graph, graph, G_TYPE_OBJECT);
static void graph_init(Graph *graph) {
graph->symbol = CIRCLE;
- GPtrArray = g_ptr_array_new();
+ graph->points = g_ptr_array_new();
}
Graph *graph_new(void) {
- return g_object_new(G_GRAPH_TYPE);
+ return g_object_new(GRAPH_TYPE, NULL);
}
int graph_add_point(Graph* graph, double x, double y) {
point[0] = x;
point[1] = y;
g_ptr_array_add(graph->points, (gpointer)point);
- if(points->len == 1) {
- maxx = minx = x;
- maxy = miny = x;
+ if(graph->points->len == 1) {
+ graph->maxx = graph->minx = x;
+ graph->maxy = graph->miny = x;
}else{
- if(x > maxx) maxx = x;
- if(x < minx) minx = x;
- if(y > mayy) maxy = y;
- if(y < miny) miny = y;
+ if(x > graph->maxx) graph->maxx = x;
+ if(x < graph->minx) graph->minx = x;
+ if(y > graph->maxy) graph->maxy = y;
+ if(y < graph->miny) graph->miny = y;
}
return 0;
}
** Login <solarion@johnathan>
**
-Copyright (C) 2008 Joseph Pingenot
+ Copyright (C) 2008 Joseph Pingenot
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
-You should have received a copy of the GNU Lesser General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
** Started on Thu Jul 17 10:51:32 2008 Johnny Q. Hacker
** Last update Thu Jul 17 10:51:32 2008 Johnny Q. Hacker
*/
-#ifndef GRAPH_H_
-# define GRAPH_H_
+#ifndef GRAPHCLASS_H_
+#define GRAPHCLASS_H_
#include <glib-2.0/glib-object.h>
-enum graph_symbol {
- SQUARE,
- CIRCLE,
- STAR,
- PLUS,
- MINUX,
- CROSS
- };
+typedef enum {SQUARE, CIRCLE, STAR, PLUS, MINUS, CROSS} graph_symbol;
typedef struct _Graph {
GObject parent;
Graph *graph_new(void);
int graph_add_point(Graph* graph, double x, double y);
-#endif /* !GRAPH_H_ */
+#endif /* !GRAPHCLASS_H_ */
** Login <solarion@johnathan>
**
-Copyright (C) 2008 Joseph Pingenot
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
+ Copyright (C) 2008 Joseph Pingenot
-You should have received a copy of the GNU Lesser General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
**Many thanks to Davyd Madeley for the excellent Cairo Widget Tutorial
** at http://gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/
-#include "graphwidget.h"
+#include <graphwidget.h>
+#include <math.h>
G_DEFINE_TYPE(GraphWidget, graph_widget, GTK_TYPE_DRAWING_AREA);
static void draw_point(gpointer data, gpointer user_data) {
struct drawing_context *cxt = (struct drawing_context *) user_data;
- cairo_arc(cxt->cr, ((*double)data)[0], ((*double)data)[1], cxt->radius, 0, 2*M_PI);
+ double *d = (double*)data;
+ cairo_arc(cxt->cr, d[0], d[1], cxt->radius, 0, 2*M_PI);
}
static void draw(GtkWidget *graph, cairo_t *cr) {
graph->graph = graph_new();
}
-GtkWidget *graph_widget_new() {
- return = g_object_new(GRAPH_WIDGET_TYPE, NULL);
+GtkWidget *graph_widget_new(void) {
+ return g_object_new(GRAPH_WIDGET_TYPE, NULL);
}
-Graph* get_graph(GraphWidget* gw) {
+Graph* graph_widget_get_graph(GraphWidget* gw) {
return gw->graph;
}
** Login <solarion@johnathan>
**
-Copyright (C) 2008 Joseph Pingenot
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
+ Copyright (C) 2008 Joseph Pingenot
-You should have received a copy of the GNU Lesser General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
** Started on Thu Jul 17 10:51:32 2008 Johnny Q. Hacker
** Last update Thu Jul 17 10:51:32 2008 Johnny Q. Hacker
*/
-#ifndef GRAPH_H_
-# define GRAPH_H_
+#ifndef GRAPHWIDGET_H_
+#define GRAPHWIDGET_H_
#include <gtk/gtkdrawingarea.h>
#include <graph.h>
#define IS_GRAPH_WIDGET_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GRAPH_WIDGET_CLASS_TYPE))
#define GRAPH_WIDGET_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), GRAPH_WIDGET, GraphWidgetClass))
-GtkWidget* graph_widget_new(Graph* graph);
+GtkWidget* graph_widget_new(void);
-Graph* get_graph(GraphWidget* gw);
+Graph* graph_widget_get_graph(GraphWidget* gw);
-#endif /* !GRAPH_H_ */
+#endif /* !GRAPHWIDGET_H_ */
**
** Holds the SC graphing widget.
-Copyright (C) 2008 Joseph Pingenot
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ Copyright (C) 2008 Joseph Pingenot
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
** Started on Thu Jul 17 11:03:27 2008 Johnny Q. Hacker
** Last update Sun May 12 01:17:25 2002 Speed Blue
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_container_add(GTK_CONTAINER(window), graph);
+ graph_add_point(graph_widget_get_graph(graph), 5, 3);
+ graph_add_point(graph_widget_get_graph(graph), 8, 12);
+ graph_add_point(graph_widget_get_graph(graph), 11, 48);
gtk_widget_show_all (window);