Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
6457 punk_joker 1
#include 
6391 ashmew2 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
 
6457 punk_joker 15
  kolibri_window *main_window = kolibri_new_window(50, 50, 400, 100, "BoardMsg: OpenDialog 0.12");
6466 siemargl 16
  check_box *checkbox = kolibri_new_check_box(20, 45, 12, 12, "Append BOARDMSG to entered message.");
17
  edit_box *textbox = kolibri_new_edit_box(20, 60, 40);
18
  kolibri_button *button = kolibri_new_button(310, 60, 24, 14, 0x21, kolibri_color_table.color_work_button);
19
  frame *fr = kolibri_new_frame(12, 35, 350, 50, 0x00FCFCFC, 0x00DCDCDC, 1, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
6395 siemargl 20
 
6391 ashmew2 21
  kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox);
22
  kolibri_window_add_element(main_window, KOLIBRI_CHECK_BOX, checkbox);
23
  kolibri_window_add_element(main_window, KOLIBRI_BUTTON, button);
6466 siemargl 24
  kolibri_window_add_element(main_window, KOLIBRI_FRAME, fr);
6395 siemargl 25
 
6397 siemargl 26
  extern volatile unsigned press_key;
6395 siemargl 27
 
6391 ashmew2 28
  do  /* Start of main activity loop */
29
    {
30
      if(gui_event == KOLIBRI_EVENT_REDRAW)
31
	{
32
	  kolibri_handle_event_redraw(main_window);
33
	}
34
      else if(gui_event == KOLIBRI_EVENT_KEY)
6395 siemargl 35
	{
6393 punk_joker 36
	  key = get_key();
37
	  switch (key.code)
38
	  {
39
		  case 13:
6397 siemargl 40
			if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
6393 punk_joker 41
				debug_board_write_str("BOARDMSG: ");
42
 
43
			debug_board_write_str(textbox->text);
44
			debug_board_write_str("\n");
45
			break;
46
	  }
47
	  press_key = key.val;
6397 siemargl 48
 
6391 ashmew2 49
	  kolibri_handle_event_key(main_window);
50
	}
51
      else if(gui_event == KOLIBRI_EVENT_BUTTON)
52
	{
53
	  unsigned int pressed_button = kolibri_button_get_identifier();
6393 punk_joker 54
	  switch (pressed_button)
55
	  {
56
		  case 0x21:
57
			if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
58
			debug_board_write_str("BOARDMSG: ");
59
			debug_board_write_str(textbox->text);
60
			debug_board_write_str("\n");
61
			break;
6457 punk_joker 62
	      case BUTTON_CLOSE:
6393 punk_joker 63
			kolibri_exit();
64
	  }
65
	 }
6391 ashmew2 66
      else if(gui_event == KOLIBRI_EVENT_MOUSE)
67
	{
68
	  kolibri_handle_event_mouse(main_window);
69
	}
70
 
6466 siemargl 71
    } while((gui_event = get_os_event())); /* End of main activity loop */
6391 ashmew2 72
 
73
  /* kolibri_quit(); */
74
 
75
  return 0;
76
}