- 生成 24 个 _cfl*.vp(10327 条 extern 声明)+ _types/_enums 常量 - __init__.vp 提供 Fl/Fl_Widget/Fl_Window/Fl_Button/Fl_Input/Fl_Text_Buffer/Fl_Group/Fl_Menu_Bar/Fl_Native_File_Chooser 等包装类 - 回调(Fl_Callback)按 bytes 不透明处理,菜单回调位传 t.CPtr(0) - 新增 examples/hello.vp、dialog.vp 冒烟样例,26 个 .vp 全部通过 vast parse - 内嵌 cfltk(C API 封装)与 FLTK 1.4 完整源码,构建目标 cfltk2
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#include <FL/Fl.H>
|
|
#include <FL/Fl_Box.H>
|
|
#include <FL/Fl_Button.H>
|
|
#include <FL/Fl_Window.H>
|
|
#include <cstdio>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
using namespace std::chrono_literals;
|
|
|
|
void cb(Fl_Widget *w, void *data) {
|
|
auto box = (Fl_Box *)data;
|
|
std::thread writer([=] {
|
|
for (int i = 0; i != 1000; i++) {
|
|
std::this_thread::sleep_for(10ms);
|
|
char buf[100];
|
|
snprintf(buf, 100, "Hello %d", i);
|
|
Fl::lock();
|
|
box->copy_label(buf);
|
|
Fl::awake();
|
|
Fl::unlock();
|
|
}
|
|
});
|
|
writer.detach();
|
|
std::thread reader([=] {
|
|
while (true) {
|
|
std::this_thread::sleep_for(1000ms);
|
|
Fl::lock();
|
|
printf("%s\n", box->label());
|
|
fflush(stdout);
|
|
Fl::awake();
|
|
Fl::unlock();
|
|
}
|
|
});
|
|
reader.detach();
|
|
}
|
|
|
|
int main() {
|
|
Fl::lock();
|
|
auto win = new Fl_Window(400, 300);
|
|
auto box = new Fl_Box(0, 0, 400, 200, "Hello");
|
|
auto but = new Fl_Button(160, 210, 80, 40, "Click");
|
|
win->end();
|
|
win->show();
|
|
but->callback(cb, box);
|
|
|
|
return Fl::run();
|
|
} |