Rev 6601 | Rev 6615 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6601 | Rev 6612 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | 26 | ||
Line 27... | Line 27... | ||
27 | char* load_file_inmem(char* fname, int32_t* read_sz); // see below |
27 | char* load_file_inmem(char* fname, int32_t* read_sz); // see below |
28 | char* load_image_file(char* fname); // see below |
28 | char* load_image_file(char* fname); // see below |
Line -... | Line 29... | ||
- | 29 | ||
- | 30 | void set_os_keyb_mode(int mode) |
|
- | 31 | // 0 - ASCII, 1 - SCAN |
|
- | 32 | { |
|
- | 33 | __asm__ __volatile__( |
|
- | 34 | "int $0x40" |
|
- | 35 | ::"a"(66), "b"(1), "c"(mode)); |
|
- | 36 | }; |
|
- | 37 | ||
29 | 38 | ||
30 | int main(int argc, char **argv) |
39 | int main(int argc, char **argv) |
31 | { |
40 | { |
32 | /* Load all libraries, initialize global tables like system color table and |
41 | /* Load all libraries, initialize global tables like system color table and |
33 | operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails |
42 | operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails |
34 | to do it's job. This is all you need to call and all libraries and GUI |
43 | to do it's job. This is all you need to call and all libraries and GUI |
35 | elements can be used after a successful call to this function |
44 | elements can be used after a successful call to this function |
36 | */ |
45 | */ |
- | 46 | kolibri_gui_init(); |
|
37 | kolibri_gui_init(); |
47 | set_os_keyb_mode(1); // scan code mode needed for editor |
38 | // kolibri_proclib_init(); // opensave && color dialogs |
48 | // kolibri_proclib_init(); // opensave && color dialogs |
Line 39... | Line 49... | ||
39 | kolibri_libimg_init(); // png handling |
49 | kolibri_libimg_init(); // png handling |
40 | 50 | ||
41 | int gui_event = KOLIBRI_EVENT_REDRAW; |
51 | int gui_event = KOLIBRI_EVENT_REDRAW; |
42 | uint32_t pressed_button = 0; |
52 | uint32_t pressed_button = 0; |
43 | // uint32_t mouse_button; |
53 | // uint32_t mouse_button; |
Line 44... | Line 54... | ||
44 | // pos_t mouse_pos; |
54 | // pos_t mouse_pos; |
45 | oskey_t keypress; |
55 | // oskey_t keypress; |
46 | 56 | ||
47 | // make full path + argv |
57 | // make full path + argv |
Line 53... | Line 63... | ||
53 | // creating GUI using library functions |
63 | // creating GUI using library functions |
54 | kolibri_window *main_window = kolibri_new_window(50, 40, 490, 500, "Editor, TreeView and MsgBox demo"); |
64 | kolibri_window *main_window = kolibri_new_window(50, 40, 490, 500, "Editor, TreeView and MsgBox demo"); |
Line 55... | Line 65... | ||
55 | 65 | ||
56 | editor *ed; |
66 | editor *ed; |
Line 57... | Line 67... | ||
57 | editor *ed_lock; |
67 | void *ed_lock; |
58 | 68 | ||
- | 69 | gui_add_editor(main_window, ed = kolibri_new_editor(X_Y(0, 440), X_Y(20, 150), 0x11, 2048, &ed_lock)); // 0x11 font 8x16 sized x2 |
|
- | 70 | ed_lock = ed; |
|
- | 71 | /* |
|
- | 72 | // load sample file |
|
- | 73 | int res, len; |
|
- | 74 | res = editor_openfile(ed, "/rd/1/boardlog.txt", &len); |
|
- | 75 | debug_board_printf("loaded sample file err=%d, len=%d\n", res, len); |
|
- | 76 | */ |
|
- | 77 | //adding sample text @cursor |
|
Line -... | Line 78... | ||
- | 78 | char *sampletext = "==========ADDED SAMPLE TEXT==========\n"; |
|
59 | gui_add_editor(main_window, ed = kolibri_new_editor(X_Y(0, 440), X_Y(20, 150), 0x1001, 2048, &ed_lock)); |
79 | (*ted_text_add)(ed, sampletext, strlen(sampletext), 0); |
60 | ed_lock = ed; |
80 | |
Line 61... | Line 81... | ||
61 | 81 | // treelist as tree |
|
62 | treelist *tl = kolibri_new_treelist(X_Y(0, 440), X_Y(200, 200), 16, X_Y(16, 16), 100, 50, 0, 0, TL_KEY_NO_EDIT | TL_DRAW_PAR_LINE, &ed_lock, 0x8080ff, 0x0000ff, 0xffffff); |
82 | treelist *tl = kolibri_new_treelist(X_Y(0, 200), X_Y(200, 200), 16, X_Y(16, 16), 100, 50, 0, 0, TL_KEY_NO_EDIT | TL_DRAW_PAR_LINE, &ed_lock, 0x8080ff, 0x0000ff, 0xffffff); |
63 | treelist_data_init(tl); |
83 | treelist_data_init(tl); |
Line 73... | Line 93... | ||
73 | tl->data_img = load_image_file(fname); |
93 | tl->data_img = load_image_file(fname); |
74 | 94 | ||
Line 75... | Line 95... | ||
75 | treelist_node_add(tl, "node1", 1, 0, 0); // ãäå 1 íîìåð èêîíêè ñ êíèãîé |
95 | treelist_node_add(tl, "node1", 1, 0, 0); // ãäå 1 íîìåð èêîíêè ñ êíèãîé |
76 | treelist_cursor_next(tl); |
96 | treelist_cursor_next(tl); |
- | 97 | treelist_node_add(tl, "node1.1", 1, 0, 1); |
|
- | 98 | treelist_cursor_next(tl); |
|
- | 99 | treelist_node_add(tl, "node1.1.1", 0, 0, 2); |
|
- | 100 | treelist_cursor_next(tl); |
|
- | 101 | treelist_node_add(tl, "node1.2", 1, 0, 1); |
|
- | 102 | treelist_cursor_next(tl); |
|
Line -... | Line 103... | ||
- | 103 | ||
- | 104 | treelist_node_add(tl, "node2", 1, 1, 0); // closed node |
|
77 | 105 | treelist_cursor_next(tl); |
|
78 | treelist_node_add(tl, "node2", 1, 0, 0); |
106 | treelist_node_add(tl, "node2.1", 1, 0, 1); |
Line 79... | Line 107... | ||
79 | treelist_cursor_next(tl); |
107 | treelist_cursor_next(tl); |
80 | 108 | ||
Line 81... | Line 109... | ||
81 | treelist_node_add(tl, "node3", 1, 0, 0); |
109 | treelist_node_add(tl, "node3", 1, 0, 0); |
82 | treelist_cursor_next(tl); |
110 | treelist_cursor_next(tl); |
Line -... | Line 111... | ||
- | 111 | ||
- | 112 | treelist_cursor_begin(tl); //;ñòàâèì êóðñîð íà íà÷àëî ñïèñêà |
|
- | 113 | gui_add_treelist(main_window, tl); |
|
- | 114 | ||
- | 115 | // treelist as listbox |
|
- | 116 | treelist *tl2 = kolibri_new_treelist(X_Y(220, 200), X_Y(200, 200), 16, X_Y(16, 16), 100, 50, 0, 0, TL_LISTBOX_MODE, &ed_lock, 0x8080ff, 0x0000ff, 0xffffff); |
|
- | 117 | treelist_data_init(tl2); |
|
- | 118 | ||
- | 119 | tl2->data_img_sys = tl->data_img_sys; |
|
- | 120 | tl2->data_img = tl->data_img; |
|
- | 121 | ||
- | 122 | treelist_node_add(tl2, "list1", 0, 0, 0); // ãäå 1 íîìåð èêîíêè ñ êíèãîé |
|
- | 123 | treelist_cursor_next(tl2); |
|
- | 124 | ||
- | 125 | treelist_node_add(tl2, "list2", 0, 0, 0); |
|
- | 126 | treelist_cursor_next(tl2); |
|
- | 127 | ||
- | 128 | treelist_node_add(tl2, "list3", 0, 0, 0); |
|
- | 129 | treelist_cursor_next(tl2); |
|
83 | 130 | ||
Line -... | Line 131... | ||
- | 131 | treelist_cursor_begin(tl2); //;ñòàâèì êóðñîð íà íà÷àëî ñïèñêà |
|
84 | treelist_cursor_begin(tl); //;ñòàâèì êóðñîð íà íà÷àëî ñïèñêà |
132 | gui_add_treelist(main_window, tl2); |
85 | gui_add_treelist(main_window, tl); |
133 | |
86 | 134 | msgbox* box = kolibri_new_msgbox("Exit", "Are\rYOU\rSure?", 3, "YES", "Absolute", "Not Yet", NULL); // default NOT |
|
87 | msgbox* box = kolibri_new_msgbox("Exit", "Are\rYOU\rSure?", 3, "YES", "Absolute", "Not Yet", NULL); // default NOT |
135 | |
88 | 136 | oskey_t key; |
|
Line 97... | Line 145... | ||
97 | break; |
145 | break; |
98 | case KOLIBRI_EVENT_NONE: |
146 | case KOLIBRI_EVENT_NONE: |
99 | break; |
147 | break; |
100 | case KOLIBRI_EVENT_KEY: |
148 | case KOLIBRI_EVENT_KEY: |
101 | if (ed_lock == ed) |
149 | key = get_key(); |
- | 150 | trap(0x55); // for stop in debug |
|
- | 151 | if (ed_lock == ed) |
|
102 | editor_key(ed); |
152 | editor_key(ed, key); |
103 | else |
153 | else if(ed_lock == tl) |
- | 154 | { |
|
- | 155 | treelist_key(tl, key); |
|
- | 156 | } |
|
- | 157 | else if(ed_lock == tl2) |
|
- | 158 | { |
|
- | 159 | treelist_key(tl2, key); |
|
- | 160 | } |
|
- | 161 | else |
|
104 | kolibri_handle_event_key(main_window); |
162 | kolibri_handle_event_key(main_window, key); |
105 | break; |
163 | break; |
106 | case KOLIBRI_EVENT_BUTTON: |
164 | case KOLIBRI_EVENT_BUTTON: |
107 | pressed_button = get_os_button(); |
165 | pressed_button = get_os_button(); |
108 | switch (pressed_button) |
166 | switch (pressed_button) |
109 | { |
167 | { |
110 | case BTN_QUIT: |
168 | case BTN_QUIT: |