| 20 | lemon_sysinfo_t sysInfo; |
| 21 | |
| 22 | int main(int argc, char** argv){ |
| 23 | Lemon::Graphics::LoadImage("/initrd/banner.png", &banner); |
| 24 | |
| 25 | bannerW = new Lemon::GUI::Bitmap({{0, 0}, {300, banner.height}}, &banner); |
| 26 | |
| 27 | int winWidth = (banner.width > 200) ? banner.width : 200; |
| 28 | |
| 29 | window = new Lemon::GUI::Window("System Information", {winWidth, 300}, WINDOW_FLAGS_RESIZABLE, Lemon::GUI::WindowType::GUI); |
| 30 | window->AddWidget(bannerW); |
| 31 | |
| 32 | int ypos = banner.height + 4; |
| 33 | sysInfo = Lemon::SysInfo(); |
| 34 | |
| 35 | char buf[64]; |
| 36 | |
| 37 | syscall(SYS_UNAME, versionString,0,0,0,0); |
| 38 | |
| 39 | window->AddWidget(new Lemon::GUI::Label(versionString, {{4, ypos}, {200, 12}})); |
| 40 | ypos += 24; |
| 41 | |
| 42 | snprintf(buf, 64, "Total System Memory: %lu MB (%lu KB)", sysInfo.totalMem / 1024, sysInfo.totalMem); |
| 43 | totalMem = new Lemon::GUI::Label(buf, {{4, ypos}, {200, 12}}); |
| 44 | window->AddWidget(totalMem); |
| 45 | ypos += 16; |
| 46 | |
| 47 | snprintf(buf, 64, "Used System Memory: %lu MB (%lu KB)", sysInfo.usedMem / 1024, sysInfo.usedMem); |
| 48 | usedMem = new Lemon::GUI::Label(buf, {{4, ypos}, {200, 12}}); |
| 49 | window->AddWidget(usedMem); |
| 50 | ypos += 16; |
| 51 | |
| 52 | while(!window->closed){ |
| 53 | Lemon::LemonEvent ev; |
| 54 | while(window->PollEvent(ev)){ |
| 55 | window->GUIHandleEvent(ev); |
| 56 | } |
| 57 | |
| 58 | window->Paint(); |
| 59 | |
| 60 | lemon_sysinfo_t _sysInfo = Lemon::SysInfo(); |
| 61 | |
| 62 | if(_sysInfo.usedMem != sysInfo.usedMem){ |
| 63 | snprintf(buf, 64, "Used System Memory: %lu MB (%lu KB)", sysInfo.usedMem / 1024, sysInfo.usedMem); |
| 64 | usedMem->label = buf; |
| 65 | } sysInfo = _sysInfo; |
| 66 | |
| 67 | window->WaitEvent(); |
| 68 | } |
| 69 | } |