summaryrefslogtreecommitdiff
path: root/src/c_fl_scrollbar.cpp
blob: 848d83fb280857ecf61c9f7c9e8a60b0c3afe7a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


//  Programmed by Jedidiah Barber
//  Released into the public domain


#include <FL/Fl_Scrollbar.H>
#include "c_fl_scrollbar.h"
#include "c_fl_type.h"




//  Telprot stopovers

extern "C" void scrollbar_extra_init_hook(void * aobj, int x, int y, int w, int h, const char * l);
void fl_scrollbar_extra_init (void * adaobj, int x, int y, int w, int h, const char * label) {
    scrollbar_extra_init_hook(adaobj, x, y, w, h, label);
}

extern "C" void scrollbar_extra_final_hook(void * aobj);
void fl_scrollbar_extra_final(void * adaobj) {
    scrollbar_extra_final_hook(adaobj);
}




class My_Scrollbar : public Fl_Scrollbar {
    public:
        using Fl_Scrollbar::Fl_Scrollbar;
        friend void scrollbar_set_draw_hook(SCROLLBAR s, void * d);
        friend void fl_scrollbar_draw(SCROLLBAR s);
        friend void scrollbar_set_handle_hook(SCROLLBAR s, void * h);
        friend int fl_scrollbar_handle(SCROLLBAR 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_Scrollbar::draw() {
    (*draw_hook)(this->user_data());
}

void My_Scrollbar::real_draw() {
    Fl_Scrollbar::draw();
}

int My_Scrollbar::handle(int e) {
    return (*handle_hook)(this->user_data(), e);
}

int My_Scrollbar::real_handle(int e) {
    return Fl_Scrollbar::handle(e);
}

void scrollbar_set_draw_hook(SCROLLBAR s, void * d) {
    reinterpret_cast<My_Scrollbar*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d);
}

void fl_scrollbar_draw(SCROLLBAR s) {
    reinterpret_cast<My_Scrollbar*>(s)->real_draw();
}

void scrollbar_set_handle_hook(SCROLLBAR s, void * h) {
    reinterpret_cast<My_Scrollbar*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h);
}

int fl_scrollbar_handle(SCROLLBAR s, int e) {
    return reinterpret_cast<My_Scrollbar*>(s)->real_handle(e);
}




SCROLLBAR new_fl_scrollbar(int x, int y, int w, int h, char* label) {
    My_Scrollbar *s = new My_Scrollbar(x, y, w, h, label);
    return s;
}

void free_fl_scrollbar(SCROLLBAR s) {
    delete reinterpret_cast<My_Scrollbar*>(s);
}




int fl_scrollbar_get_linesize(SCROLLBAR s) {
    return reinterpret_cast<Fl_Scrollbar*>(s)->linesize();
}

void fl_scrollbar_set_linesize(SCROLLBAR s, int t) {
    reinterpret_cast<Fl_Scrollbar*>(s)->linesize(t);
}

int fl_scrollbar_get_value(SCROLLBAR s) {
    return reinterpret_cast<Fl_Scrollbar*>(s)->value();
}

void fl_scrollbar_set_value(SCROLLBAR s, int t) {
    reinterpret_cast<Fl_Scrollbar*>(s)->value(t);
}

void fl_scrollbar_set_value2(SCROLLBAR s, int p, int w, int f, int t) {
    reinterpret_cast<Fl_Scrollbar*>(s)->value(p,w,f,t);
}