summaryrefslogtreecommitdiff
path: root/body/c_fl_chart.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-01-21 21:04:54 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2025-01-21 21:04:54 +1300
commitb4438b2fbe895694be98e6e8426103deefc51448 (patch)
tree760d86cd7c06420a91dad102cc9546aee73146fc /body/c_fl_chart.cpp
parenta4703a65b015140cd4a7a985db66264875ade734 (diff)
Split public API and private implementation files into different directories
Diffstat (limited to 'body/c_fl_chart.cpp')
-rw-r--r--body/c_fl_chart.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/body/c_fl_chart.cpp b/body/c_fl_chart.cpp
new file mode 100644
index 0000000..c065327
--- /dev/null
+++ b/body/c_fl_chart.cpp
@@ -0,0 +1,151 @@
+
+
+// Programmed by Jedidiah Barber
+// Released into the public domain
+
+
+#include <FL/Fl_Chart.H>
+#include "c_fl_chart.h"
+
+
+
+
+// Exports from Ada
+
+extern "C" void widget_draw_hook(void * ud);
+extern "C" int widget_handle_hook(void * ud, int e);
+
+
+
+
+// Attaching all relevant hooks and friends
+
+class My_Chart : public Fl_Chart {
+public:
+ using Fl_Chart::Fl_Chart;
+
+ friend void fl_chart_draw(CHART n);
+ friend int fl_chart_handle(CHART n, int e);
+
+ void draw();
+ int handle(int e);
+};
+
+void My_Chart::draw() {
+ widget_draw_hook(this->user_data());
+}
+
+int My_Chart::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
+}
+
+
+
+
+// Flattened C API
+
+CHART new_fl_chart(int x, int y, int w, int h, char* label) {
+ My_Chart *b = new My_Chart(x, y, w, h, label);
+ return b;
+}
+
+void free_fl_chart(CHART b) {
+ delete static_cast<My_Chart*>(b);
+}
+
+
+
+
+void fl_chart_add(CHART b, double v, char * s, unsigned int c) {
+ static_cast<Fl_Chart*>(b)->add(v,s,c);
+}
+
+void fl_chart_insert(CHART b, int i, double v, char * s, unsigned int c) {
+ static_cast<Fl_Chart*>(b)->insert(i,v,s,c);
+}
+
+void fl_chart_replace(CHART b, int i, double v, char * s, unsigned int c) {
+ static_cast<Fl_Chart*>(b)->replace(i,v,s,c);
+}
+
+void fl_chart_clear(CHART b) {
+ static_cast<Fl_Chart*>(b)->clear();
+}
+
+
+
+
+int fl_chart_get_autosize(CHART b) {
+ return static_cast<Fl_Chart*>(b)->autosize();
+}
+
+void fl_chart_set_autosize(CHART b, int a) {
+ static_cast<Fl_Chart*>(b)->autosize(a);
+}
+
+void fl_chart_get_bounds(CHART b, double * l, double * u) {
+ static_cast<Fl_Chart*>(b)->bounds(l,u);
+}
+
+void fl_chart_set_bounds(CHART b, double l, double u) {
+ static_cast<Fl_Chart*>(b)->bounds(l,u);
+}
+
+int fl_chart_get_maxsize(CHART b) {
+ return static_cast<Fl_Chart*>(b)->maxsize();
+}
+
+void fl_chart_set_maxsize(CHART b, int m) {
+ static_cast<Fl_Chart*>(b)->maxsize(m);
+}
+
+int fl_chart_size(CHART b) {
+ return static_cast<Fl_Chart*>(b)->size();
+}
+
+
+
+
+void fl_chart_size2(CHART b, int w, int h) {
+ static_cast<Fl_Chart*>(b)->size(w, h);
+}
+
+
+
+
+unsigned int fl_chart_get_textcolor(CHART b) {
+ return static_cast<Fl_Chart*>(b)->textcolor();
+}
+
+void fl_chart_set_textcolor(CHART b, unsigned int c) {
+ static_cast<Fl_Chart*>(b)->textcolor(c);
+}
+
+int fl_chart_get_textfont(CHART b) {
+ return static_cast<Fl_Chart*>(b)->textfont();
+}
+
+void fl_chart_set_textfont(CHART b, int f) {
+ static_cast<Fl_Chart*>(b)->textfont(f);
+}
+
+int fl_chart_get_textsize(CHART b) {
+ return static_cast<Fl_Chart*>(b)->textsize();
+}
+
+void fl_chart_set_textsize(CHART b, int s) {
+ static_cast<Fl_Chart*>(b)->textsize(s);
+}
+
+
+
+
+void fl_chart_draw(CHART n) {
+ static_cast<My_Chart*>(n)->Fl_Chart::draw();
+}
+
+int fl_chart_handle(CHART n, int e) {
+ return static_cast<My_Chart*>(n)->Fl_Chart::handle(e);
+}
+
+