- 生成 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.2 KiB
C++
49 lines
1.2 KiB
C++
#include <cfltk2/cfl.h>
|
|
#include <cfltk2/cfl_box.h>
|
|
#include <cfltk2/cfl_button.h>
|
|
#include <cfltk2/cfl_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();
|
|
Fl_Box_set_label(box, buf);
|
|
Fl_awake();
|
|
Fl_unlock();
|
|
}
|
|
});
|
|
writer.detach();
|
|
std::thread reader([=] {
|
|
while (true) {
|
|
std::this_thread::sleep_for(1000ms);
|
|
Fl_lock();
|
|
printf("%s\n", Fl_Box_label(box));
|
|
fflush(stdout);
|
|
Fl_awake();
|
|
Fl_unlock();
|
|
}
|
|
});
|
|
reader.detach();
|
|
}
|
|
|
|
int main() {
|
|
Fl_lock();
|
|
auto win = Fl_Window_new(100, 100, 400, 300, "");
|
|
auto box = Fl_Box_new(0, 0, 400, 200, "Hello");
|
|
auto but = Fl_Button_new(160, 210, 80, 40, "Click");
|
|
Fl_Window_end(win);
|
|
Fl_Window_show(win);
|
|
Fl_Button_set_callback(but, cb, box);
|
|
|
|
return Fl_run();
|
|
} |