summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_scroll.cpp110
-rw-r--r--src/c_fl_scroll.h29
-rw-r--r--src/fltk-widgets-groups-scrolls.adb195
-rw-r--r--src/fltk-widgets-groups-scrolls.ads78
4 files changed, 412 insertions, 0 deletions
diff --git a/src/c_fl_scroll.cpp b/src/c_fl_scroll.cpp
new file mode 100644
index 0000000..999c3a4
--- /dev/null
+++ b/src/c_fl_scroll.cpp
@@ -0,0 +1,110 @@
+
+
+#include <FL/Fl_Scroll.H>
+#include "c_fl_scroll.h"
+#include "c_fl_type.h"
+
+
+
+
+class My_Scroll : public Fl_Scroll {
+ public:
+ using Fl_Scroll::Fl_Scroll;
+ friend void scroll_set_draw_hook(SCROLL s, void * d);
+ friend void fl_scroll_draw(SCROLL s);
+ friend void scroll_set_handle_hook(SCROLL s, void * h);
+ friend int fl_scroll_handle(SCROLL s, int e);
+ protected:
+ void draw();
+ void real_draw();
+ int handle(int e);
+ int real_handle(int e);
+ d_hook_p draw_hook;
+ h_hook_p handle_hook;
+};
+
+
+void My_Scroll::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+
+void My_Scroll::real_draw() {
+ Fl_Scroll::draw();
+}
+
+
+int My_Scroll::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+
+int My_Scroll::real_handle(int e) {
+ return Fl_Scroll::handle(e);
+}
+
+
+void scroll_set_draw_hook(SCROLL s, void * d) {
+ reinterpret_cast<My_Scroll*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d);
+}
+
+
+void fl_scroll_draw(SCROLL s) {
+ reinterpret_cast<My_Scroll*>(s)->real_draw();
+}
+
+
+void scroll_set_handle_hook(SCROLL s, void * h) {
+ reinterpret_cast<My_Scroll*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+
+int fl_scroll_handle(SCROLL s, int e) {
+ return reinterpret_cast<My_Scroll*>(s)->real_handle(e);
+}
+
+
+
+
+SCROLL new_fl_scroll(int x, int y, int w, int h, char* label) {
+ My_Scroll *s = new My_Scroll(x, y, w, h, label);
+ return s;
+}
+
+
+void free_fl_scroll(SCROLL s) {
+ delete reinterpret_cast<My_Scroll*>(s);
+}
+
+
+
+
+void fl_scroll_to(SCROLL s, int x, int y) {
+ reinterpret_cast<Fl_Scroll*>(s)->scroll_to(x, y);
+}
+
+
+int fl_scroll_get_size(SCROLL s) {
+ return reinterpret_cast<Fl_Scroll*>(s)->scrollbar_size();
+}
+
+
+void fl_scroll_set_size(SCROLL s, int t) {
+ reinterpret_cast<Fl_Scroll*>(s)->scrollbar_size(t);
+}
+
+
+int fl_scroll_xposition(SCROLL s) {
+ return reinterpret_cast<Fl_Scroll*>(s)->xposition();
+}
+
+
+int fl_scroll_yposition(SCROLL s) {
+ return reinterpret_cast<Fl_Scroll*>(s)->yposition();
+}
+
+
+void fl_scroll_set_type(SCROLL s, int t) {
+ reinterpret_cast<Fl_Scroll*>(s)->type(t);
+}
+
diff --git a/src/c_fl_scroll.h b/src/c_fl_scroll.h
new file mode 100644
index 0000000..3379063
--- /dev/null
+++ b/src/c_fl_scroll.h
@@ -0,0 +1,29 @@
+
+
+#ifndef FL_SCROLL_GUARD
+#define FL_SCROLL_GUARD
+
+
+typedef void* SCROLL;
+
+
+extern "C" void scroll_set_draw_hook(SCROLL s, void * d);
+extern "C" void fl_scroll_draw(SCROLL s);
+extern "C" void scroll_set_handle_hook(SCROLL s, void * h);
+extern "C" int fl_scroll_handle(SCROLL s, int e);
+
+
+extern "C" SCROLL new_fl_scroll(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_scroll(SCROLL s);
+
+
+extern "C" void fl_scroll_to(SCROLL s, int x, int y);
+extern "C" int fl_scroll_get_size(SCROLL s);
+extern "C" void fl_scroll_set_size(SCROLL s, int t);
+extern "C" int fl_scroll_xposition(SCROLL s);
+extern "C" int fl_scroll_yposition(SCROLL s);
+extern "C" void fl_scroll_set_type(SCROLL s, int t);
+
+
+#endif
+
diff --git a/src/fltk-widgets-groups-scrolls.adb b/src/fltk-widgets-groups-scrolls.adb
new file mode 100644
index 0000000..09aae1e
--- /dev/null
+++ b/src/fltk-widgets-groups-scrolls.adb
@@ -0,0 +1,195 @@
+
+
+with Interfaces.C;
+with System;
+use type System.Address;
+
+
+package body FLTK.Widgets.Groups.Scrolls is
+
+
+ procedure scroll_set_draw_hook
+ (S, D : in System.Address);
+ pragma Import (C, scroll_set_draw_hook, "scroll_set_draw_hook");
+
+ procedure scroll_set_handle_hook
+ (S, H : in System.Address);
+ pragma Import (C, scroll_set_handle_hook, "scroll_set_handle_hook");
+
+
+ function new_fl_scroll
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_scroll, "new_fl_scroll");
+
+ procedure free_fl_scroll
+ (S : in System.Address);
+ pragma Import (C, free_fl_scroll, "free_fl_scroll");
+
+
+ procedure fl_scroll_to
+ (S : in System.Address;
+ X, Y : in Interfaces.C.int);
+ pragma Import (C, fl_scroll_to, "fl_scroll_to");
+
+ function fl_scroll_get_size
+ (S : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_scroll_get_size, "fl_scroll_get_size");
+
+ procedure fl_scroll_set_size
+ (S : in System.Address;
+ T : in Interfaces.C.int);
+ pragma Import (C, fl_scroll_set_size, "fl_scroll_set_size");
+
+ function fl_scroll_xposition
+ (S : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_scroll_xposition, "fl_scroll_xposition");
+
+ function fl_scroll_yposition
+ (S : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_scroll_yposition, "fl_scroll_yposition");
+
+ procedure fl_scroll_set_type
+ (S : in System.Address;
+ T : in Interfaces.C.int);
+ pragma Import (C, fl_scroll_set_type, "fl_scroll_set_type");
+
+ procedure fl_scroll_draw
+ (S : in System.Address);
+ pragma Import (C, fl_scroll_draw, "fl_scroll_draw");
+
+ function fl_scroll_handle
+ (S : in System.Address;
+ E : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_scroll_handle, "fl_scroll_handle");
+
+
+
+
+ procedure Finalize
+ (This : in out Scroll) is
+ begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in Scroll'Class
+ then
+ This.Clear;
+ free_fl_scroll (This.Void_Ptr);
+ This.Void_Ptr := System.Null_Address;
+ end if;
+ Finalize (Group (This));
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Scroll is
+ begin
+ return This : Scroll do
+ This.Void_Ptr := new_fl_scroll
+ (Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H),
+ Interfaces.C.To_C (Text));
+ fl_group_end (This.Void_Ptr);
+ fl_widget_set_user_data
+ (This.Void_Ptr,
+ Widget_Convert.To_Address (This'Unchecked_Access));
+ scroll_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ scroll_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
+ end return;
+ end Create;
+
+
+
+
+
+ procedure Scroll_To
+ (This : in out Scroll;
+ X, Y : in Integer) is
+ begin
+ fl_scroll_to (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y));
+ end Scroll_To;
+
+
+
+
+ function Get_Scrollbar_Size
+ (This : in Scroll)
+ return Integer is
+ begin
+ return Integer (fl_scroll_get_size (This.Void_Ptr));
+ end Get_Scrollbar_Size;
+
+
+
+
+ procedure Set_Scrollbar_Size
+ (This : in out Scroll;
+ To : in Integer) is
+ begin
+ fl_scroll_set_size (This.Void_Ptr, Interfaces.C.int (To));
+ end Set_Scrollbar_Size;
+
+
+
+
+ function Get_Scroll_X
+ (This : in Scroll)
+ return Integer is
+ begin
+ return Integer (fl_scroll_xposition (This.Void_Ptr));
+ end Get_Scroll_X;
+
+
+
+
+ function Get_Scroll_Y
+ (This : in Scroll)
+ return Integer is
+ begin
+ return Integer (fl_scroll_yposition (This.Void_Ptr));
+ end Get_Scroll_Y;
+
+
+
+
+ procedure Set_Type
+ (This : in out Scroll;
+ Mode : in Scroll_Kind) is
+ begin
+ fl_scroll_set_type (This.Void_Ptr, Scroll_Kind'Pos (Mode));
+ end Set_Type;
+
+
+
+
+ procedure Draw
+ (This : in out Scroll) is
+ begin
+ fl_scroll_draw (This.Void_Ptr);
+ end Draw;
+
+
+
+
+ function Handle
+ (This : in out Scroll;
+ Event : in Event_Kind)
+ return Event_Outcome is
+ begin
+ return Event_Outcome'Val
+ (fl_scroll_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
+ end Handle;
+
+
+end FLTK.Widgets.Groups.Scrolls;
+
diff --git a/src/fltk-widgets-groups-scrolls.ads b/src/fltk-widgets-groups-scrolls.ads
new file mode 100644
index 0000000..e4ead1b
--- /dev/null
+++ b/src/fltk-widgets-groups-scrolls.ads
@@ -0,0 +1,78 @@
+
+
+package FLTK.Widgets.Groups.Scrolls is
+
+
+ type Scroll is new Group with private;
+
+
+ type Scroll_Kind is
+ (Horizontal,
+ Vertical,
+ Both,
+ Always_On,
+ Horizontal_Always,
+ Vertical_Always,
+ Both_Always);
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Scroll;
+
+
+ procedure Scroll_To
+ (This : in out Scroll;
+ X, Y : in Integer);
+
+
+ function Get_Scrollbar_Size
+ (This : in Scroll)
+ return Integer;
+
+
+ procedure Set_Scrollbar_Size
+ (This : in out Scroll;
+ To : in Integer);
+
+
+ -- These two functions are far too similar in name and
+ -- function to the Get_X and Get_Y for Widgets.
+ function Get_Scroll_X
+ (This : in Scroll)
+ return Integer;
+
+
+ function Get_Scroll_Y
+ (This : in Scroll)
+ return Integer;
+
+
+ procedure Set_Type
+ (This : in out Scroll;
+ Mode : in Scroll_Kind);
+
+
+ procedure Draw
+ (This : in out Scroll);
+
+
+ function Handle
+ (This : in out Scroll;
+ Event : in Event_Kind)
+ return Event_Outcome;
+
+
+private
+
+
+ type Scroll is new Group with null record;
+
+
+ overriding procedure Finalize
+ (This : in out Scroll);
+
+
+end FLTK.Widgets.Groups.Scrolls;
+