summaryrefslogtreecommitdiff
path: root/src/c_fl_window.cpp
blob: 14136467166a79f58266ca2bd6c0b0378ac81d54 (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


#include <FL/Fl_Window.H>
#include <FL/Fl_RGB_Image.H>
#include "c_fl_window.h"




typedef void (hook)(void*);
typedef hook* hook_p;




class My_Window : public Fl_Window {
    public:
        using Fl_Window::Fl_Window;
        friend void window_set_draw_hook(WINDOW n, void * d);
        friend void fl_window_draw(WINDOW n);
    protected:
        void draw();
        void real_draw();
        hook_p draw_hook;
};


void My_Window::draw() {
    (*draw_hook)(this->user_data());
}


void My_Window::real_draw() {
    Fl_Window::draw();
}


void window_set_draw_hook(WINDOW n, void * d) {
    reinterpret_cast<My_Window*>(n)->draw_hook = reinterpret_cast<hook_p>(d);
}


void fl_window_draw(WINDOW n) {
    reinterpret_cast<My_Window*>(n)->real_draw();
}




WINDOW new_fl_window(int x, int y, int w, int h, char* label) {
    My_Window *n = new My_Window(x, y, w, h, label);
    return n;
}


WINDOW new_fl_window2(int w, int h) {
    My_Window *n = new My_Window(w, h);
    return n;
}


void free_fl_window(WINDOW n) {
    delete reinterpret_cast<My_Window*>(n);
}




void fl_window_show(WINDOW n) {
    reinterpret_cast<Fl_Window*>(n)->show();
}


void fl_window_hide(WINDOW n) {
    reinterpret_cast<Fl_Window*>(n)->hide();
}


void fl_window_set_label(WINDOW n, char* text) {
    reinterpret_cast<Fl_Window*>(n)->copy_label(text);
}


void fl_window_size_range(WINDOW n, int lw, int lh, int hw, int hh, int dw, int dh, int a) {
    reinterpret_cast<Fl_Window*>(n)->size_range(lw, lh, hw, hh, dw, dh, a);
}


void fl_window_set_icon(WINDOW n, void * img) {
    reinterpret_cast<Fl_Window*>(n)->icon(reinterpret_cast<Fl_RGB_Image*>(img));
}


void fl_window_set_modal(WINDOW n) {
    reinterpret_cast<Fl_Window*>(n)->set_modal();
}


void fl_window_set_non_modal(WINDOW n) {
    reinterpret_cast<Fl_Window*>(n)->set_non_modal();
}