summaryrefslogtreecommitdiff
path: root/src/c_fl_overlay_window.cpp
blob: 3ce76a4f1747a3a5dc931b92408b9bdbd3971cd5 (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


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


#include <FL/Fl_Overlay_Window.H>
#include "c_fl_overlay_window.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 overlay_window_draw_overlay_hook(void * ud);




//  Attaching all relevant hooks and friends

class My_Overlay_Window : public Fl_Overlay_Window {
public:
    using Fl_Overlay_Window::Fl_Overlay_Window;

    friend OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label);
    friend OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label);

    friend void fl_overlay_window_draw(OVERLAYWINDOW w);
    friend int fl_overlay_window_handle(OVERLAYWINDOW w, int e);

    void draw();
    void draw_overlay();
    int handle(int e);
};

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

void My_Overlay_Window::draw_overlay() {
    overlay_window_draw_overlay_hook(this->user_data());
}

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




//  Flattened C API

OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label) {
    My_Overlay_Window *ow = new My_Overlay_Window(x, y, w, h, label);
    return ow;
}

OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label) {
    My_Overlay_Window *ow = new My_Overlay_Window(w, h, label);
    return ow;
}

void free_fl_overlay_window(OVERLAYWINDOW w) {
    delete reinterpret_cast<My_Overlay_Window*>(w);
}




int fl_overlay_window_can_do_overlay(OVERLAYWINDOW w) {
    return reinterpret_cast<Fl_Overlay_Window*>(w)->can_do_overlay();
}

void fl_overlay_window_resize(OVERLAYWINDOW ow, int x, int y, int w, int h) {
    reinterpret_cast<Fl_Overlay_Window*>(ow)->resize(x, y, w, h);
}




void fl_overlay_window_show(OVERLAYWINDOW w) {
    reinterpret_cast<Fl_Overlay_Window*>(w)->show();
}

void fl_overlay_window_hide(OVERLAYWINDOW w) {
    reinterpret_cast<Fl_Overlay_Window*>(w)->hide();
}

void fl_overlay_window_flush(OVERLAYWINDOW w) {
    reinterpret_cast<Fl_Overlay_Window*>(w)->flush();
}




void fl_overlay_window_redraw_overlay(OVERLAYWINDOW w) {
    reinterpret_cast<Fl_Overlay_Window*>(w)->redraw_overlay();
}

void fl_overlay_window_draw(OVERLAYWINDOW w) {
    reinterpret_cast<My_Overlay_Window*>(w)->Fl_Overlay_Window::draw();
}

int fl_overlay_window_handle(OVERLAYWINDOW w, int e) {
    return reinterpret_cast<My_Overlay_Window*>(w)->Fl_Overlay_Window::handle(e);
}