Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. #include "kolibri_gui.h"
  2.  
  3. int main()
  4. {
  5.   /* Load all libraries, initialize global tables like system color table and
  6.      operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails
  7.      to do it's job. This is all you need to call and all libraries and GUI
  8.      elements can be used after a successful call to this function
  9.   */
  10.   kolibri_gui_init();
  11.  
  12.   /* Set gui_event to REDRAW so that window is drawn in first iteration  */
  13.   unsigned int gui_event = KOLIBRI_EVENT_REDRAW;
  14.  
  15.   struct kolibri_window *main_window = kolibri_new_window(50, 50, 400, 100, "BoardMsg: Send msg to debug board");
  16.   struct check_box *checkbox = kolibri_new_check_box(20, 40, 12, 12, "Append BOARDMSG to entered message.");
  17.   struct edit_box *textbox = kolibri_new_edit_box(20, 55, 40);
  18.   struct kolibri_button *button = kolibri_new_button(310, 55, 14, 14, 0x00123456, kolibri_color_table.color_work_button);
  19.  
  20.   kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox);
  21.   kolibri_window_add_element(main_window, KOLIBRI_CHECK_BOX, checkbox);
  22.   kolibri_window_add_element(main_window, KOLIBRI_BUTTON, button);
  23.  
  24.   do  /* Start of main activity loop */
  25.     {
  26.       if(gui_event == KOLIBRI_EVENT_REDRAW)
  27.         {
  28.           kolibri_handle_event_redraw(main_window);
  29.         }
  30.       else if(gui_event == KOLIBRI_EVENT_KEY)
  31.         {
  32.           kolibri_handle_event_key(main_window);
  33.         }
  34.       else if(gui_event == KOLIBRI_EVENT_BUTTON)
  35.         {
  36.           unsigned int pressed_button = kolibri_button_get_identifier();
  37.  
  38.           if(pressed_button = 0x00123456) /* Our button was pressed */
  39.             {
  40.               if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
  41.                 debug_board_write_str("BOARDMSG: ");
  42.  
  43.               debug_board_write_str(textbox->text);
  44.               debug_board_write_str("\n");
  45.             }
  46.         }
  47.       else if(gui_event == KOLIBRI_EVENT_MOUSE)
  48.         {
  49.           kolibri_handle_event_mouse(main_window);
  50.         }
  51.  
  52.     } while(gui_event = get_os_event()); /* End of main activity loop */
  53.  
  54.   /* kolibri_quit(); */
  55.  
  56.   return 0;
  57. }
  58.