Add copyright notice
[forms.git] / test / console_ui.C
blob1d4dcc2db9e28daf15311becbd044bd6c76e8484
2  /*
3   *   Copyright (C) 2007, Harbour, All rights reserved.
4   */
6 #include <demo.H>
7 #include <F_Text.H>
8 #include <F_Button.H>
9 #include <F_Menu_Button.H>
10 #include <F_Text_Output.H>
11 #include <F_Browser.H>
12 #include <F_Input.H>
14 F_Text_Output *to = 0;
16 void button_cb(F_Button *b, void *arg)
18 // debug("button callback, bid - %d, arg - %d", b->id(), (long) arg);
19  to->addf("button %d pressed", (long) arg);
22 void menu_button_cb(F_Menu_Button *b, void *arg)
24  to->addf("menu button %d pressed", (long) arg);
27 void input_cb(F_Input *i, void *arg)
29  to->addf("input text %s", i->size() ? i->value() : "empty");
30  i->value(0);
33 void console_ui::init(void)
35  F_Window *win1 = new F_Window(5, 7, 45, 18, "Window1");
36  win1->border(F_SINGLE_BORDER);
37  to = new F_Text_Output(F_UP_BOX, 1, 1, 43, 16, "Screen Log");
38  to->color(F_BLACK, F_WHITE);
39  to->add("very loooooooooooooooooooooooooooooooooooooooooooooong line");
40  win1->add(to);
42  F_Window *win2 = new F_Window(10, 3, 35, 15, "ïËÎÏ2");
43  win2->border(F_DOUBLE_BORDER);
44  F_Button *button = new F_Button(F_UP_BOX, 7, 4, 10, 1, " ëÎÏÐËÁ 2 ");
45  button->color(F_BLACK, F_WHITE);
46  button->callback((F_Callback *)button_cb, (void *)2);
47  win2->add(button);
49  F_Menu_Button *mb = new F_Menu_Button(F_UP_BOX, 10, 7, 15, 1, "  ëÎÏÐËÁ-Menu  ");
50  mb->color(F_BLACK, F_WHITE);
51  mb->add("MenÀ éÔÅÍ 1");
52  mb->add("MenÀ éÔÅÍ 2");
53  mb->add("MenÀ éÔÅÍ 3");
54  mb->mode(0, F_MENU_TOGGLE);
55  mb->mode(1, F_MENU_TOGGLE);
56  mb->mode(2, F_MENU_TOGGLE);
57  mb->set(1);
58  mb->set(2);
59  mb->callback(0, (F_Callback *)menu_button_cb, (void *)1);
60  mb->callback(1, (F_Callback *)menu_button_cb, (void *)2);
61  mb->callback(2, (F_Callback *)menu_button_cb, (void *)3);
62  win2->add(mb);
64  F_Text *txt = new F_Text(F_UP_BOX, 2, 2, 18, 1, "ðÒÉ×ÅÔ, ÞÕÞÕÎÄÒÁ !");
65  txt->color(F_RED, F_WHITE);
66  win2->add(txt);
68  F_Window *win3 = new F_Window(23, 10, 30, 10, "ïËÎÏ3");
69  win3->border(F_DOUBLE_BORDER);
70                                 //  x  y   w  h   len = 14
71  txt = new F_Text(F_UP_BOX, 3, 2, 14, 1, "Hello, world !");
72  txt->color(F_BLACK, F_GREEN);
73  win3->add(txt);
75  button = new F_Button(F_UP_BOX, 8, 4, 10, 1, " Button 1 ");
76  button->callback((F_Callback *)button_cb, (void *)1);
77  win3->add(button);
79  F_Input *i = new F_Input(F_UP_BOX, 7, 6, 14, 2, "Some Input");
80  i->color(F_BLACK, F_MAGENTA);
81  i->callback((F_Callback *)input_cb);
82  win3->add(i);
84  // browser
85  // ...
87  win1->color(F_BLUE, F_BRIGHT_YELLOW);
88  win1->show();
89  win2->color(F_RED, F_WHITE);
90  win2->show();
91  win3->color(F_BLACK, F_WHITE);
92  win3->show();