Rev 6524 | Rev 6535 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6524 | Rev 6526 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | #include "kolibri_gui.h" |
20 | #include "kolibri_gui.h" |
21 | #include "kolibri_opendialog.h" |
21 | #include "kolibri_opendialog.h" |
22 | #include "kolibri_libimg.h" |
22 | #include "kolibri_libimg.h" |
Line 23... | Line 23... | ||
23 | 23 | ||
- | 24 | char temp_path[4096]; |
|
Line 24... | Line 25... | ||
24 | char temp_path[4096]; |
25 | char** sys_path = (char**)0x20; // hack - get path from KOS header |
25 | 26 | ||
26 | int main() |
27 | int main(int argc, char **argv) |
27 | { |
28 | { |
28 | /* Load all libraries, initialize global tables like system color table and |
29 | /* Load all libraries, initialize global tables like system color table and |
29 | operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails |
30 | operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails |
Line 42... | Line 43... | ||
42 | oskey_t keypress; |
43 | oskey_t keypress; |
Line 43... | Line 44... | ||
43 | 44 | ||
44 | // load image for buttons |
45 | // load image for buttons |
45 | const int icon_rgb_size = 16*16*3; // every icons 16x16 24bpp |
46 | const int icon_rgb_size = 16*16*3; // every icons 16x16 24bpp |
46 | char *image_data_rgb = malloc(icon_rgb_size * 3), |
47 | char *image_data_rgb = malloc(icon_rgb_size * 3), |
47 | *image_data; |
48 | *image_data, *pc; |
- | 49 | // make full path + argv |
|
- | 50 | strcpy(temp_path, *sys_path); |
|
- | 51 | pc = strrchr(temp_path, '/'); |
|
- | 52 | if (pc) pc[1] = 0; |
|
- | 53 | strcat(temp_path, "reload_16x16_8b.png"); |
|
48 | // make full path + argv |
54 | debug_board_write_str(temp_path); |
49 | FILE *ficon = fopen("reload_16x16_8b.png", "rb"); |
55 | FILE *ficon = fopen(temp_path, "rb"); |
50 | if (!ficon) |
56 | if (!ficon) |
51 | { |
57 | { |
52 | debug_board_write_str("no icons file reload_16x16_8b.png "); |
58 | debug_board_write_str("no icons file reload_16x16_8b.png "); |
53 | return 1; |
59 | return 1; |
Line 70... | Line 76... | ||
70 | // creating GUI using library functions |
76 | // creating GUI using library functions |
71 | kolibri_window *main_window = kolibri_new_window(50, 40, 400, 160, "PictureButton and File dialog demo"); |
77 | kolibri_window *main_window = kolibri_new_window(50, 40, 400, 160, "PictureButton and File dialog demo"); |
Line 72... | Line 78... | ||
72 | 78 | ||
73 | pict_button tbar[3]; |
79 | pict_button tbar[3]; |
74 | gui_add_pict_button(main_window, kolibri_pict_button(&tbar[0], X_Y(10, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); |
80 | gui_add_pict_button(main_window, kolibri_pict_button(&tbar[0], X_Y(10, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); |
75 | gui_add_pict_button(main_window, kolibri_pict_button(&tbar[1], X_Y(20, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); |
81 | gui_add_pict_button(main_window, kolibri_pict_button(&tbar[1], X_Y(35, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); |
Line 76... | Line 82... | ||
76 | gui_add_pict_button(main_window, kolibri_pict_button(&tbar[2], X_Y(30, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); |
82 | gui_add_pict_button(main_window, kolibri_pict_button(&tbar[2], X_Y(60, 16), X_Y(10, 16), image_data_rgb, image_data_rgb + icon_rgb_size, image_data_rgb + icon_rgb_size * 2, 24, NULL, 0)); |
77 | 83 | ||
78 | statictext labels[3]; // tips |
84 | statictext labels[3]; // tips |
79 | gui_add_statictext(main_window, kolibri_statictext_def(&labels[0], X_Y(5, 28), "Open")); |
85 | gui_add_statictext(main_window, kolibri_statictext_def(&labels[0], X_Y(5, 28), "Open")); |
Line 80... | Line 86... | ||
80 | gui_add_statictext(main_window, kolibri_statictext_def(&labels[1], X_Y(20, 28), "Save")); |
86 | gui_add_statictext(main_window, kolibri_statictext_def(&labels[1], X_Y(35, 28), "Save")); |
81 | gui_add_statictext(main_window, kolibri_statictext_def(&labels[2], X_Y(30, 28), "Select Dir")); |
87 | gui_add_statictext(main_window, kolibri_statictext_def(&labels[2], X_Y(65, 28), "Select Dir")); |
Line 82... | Line 88... | ||
82 | 88 | ||
83 | open_dialog *dlg_opensave = kolibri_new_open_dialog(OPEN, 10, 10, 420, 320); |
89 | open_dialog *dlg_opensave = kolibri_new_open_dialog(OPEN, 10, 10, 420, 320); |
Line 84... | Line 90... | ||
84 | (*OpenDialog_init)(dlg_opensave); |
90 | (*OpenDialog_init)(dlg_opensave); |
85 | 91 | ||
86 | pathview pview; |
92 | pathview pview; |
87 | gui_add_pathview(main_window, kolibri_pathview(&pview, X_Y(10, 40), 330, 0, 0, dlg_opensave->openfile_path, temp_path, 0, 0)); // black font, no background |
93 | gui_add_pathview(main_window, kolibri_pathview(&pview, X_Y(10, 50), 330, 1, 0, dlg_opensave->openfile_path, temp_path, 0, 0)); // black font, no background, font 1 |
Line 116... | Line 122... | ||
116 | if(tbar[0].click) // open |
122 | if(tbar[0].click) // open |
117 | { |
123 | { |
118 | tbar[0].click = 0; |
124 | tbar[0].click = 0; |
119 | dlg_opensave->mode = OPEN; |
125 | dlg_opensave->mode = OPEN; |
120 | (*OpenDialog_start)(dlg_opensave); |
126 | (*OpenDialog_start)(dlg_opensave); |
- | 127 | //debug_board_printf("status == %d, buf = %s\n", dlg_opensave->status, dlg_opensave->openfile_path); |
|
121 | if (dlg_opensave->status != 2 && dlg_opensave->status != 1) // fail or cancel |
128 | if (dlg_opensave->status != 2 && dlg_opensave->status != 0) // fail or cancel |
- | 129 | { |
|
122 | (*path_show_prepare)(&pview); |
130 | (*path_show_prepare)(&pview); |
123 | kolibri_handle_event_redraw(main_window); |
131 | (*path_show_draw)(&pview); |
- | 132 | } |
|
124 | } |
133 | } |
125 | if(tbar[1].click) // save |
134 | if(tbar[1].click) // save |
126 | { |
135 | { |
127 | tbar[1].click = 0; |
136 | tbar[1].click = 0; |
128 | dlg_opensave->mode = SAVE; |
137 | dlg_opensave->mode = SAVE; |
129 | (*OpenDialog_start)(dlg_opensave); |
138 | (*OpenDialog_start)(dlg_opensave); |
130 | if (dlg_opensave->status != 2 && dlg_opensave->status != 1) // fail or cancel |
139 | if (dlg_opensave->status != 2 && dlg_opensave->status != 0) // fail or cancel |
131 | (*path_show_prepare)(&pview); |
140 | (*path_show_prepare)(&pview); |
132 | kolibri_handle_event_redraw(main_window); |
141 | kolibri_handle_event_redraw(main_window); |
133 | } |
142 | } |
134 | if(tbar[2].click) // select |
143 | if(tbar[2].click) // select |
135 | { |
144 | { |
136 | tbar[2].click = 0; |
145 | tbar[2].click = 0; |
137 | dlg_opensave->mode = SELECT; |
146 | dlg_opensave->mode = SELECT; |
138 | (*OpenDialog_start)(dlg_opensave); |
147 | (*OpenDialog_start)(dlg_opensave); |
139 | if (dlg_opensave->status != 2 && dlg_opensave->status != 1) // fail or cancel |
148 | if (dlg_opensave->status != 2 && dlg_opensave->status != 0) // fail or cancel |
140 | (*path_show_prepare)(&pview); |
149 | (*path_show_prepare)(&pview); |
141 | kolibri_handle_event_redraw(main_window); |
150 | kolibri_handle_event_redraw(main_window); |
142 | } |
151 | } |
Line 143... | Line 152... | ||
143 | 152 |