summaryrefslogtreecommitdiff
path: root/body/c_fl_group.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_group.cpp
parenta4703a65b015140cd4a7a985db66264875ade734 (diff)
Split public API and private implementation files into different directories
Diffstat (limited to 'body/c_fl_group.cpp')
-rw-r--r--body/c_fl_group.cpp193
1 files changed, 193 insertions, 0 deletions
diff --git a/body/c_fl_group.cpp b/body/c_fl_group.cpp
new file mode 100644
index 0000000..62bee03
--- /dev/null
+++ b/body/c_fl_group.cpp
@@ -0,0 +1,193 @@
+
+
+// Programmed by Jedidiah Barber
+// Released into the public domain
+
+
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Widget.H>
+#include "c_fl_group.h"
+#include "c_fl_widget.h"
+
+
+
+
+// Exports from Ada
+
+extern "C" void widget_draw_hook(void * ud);
+extern "C" int widget_handle_hook(void * ud, int e);
+
+
+
+
+// Non-friend protected access
+
+class Friend_Group : Fl_Group {
+public:
+ using Fl_Group::draw_child;
+ using Fl_Group::draw_children;
+ using Fl_Group::draw_outside_label;
+ using Fl_Group::update_child;
+};
+
+
+
+
+// Attaching all relevant hooks and friends
+
+class My_Group : public Fl_Group {
+public:
+ using Fl_Group::Fl_Group;
+
+ friend void fl_group_draw(GROUP g);
+ friend int fl_group_handle(GROUP g, int e);
+
+ void draw();
+ int handle(int e);
+};
+
+void My_Group::draw() {
+ widget_draw_hook(this->user_data());
+}
+
+int My_Group::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
+}
+
+
+
+
+// Flattened C API
+
+GROUP new_fl_group(int x, int y, int w, int h, char* label) {
+ My_Group *g = new My_Group(x, y, w, h, label);
+ return g;
+}
+
+void free_fl_group(GROUP g) {
+ delete static_cast<My_Group*>(g);
+}
+
+
+
+
+void fl_group_add(GROUP g, WIDGET item) {
+ static_cast<Fl_Group*>(g)->add(static_cast<Fl_Widget*>(item));
+}
+
+void fl_group_insert(GROUP g, WIDGET item, int place) {
+ static_cast<Fl_Group*>(g)->insert(*(static_cast<Fl_Widget*>(item)), place);
+}
+
+void fl_group_insert2(GROUP g, WIDGET item, WIDGET before) {
+ static_cast<Fl_Group*>(g)->insert(*(static_cast<Fl_Widget*>(item)), static_cast<Fl_Widget*>(before));
+}
+
+void fl_group_remove(GROUP g, WIDGET item) {
+ static_cast<Fl_Group*>(g)->remove(static_cast<Fl_Widget*>(item));
+}
+
+void fl_group_remove2(GROUP g, int place) {
+ static_cast<Fl_Group*>(g)->remove(place);
+}
+
+
+
+
+void * fl_group_child(GROUP g, int place) {
+ return static_cast<Fl_Group*>(g)->child(place);
+}
+
+int fl_group_find(GROUP g, WIDGET item) {
+ return static_cast<Fl_Group*>(g)->find(static_cast<Fl_Widget*>(item));
+}
+
+int fl_group_children(GROUP g) {
+ return static_cast<Fl_Group*>(g)->children();
+}
+
+
+
+
+unsigned int fl_group_get_clip_children(GROUP g) {
+ return static_cast<Fl_Group*>(g)->clip_children();
+}
+
+void fl_group_set_clip_children(GROUP g, int c) {
+ static_cast<Fl_Group*>(g)->clip_children(c);
+}
+
+
+
+
+void fl_group_add_resizable(GROUP g, WIDGET w) {
+ Fl_Widget &ref = *(static_cast<Fl_Widget*>(w));
+ static_cast<Fl_Group*>(g)->add_resizable(ref);
+}
+
+void * fl_group_get_resizable(GROUP g) {
+ return static_cast<Fl_Group*>(g)->resizable();
+}
+
+void fl_group_set_resizable(GROUP g, WIDGET item) {
+ static_cast<Fl_Group*>(g)->resizable(static_cast<Fl_Widget*>(item));
+}
+
+void fl_group_init_sizes(GROUP g) {
+ static_cast<Fl_Group*>(g)->init_sizes();
+}
+
+void fl_group_resize(GROUP g, int x, int y, int w, int h) {
+ static_cast<Fl_Group*>(g)->resize(x, y, w, h);
+}
+
+
+
+
+void * fl_group_get_current() {
+ return Fl_Group::current();
+}
+
+void fl_group_set_current(GROUP g) {
+ Fl_Group::current(static_cast<Fl_Group*>(g));
+}
+
+void fl_group_begin(GROUP g) {
+ static_cast<Fl_Group*>(g)->begin();
+}
+
+void fl_group_end(GROUP g) {
+ static_cast<Fl_Group*>(g)->end();
+}
+
+
+
+
+void fl_group_draw(GROUP g) {
+ static_cast<My_Group*>(g)->Fl_Group::draw();
+}
+
+void fl_group_draw_child(GROUP g, WIDGET w) {
+ Fl_Widget &ref = *(static_cast<Fl_Widget*>(w));
+ (static_cast<Fl_Group*>(g)->*(&Friend_Group::draw_child))(ref);
+}
+
+void fl_group_draw_children(GROUP g) {
+ (static_cast<Fl_Group*>(g)->*(&Friend_Group::draw_children))();
+}
+
+void fl_group_draw_outside_label(GROUP g, WIDGET w) {
+ Fl_Widget &ref = *(static_cast<Fl_Widget*>(w));
+ (static_cast<Fl_Group*>(g)->*(&Friend_Group::draw_outside_label))(ref);
+}
+
+void fl_group_update_child(GROUP g, WIDGET w) {
+ Fl_Widget &ref = *(static_cast<Fl_Widget*>(w));
+ (static_cast<Fl_Group*>(g)->*(&Friend_Group::update_child))(ref);
+}
+
+int fl_group_handle(GROUP g, int e) {
+ return static_cast<My_Group*>(g)->Fl_Group::handle(e);
+}
+
+