Egrome是一个基于EGE的开源图形应用程序框架,目前基于EGE20.08
Egrome的使用方式有点类似于Qt,通过如下方式就可以创建一个基本的1000×600的应用程序窗口
#include<egrome/App> #include<egrome/Block> int main(){ Block block{Rect{0,0,1000,600}}; App app{&block}; app.run(); return 0; }
也可以通过继承Block来实现自定义内容,框架内也提供了一些已经封装好的控件(如按钮、文本标签、单选框、复选框等)
以下是Github仓库中用于调试和测试单选框控件的代码:
#include "radiobox.h" #include "App.h" class Window : public Block { RadioBox *radiobox1; RadioBox *radiobox2; RadioBox *radiobox3; RadioBoxGroup *radioboxgroup; public: Window(const Rect &rect) : Block(rect) { radioboxgroup = new RadioBoxGroup(); radiobox1 = new RadioBox(Rect(10, 10, 100, 20), *radioboxgroup, this); radiobox1->setText(L"RadioBox1"); radiobox2 = new RadioBox(Rect(10, 40, 100, 20), *radioboxgroup, this); radiobox2->setText(L"RadioBox2"); radiobox3 = new RadioBox(Rect(10, 70, 100, 20), *radioboxgroup, this); radiobox3->setText(L"RadioBox3"); radiobox1->selectedChanged.connect( [this](bool selected) { std::cout << "RadioBox1 selected: " << selected << std::endl; }); radiobox2->selectedChanged.connect( [this](bool selected) { std::cout << "RadioBox2 selected: " << selected << std::endl; }); radiobox3->selectedChanged.connect( [this](bool selected) { std::cout << "RadioBox3 selected: " << selected << std::endl; }); } ~Window() { delete radioboxgroup; delete radiobox1; delete radiobox2; delete radiobox3; } }; int main() { Window window(Rect(0, 0, 1000, 800)); App app{&window}; app.run(); return 0; }
上述代码中类Window通过继承Block类实现了自定义功能
项目:Egrome