X-Git-Url: https://eleni.mutantstargoat.com/git/?p=winnie;a=blobdiff_plain;f=src%2Fmain.cc;h=cb6018d43dededc900218769f9886cc1f5cbe1e2;hp=f87b011559856e035e5d1af181e7be5bc0c57eeb;hb=65eda3d5a8e4ad8d28bda12cace044628c1a69be;hpb=026158b5ee6ffac95c3efc6eee4c155497cd8594 diff --git a/src/main.cc b/src/main.cc index f87b011..cb6018d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,5 +1,6 @@ #include #include +#include #include "winnie.h" @@ -11,11 +12,14 @@ static void cleanup(); int main() { - winnie_init(); + if(!winnie_init()) { + exit(1); + } + atexit(cleanup); Window *win1 = new Window; - win1->set_title("title1"); + win1->set_title("red"); win1->move(5, 10); win1->resize(200, 300); win1->set_display_callback(display); @@ -23,7 +27,17 @@ int main() win1->set_mouse_button_callback(button); win1->set_mouse_motion_callback(motion); + Window *win2 = new Window; + win2->set_title("yellow"); + win2->move(150, 10); + win2->resize(200, 300); + win2->set_display_callback(display); + win2->set_keyboard_callback(keyboard); + win2->set_mouse_button_callback(button); + win2->set_mouse_motion_callback(motion); + wm->add_window(win1); + wm->add_window(win2); while(1) { process_events(); @@ -32,11 +46,16 @@ int main() static void display(Window *win) { - if(wm->get_focused_window() != win) { - fill_rect(win->get_absolute_rect(), 106, 106, 250); + const char *win_title = win->get_title(); + const char *t1 = "red"; + const char *t2 = "yellow"; + + if(!strcmp(win_title, t1)) { + fill_rect(win->get_absolute_rect(), 247, 68, 50); } - else { - fill_rect(win->get_absolute_rect(), 0, 0, 255); + + if(!strcmp(win_title, t2)) { + fill_rect(win->get_absolute_rect(), 255, 215, 78); } }