From 9c302ae433fd9a41cf22e43bf185255ff8afa283 Mon Sep 17 00:00:00 2001 From: MoAlyousef Date: Fri, 22 Sep 2023 00:49:38 +0300 Subject: [PATCH] update counter example --- examples/counter.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/examples/counter.c b/examples/counter.c index af01df5..2ec1b32 100644 --- a/examples/counter.c +++ b/examples/counter.c @@ -3,15 +3,16 @@ #include #include #include +#include #include // Fl_register_images #include #include #include #include -#define BLUE Fl_get_rgb_color(0x42, 0xA5, 0xF5) -#define SEL_BLUE Fl_get_rgb_color(0x21, 0x96, 0xF3) -#define GRAY Fl_get_rgb_color(0x75, 0x75, 0x75) +#define BLUE 0x42A5F500 +#define SEL_BLUE 0x2196F300 +#define GRAY 0x75757500 #define WIDTH 600 #define HEIGHT 400 @@ -34,12 +35,28 @@ void draw(Fl_Widget *w, void *data) { int main(void) { Fl_init_all(); // init all styles Fl_Window *w = Fl_Window_new(100, 100, WIDTH, HEIGHT, "Flutter-like"); - Fl_Box *bar = Fl_Box_new(0, 0, WIDTH, 60, " FLTK App!"); - Fl_Box *text = Fl_Box_new(250, 180, 100, 40, "You have pushed the button this many times:"); - Fl_Box *count = Fl_Box_new(250, 220, 100, 40, "0"); + Fl_Flex *col = Fl_Flex_new(0, 0, WIDTH, HEIGHT, NULL); + Fl_Box *bar = Fl_Box_new(0, 0, 0, 0, " FLTK App!"); + Fl_Flex_set_size(col, (Fl_Widget *)bar, 60); + Fl_Box_set_align(bar, Fl_Align_Left | Fl_Align_Inside); + Fl_Box *text = Fl_Box_new(0, 0, 0, 0, "You have pushed the button this many times:"); + Fl_Box_set_align(text, Fl_Align_Bottom | Fl_Align_Inside); + Fl_Box *count = Fl_Box_new(0, 0, 0, 0, "0"); + Fl_Box_set_align(count, Fl_Align_Top | Fl_Align_Inside); + Fl_Flex *row = Fl_Flex_new(0, 0, 0, 0, NULL); + Fl_Flex_set_type(row, 1); // row + Fl_Flex_set_size(col, (Fl_Widget *)row, 60); + Fl_Box_new(0, 0, 0, 0, NULL); Fl_Button *but = Fl_Button_new(WIDTH - 100, HEIGHT - 100, 60, 60, "@+6plus"); - Fl_Window_resizable(w, w); + Fl_Flex_set_size(row, (Fl_Widget *)but, 60); + Fl_Box *spacing1 = Fl_Box_new(0, 0, 0, 0, NULL); + Fl_Flex_set_size(row, (Fl_Widget *)spacing1, 20); + Fl_Flex_end(row); + Fl_Box *spacing2 = Fl_Box_new(0, 0, 0, 0, NULL); + Fl_Flex_set_size(col, (Fl_Widget *)spacing2, 20); + Fl_Flex_end(col); Fl_Window_end(w); + Fl_Window_resizable(w, w); Fl_Window_show(w); Fl_background(255, 255, 255); @@ -49,7 +66,6 @@ int main(void) { Fl_Box_set_label_size(bar, 22); Fl_Box_set_label_color(bar, Fl_Color_White); Fl_Box_set_color(bar, BLUE); - Fl_Box_set_align(bar, Fl_Align_Left | Fl_Align_Inside); Fl_Box_draw(bar, draw, NULL); Fl_Box_set_label_size(text, 18);