Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include "window.h"
- #include "generic.h"
- #include "tabcontrol.h"
- #include "tabcontrolex.h"
- #include "button.h"
- #include "sizer.h"
- #include "checkbox.h"
- #pragma comment (lib, "Lychee.lib")
- #ifdef _UNICODE
- #if defined _M_IX86
- #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #elif defined _M_IA64
- #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #elif defined _M_X64
- #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #else
- #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #endif
- #endif
- class mainwindow {
- public:
- hinstance hinst;
- window *w;
- public:
- button *btn1;
- checkbox *checkbox1;
- checkbox *checkbox2;
- checkbox *checkbox3;
- checkbox *checkbox4;
- checkbox *checkbox1_2;
- checkbox *checkbox2_2;
- checkbox *checkbox3_2;
- checkbox *checkbox4_2;
- sizer *sizer1;
- sizer *sizer2;
- sizer *sizer3;
- sizer *sizer4;
- enum LYCHEE_TEST_ID : uint32_t {
- BUTTON1 = 1,
- };
- public:
- static LYCHEE_FUNCTION(on_button1, {
- MessageBox(0, L"Button1 Clicked", 0, 0);
- })
- static void on_size(hwnd wnd, wparam w, lparam l, lpvoid parameter) {
- rectangle r = window::get_window(wnd)->get_client_rectangle();
- reinterpret_cast<mainwindow*>(parameter)->btn1->expand_horizontal();
- reinterpret_cast<mainwindow*>(parameter)->sizer3->size(r.right / 2 - 13);
- reinterpret_cast<mainwindow*>(parameter)->sizer3->pos(6, 25);
- }
- static void on_create(hwnd wnd, wparam w, lparam l, lpvoid parameter) {
- mainwindow *m = reinterpret_cast<mainwindow*>(parameter);
- m->btn1 = new button(mainwindow::BUTTON1, 0, 0, 0, 0, L"button1", wnd);
- m->btn1->set_window_size(0, 20);
- m->btn1->set_window_pos(0, 5);
- m->btn1->expand_horizontal(5);
- rectangle r = window::get_window(wnd)->get_client_rectangle();
- m->checkbox1 = new checkbox(mainwindow::BUTTON1, 0, 0, 0, 0, L"checkbox1", wnd);
- m->checkbox2 = new checkbox(mainwindow::BUTTON1, 0, 0, 0, 0, L"checkbox2", wnd);
- m->checkbox3 = new checkbox(mainwindow::BUTTON1, 0, 0, 0, 0, L"checkbox3", wnd);
- m->checkbox4 = new checkbox(mainwindow::BUTTON1, 0, 0, 0, 0, L"checkbox4", wnd);
- m->sizer1 = new sizer(sizer::orientation::vertical, 25);
- m->sizer1->add(std::vector<widget*>({ m->checkbox1, m->checkbox2, m->checkbox3, m->checkbox4 }));
- m->checkbox1_2 = new checkbox(mainwindow::BUTTON1, 0, 0, 0, 0, L"checkbox5", wnd);
- m->checkbox2_2 = new checkbox(mainwindow::BUTTON1, 0, 0, 0, 0, L"checkbox6", wnd);
- m->checkbox3_2 = new checkbox(mainwindow::BUTTON1, 0, 0, 0, 0, L"checkbox7", wnd);
- m->checkbox4_2 = new checkbox(mainwindow::BUTTON1, 0, 0, 0, 0, L"checkbox8", wnd);
- m->sizer2 = new sizer(sizer::orientation::vertical, 25);
- m->sizer2->add(std::vector<widget*>({ m->checkbox1_2, m->checkbox2_2, m->checkbox3_2, m->checkbox4_2 }));
- m->sizer3 = new sizer(sizer::orientation::horizontal);
- m->sizer3->add(m->sizer1);
- m->sizer3->add(m->sizer2);
- m->sizer3->size(r.right / 2 - 13);
- m->sizer3->pos(6, 25);
- m->sizer3->insert_hyphen();
- }
- mainwindow(hinstance hinst) {
- this->hinst = hinst;
- w = new window(hinst, L"Lychee Tester Window", L"CLychee", &on_create, this, 500, 500);
- w->add_wndproc_listener(WM_SIZE, &on_size, false, this);
- w->add_message_handler(mainwindow::BUTTON1, &on_button1);
- }
- int message_loop() {
- return w->handle_message();
- }
- };
- int CALLBACK WinMain(
- _In_ HINSTANCE hInstance,
- _In_ HINSTANCE hPrevInstance,
- _In_ LPSTR lpCmdLine,
- _In_ int nCmdShow
- )
- {
- return mainwindow(hInstance).message_loop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement