Subversion Repositories Kolibri OS

Rev

Rev 6393 | Rev 6397 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6391 ashmew2 1
#include "kolibri_gui.h"
2
 
3
int main()
4
{
6395 siemargl 5
  /* Load all libraries, initialize global tables like system color table and
6391 ashmew2 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
  /* Set gui_event to REDRAW so that window is drawn in first iteration  */
12
  unsigned int gui_event = KOLIBRI_EVENT_REDRAW;
6393 punk_joker 13
  oskey_t key;
6391 ashmew2 14
 
6393 punk_joker 15
  struct kolibri_window *main_window = kolibri_new_window(50, 50, 400, 100, "BoardMsg: OpenDialog 0.12");
6391 ashmew2 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);
6393 punk_joker 18
  struct kolibri_button *button = kolibri_new_button(310, 55, 24, 14, 0x21, kolibri_color_table.color_work_button);
6395 siemargl 19
 
6391 ashmew2 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);
6395 siemargl 23
 
24
  volatile unsigned press_key;
25
 
6391 ashmew2 26
  do  /* Start of main activity loop */
27
    {
28
      if(gui_event == KOLIBRI_EVENT_REDRAW)
29
	{
30
	  kolibri_handle_event_redraw(main_window);
31
	}
32
      else if(gui_event == KOLIBRI_EVENT_KEY)
6395 siemargl 33
	{
34
/* siemargl commented out because keys stealed from textinput
6393 punk_joker 35
	  key = get_key();
36
	  switch (key.code)
37
	  {
38
		  case 13:
6395 siemargl 39
			if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set * /
6393 punk_joker 40
				debug_board_write_str("BOARDMSG: ");
41
 
42
			debug_board_write_str(textbox->text);
43
			debug_board_write_str("\n");
44
			break;
45
	  }
46
	  press_key = key.val;
6395 siemargl 47
*/
6391 ashmew2 48
	  kolibri_handle_event_key(main_window);
49
	}
50
      else if(gui_event == KOLIBRI_EVENT_BUTTON)
51
	{
52
	  unsigned int pressed_button = kolibri_button_get_identifier();
6393 punk_joker 53
	  switch (pressed_button)
54
	  {
55
		  case 0x21:
56
			if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
57
			debug_board_write_str("BOARDMSG: ");
58
			debug_board_write_str(textbox->text);
59
			debug_board_write_str("\n");
60
			break;
61
	      case 0x00000001:
62
			kolibri_exit();
63
	  }
64
	 }
6391 ashmew2 65
      else if(gui_event == KOLIBRI_EVENT_MOUSE)
66
	{
67
	  kolibri_handle_event_mouse(main_window);
68
	}
69
 
70
    } while(gui_event = get_os_event()); /* End of main activity loop */
71
 
72
  /* kolibri_quit(); */
73
 
74
  return 0;
75
}