summaryrefslogtreecommitdiff
path: root/body/c_fl_table_row.cpp
blob: 8094df4dc418b020cab010ad3211981cb4df8a78 (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
120
121
122
123
124
125
126
127
128
129


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


#include <FL/Fl_Table_Row.H>
#include "c_fl_table_row.h"




//  Exports from Ada

extern "C" void widget_draw_hook(void * ud);
extern "C" int widget_handle_hook(void * ud, int e);

extern "C" void table_draw_cell_hook(void * ud, int e, int r, int c, int x, int y, int w, int h);




//  Non-friend protected access

class Friend_Table_Row : Fl_Table_Row {
public:
    using Fl_Table_Row::find_cell;
};




//  Attaching all relevant hooks and friends

class My_Table_Row : public Fl_Table_Row {
public:
    using Fl_Table_Row::Fl_Table_Row;

    friend void fl_table_row_draw(ROWTABLE t);
    friend void fl_table_row_draw_cell(ROWTABLE t, int e, int r, int c, int x, int y, int w, int h);
    friend int fl_table_row_handle(ROWTABLE t, int e);

    void draw();
    void draw_cell(Fl_Table::TableContext e, int r=0, int c=0, int x=0, int y=0, int w=0, int h=0);
    int handle(int e);
};

void My_Table_Row::draw() {
    widget_draw_hook(this->user_data());
}

void My_Table_Row::draw_cell(Fl_Table::TableContext e, int r, int c, int x, int y, int w, int h) {
    table_draw_cell_hook(this->user_data(), static_cast<int>(e), r, c, x, y, w, h);
}

int My_Table_Row::handle(int e) {
    return widget_handle_hook(this->user_data(), e);
}




//  Flattened C API

ROWTABLE new_fl_table_row(int x, int y, int w, int h, char * label) {
    My_Table_Row *t = new My_Table_Row(x, y, w, h, label);
    return t;
}

void free_fl_table_row(ROWTABLE t) {
    delete static_cast<My_Table_Row*>(t);
}




int fl_table_row_get_rows(ROWTABLE t) {
    return static_cast<Fl_Table_Row*>(t)->rows();
}

void fl_table_row_set_rows(ROWTABLE t, int r) {
    static_cast<Fl_Table_Row*>(t)->rows(r);
}




int fl_table_row_row_selected(ROWTABLE t, int r) {
    return static_cast<Fl_Table_Row*>(t)->row_selected(r);
}

int fl_table_row_select_row(ROWTABLE t, int r, int f) {
    return static_cast<Fl_Table_Row*>(t)->select_row(r, f);
}

void fl_table_row_select_all_rows(ROWTABLE t, int f) {
    static_cast<Fl_Table_Row*>(t)->select_all_rows(f);
}

int fl_table_row_get_type(ROWTABLE t) {
    return static_cast<int>(static_cast<Fl_Table_Row*>(t)->type());
}

void fl_table_row_set_type(ROWTABLE t, int v) {
    static_cast<Fl_Table_Row*>(t)->type(static_cast<Fl_Table_Row::TableRowSelectMode>(v));
}




void fl_table_row_draw(ROWTABLE t) {
    static_cast<My_Table_Row*>(t)->Fl_Table_Row::draw();
}

void fl_table_row_draw_cell(ROWTABLE t, int e, int r, int c, int x, int y, int w, int h) {
    static_cast<My_Table_Row*>(t)->Fl_Table_Row::draw_cell
        (static_cast<Fl_Table::TableContext>(e), r, c, x, y, w, h);
}

int fl_table_row_find_cell(ROWTABLE t, int e, int r, int c, int &x, int &y, int &w, int &h) {
    return (static_cast<Fl_Table_Row*>(t)->*(&Friend_Table_Row::find_cell))
        (static_cast<Fl_Table::TableContext>(e), r, c, x, y, w, h);
}

int fl_table_row_handle(ROWTABLE t, int e) {
    return static_cast<My_Table_Row*>(t)->Fl_Table_Row::handle(e);
}