2016-08-15 21:52:50 +02:00
|
|
|
/*
|
|
|
|
KolibriGUI demobox
|
|
|
|
-Button
|
|
|
|
-CheckBox
|
|
|
|
-EditBox
|
|
|
|
-Frame
|
|
|
|
|
|
|
|
Free for all
|
|
|
|
|
|
|
|
Initially written by ashmew2, 2015
|
|
|
|
|
|
|
|
Updated by Siemargl, 2016
|
|
|
|
|
|
|
|
ToDo
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <kos32sys.h>
|
2016-06-30 18:10:04 +02:00
|
|
|
#include <kolibri_gui.h>
|
2016-04-11 15:38:48 +02:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2016-04-12 20:50:48 +02:00
|
|
|
/* Load all libraries, initialize global tables like system color table and
|
2016-04-11 15:38:48 +02:00
|
|
|
operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails
|
|
|
|
to do it's job. This is all you need to call and all libraries and GUI
|
|
|
|
elements can be used after a successful call to this function
|
|
|
|
*/
|
|
|
|
kolibri_gui_init();
|
|
|
|
/* Set gui_event to REDRAW so that window is drawn in first iteration */
|
|
|
|
unsigned int gui_event = KOLIBRI_EVENT_REDRAW;
|
2016-04-11 18:50:10 +02:00
|
|
|
oskey_t key;
|
2016-04-11 15:38:48 +02:00
|
|
|
|
2016-08-15 21:52:50 +02:00
|
|
|
kolibri_window *main_window = kolibri_new_window(50, 50, 400, 120, "BoardMsg: OpenDialog 0.12");
|
|
|
|
check_box *checkbox = kolibri_new_check_box(20, 45, 12, 12, "Append BOARDMSG to entered message.");
|
|
|
|
|
|
|
|
edit_box *editbox_interlock = NULL;
|
|
|
|
edit_box *textbox = kolibri_new_edit_box(20, 60, 40, &editbox_interlock);
|
2016-08-18 17:45:53 +02:00
|
|
|
edit_box *textbox2 = kolibri_new_edit_box(20, 80, 30, &editbox_interlock);
|
2016-07-31 16:43:54 +02:00
|
|
|
kolibri_button *button = kolibri_new_button(310, 60, 24, 14, 0x21, kolibri_color_table.color_work_button);
|
2016-08-15 21:52:50 +02:00
|
|
|
frame *fr = kolibri_new_frame(X_Y(12, 350), X_Y(35, 70), 0x00FCFCFC, 0x00DCDCDC, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
|
2016-04-12 20:50:48 +02:00
|
|
|
|
2016-04-11 15:38:48 +02:00
|
|
|
kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox);
|
2016-08-15 21:52:50 +02:00
|
|
|
kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox2);
|
2016-04-11 15:38:48 +02:00
|
|
|
kolibri_window_add_element(main_window, KOLIBRI_CHECK_BOX, checkbox);
|
|
|
|
kolibri_window_add_element(main_window, KOLIBRI_BUTTON, button);
|
2016-07-31 16:43:54 +02:00
|
|
|
kolibri_window_add_element(main_window, KOLIBRI_FRAME, fr);
|
2016-08-18 17:45:53 +02:00
|
|
|
|
|
|
|
(*edit_box_set_text)(textbox2, "Sample text very long to get shorted");
|
2016-04-12 20:50:48 +02:00
|
|
|
|
2016-04-12 21:12:45 +02:00
|
|
|
extern volatile unsigned press_key;
|
2016-04-12 20:50:48 +02:00
|
|
|
|
2016-04-11 15:38:48 +02:00
|
|
|
do /* Start of main activity loop */
|
|
|
|
{
|
|
|
|
if(gui_event == KOLIBRI_EVENT_REDRAW)
|
|
|
|
{
|
|
|
|
kolibri_handle_event_redraw(main_window);
|
|
|
|
}
|
|
|
|
else if(gui_event == KOLIBRI_EVENT_KEY)
|
2016-04-12 20:50:48 +02:00
|
|
|
{
|
2016-04-11 18:50:10 +02:00
|
|
|
key = get_key();
|
|
|
|
switch (key.code)
|
|
|
|
{
|
|
|
|
case 13:
|
2016-04-12 21:12:45 +02:00
|
|
|
if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
|
2016-04-11 18:50:10 +02:00
|
|
|
debug_board_write_str("BOARDMSG: ");
|
|
|
|
|
|
|
|
debug_board_write_str(textbox->text);
|
|
|
|
debug_board_write_str("\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
press_key = key.val;
|
2016-04-12 21:12:45 +02:00
|
|
|
|
2016-04-11 15:38:48 +02:00
|
|
|
kolibri_handle_event_key(main_window);
|
|
|
|
}
|
|
|
|
else if(gui_event == KOLIBRI_EVENT_BUTTON)
|
|
|
|
{
|
|
|
|
unsigned int pressed_button = kolibri_button_get_identifier();
|
2016-04-11 18:50:10 +02:00
|
|
|
switch (pressed_button)
|
|
|
|
{
|
|
|
|
case 0x21:
|
|
|
|
if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
|
|
|
|
debug_board_write_str("BOARDMSG: ");
|
|
|
|
debug_board_write_str(textbox->text);
|
|
|
|
debug_board_write_str("\n");
|
|
|
|
break;
|
2016-06-30 18:10:04 +02:00
|
|
|
case BUTTON_CLOSE:
|
2016-04-11 18:50:10 +02:00
|
|
|
kolibri_exit();
|
|
|
|
}
|
|
|
|
}
|
2016-04-11 15:38:48 +02:00
|
|
|
else if(gui_event == KOLIBRI_EVENT_MOUSE)
|
|
|
|
{
|
|
|
|
kolibri_handle_event_mouse(main_window);
|
|
|
|
}
|
|
|
|
|
2016-07-31 16:43:54 +02:00
|
|
|
} while((gui_event = get_os_event())); /* End of main activity loop */
|
2016-04-11 15:38:48 +02:00
|
|
|
|
|
|
|
/* kolibri_quit(); */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|