summaryrefslogtreecommitdiff
path: root/src/c_fl_color_chooser.cpp
blob: fa34171f46bd654637123e89872cc333083313ec (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
112
113
114
115
116
117
118
119


#include <FL/Fl_Color_Chooser.H>
#include "c_fl_color_chooser.h"
#include "c_fl_type.h"




class My_Color_Chooser : public Fl_Color_Chooser {
    public:
        using Fl_Color_Chooser::Fl_Color_Chooser;
        friend void color_chooser_set_draw_hook(COLOR_CHOOSER n, void * d);
        friend void fl_color_chooser_draw(COLOR_CHOOSER n);
        friend void color_chooser_set_handle_hook(COLOR_CHOOSER n, void * h);
        friend int fl_color_chooser_handle(COLOR_CHOOSER n, 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_Color_Chooser::draw() {
    (*draw_hook)(this->user_data());
}

void My_Color_Chooser::real_draw() {
    Fl_Color_Chooser::draw();
}

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

int My_Color_Chooser::real_handle(int e) {
    return Fl_Color_Chooser::handle(e);
}

void color_chooser_set_draw_hook(COLOR_CHOOSER n, void * d) {
    reinterpret_cast<My_Color_Chooser*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d);
}

void fl_color_chooser_draw(COLOR_CHOOSER n) {
    reinterpret_cast<My_Color_Chooser*>(n)->real_draw();
}

void color_chooser_set_handle_hook(COLOR_CHOOSER n, void * h) {
    reinterpret_cast<My_Color_Chooser*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h);
}

int fl_color_chooser_handle(COLOR_CHOOSER n, int e) {
    return reinterpret_cast<My_Color_Chooser*>(n)->real_handle(e);
}




COLOR_CHOOSER new_fl_color_chooser(int x, int y, int w, int h, char* label) {
    My_Color_Chooser *n = new My_Color_Chooser(x, y, w, h, label);
    return n;
}

void free_fl_color_chooser(COLOR_CHOOSER n) {
    delete reinterpret_cast<My_Color_Chooser*>(n);
}




double fl_color_chooser_r(COLOR_CHOOSER n) {
    return reinterpret_cast<My_Color_Chooser*>(n)->r();
}

double fl_color_chooser_g(COLOR_CHOOSER n) {
    return reinterpret_cast<My_Color_Chooser*>(n)->g();
}

double fl_color_chooser_b(COLOR_CHOOSER n) {
    return reinterpret_cast<My_Color_Chooser*>(n)->b();
}

int fl_color_chooser_rgb(COLOR_CHOOSER n, int r, int g, int b) {
    return reinterpret_cast<My_Color_Chooser*>(n)->rgb(r,g,b);
}




double fl_color_chooser_hue(COLOR_CHOOSER n) {
    return reinterpret_cast<My_Color_Chooser*>(n)->hue();
}

double fl_color_chooser_saturation(COLOR_CHOOSER n) {
    return reinterpret_cast<My_Color_Chooser*>(n)->saturation();
}

double fl_color_chooser_value(COLOR_CHOOSER n) {
    return reinterpret_cast<My_Color_Chooser*>(n)->value();
}

int fl_color_chooser_hsv(COLOR_CHOOSER n, int h, int s, int v) {
    return reinterpret_cast<My_Color_Chooser*>(n)->hsv(h,s,v);
}




int fl_color_chooser_get_mode(COLOR_CHOOSER n) {
    return reinterpret_cast<My_Color_Chooser*>(n)->mode();
}

void fl_color_chooser_set_mode(COLOR_CHOOSER n, int m) {
    reinterpret_cast<My_Color_Chooser*>(n)->mode(m);
}