Rev 6470 | Rev 6612 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6470 | Rev 6479 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | #include "kolibri_colors.h" |
4 | #include "kolibri_colors.h" |
Line 5... | Line 5... | ||
5 | 5 | ||
6 | /* flags meaning |
6 | /* flags meaning |
7 | ed_figure_only= 1000000000000000b ;îäíè ñèìâîëû |
7 | ed_figure_only= 1000000000000000b ;îäíè ñèìâîëû |
8 | ed_always_focus= 100000000000000b |
8 | ed_always_focus= 100000000000000b |
9 | ed_focus= 10b ;ôîêóñ ïðèëîæåíèÿ |
9 | ed_focus= 10b ;ôîêóñ ââîäà ïðèëîæåíèÿ |
10 | ed_pass= 1b ;ïîëå ñ ïàðîëåì |
10 | ed_pass= 1b ;ïîëå ñ ïàðîëåì |
11 | ed_shift_on= 1000b ;åñëè íå óñòàíîâëåí -çíà÷èò âïåðâûå íàæàò shift,åñëè áûë óñòàíîâëåí, çíà÷èò ìû óæå ÷òî - òî äåëàëè óäåðæèâàÿ shift |
11 | ed_shift_on= 1000b ;åñëè íå óñòàíîâëåí -çíà÷èò âïåðâûå íàæàò shift,åñëè áûë óñòàíîâëåí, çíà÷èò ìû óæå ÷òî - òî äåëàëè óäåðæèâàÿ shift |
12 | ed_shift_on_off=1111111111110111b |
12 | ed_shift_on_off=1111111111110111b |
13 | ed_shift= 100b ;âêëþ÷àåòñÿ ïðè íàæàòèè íà shift ò.å. åñëè íàæèìàþ |
13 | ed_shift= 100b ;âêëþ÷àåòñÿ ïðè íàæàòèè íà shift ò.å. åñëè íàæèìàþ |
Line 23... | Line 23... | ||
23 | ed_insert= 10000000b |
23 | ed_insert= 10000000b |
24 | ed_insert_cl= 1111111101111111b |
24 | ed_insert_cl= 1111111101111111b |
25 | ed_mouse_on = 100000000b |
25 | ed_mouse_on = 100000000b |
26 | ed_mous_adn_b= 100011000b |
26 | ed_mous_adn_b= 100011000b |
27 | ed_mouse_on_off=1111111011111111b |
27 | ed_mouse_on_off=1111111011111111b |
- | 28 | ed_mouse_on_off= not (ed_mouse_on) |
|
- | 29 | ed_ctrl_on = 1000000000b |
|
- | 30 | ed_ctrl_off = not (ed_ctrl_on) |
|
- | 31 | ed_alt_on = 10000000000b |
|
- | 32 | ed_alt_off = not (ed_alt_on) |
|
- | 33 | ed_disabled= 100000000000b |
|
28 | */ |
34 | */ |
Line 29... | Line 35... | ||
29 | 35 | ||
30 | typedef struct { |
36 | typedef struct edit_box_t { |
31 | unsigned int width; |
37 | unsigned int width; |
32 | unsigned int left; |
38 | unsigned int left; |
33 | unsigned int top; |
39 | unsigned int top; |
34 | unsigned int color; |
40 | unsigned int color; |
35 | unsigned int shift_color; // selected text color |
41 | unsigned int shift_color; // selected text color |
36 | unsigned int focus_border_color; |
42 | unsigned int focus_border_color; |
37 | unsigned int blur_border_color; |
43 | unsigned int blur_border_color; |
38 | unsigned int text_color; |
44 | unsigned int text_color; |
39 | unsigned int max; |
45 | unsigned int max; |
40 | char *text; |
46 | char *text; |
41 | unsigned int mouse_variable; // mus be int* pointer to saved mouse pos ?? |
47 | struct edit_box_t** mouse_variable; // must be pointer edit_box** to save focused editbox |
Line 42... | Line 48... | ||
42 | unsigned int flags; |
48 | unsigned int flags; |
43 | 49 | ||
44 | unsigned int size; // used symbols in buffer without trailing zero |
50 | unsigned int size; // used symbols in buffer without trailing zero |
Line 64... | Line 70... | ||
64 | 70 | ||
65 | tlx,tly = Coordinates of the beginning of the edit box. |
71 | tlx,tly = Coordinates of the beginning of the edit box. |
66 | max_chars = Limit of number of characters user can enter into edit box. |
72 | max_chars = Limit of number of characters user can enter into edit box. |
Line 67... | Line 73... | ||
67 | */ |
73 | */ |
68 | 74 | ||
69 | edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsigned int max_chars) |
75 | edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsigned int max_chars, edit_box **editbox_interlock) |
70 | { |
76 | { |
71 | unsigned int PIXELS_PER_CHAR = 7; |
77 | unsigned int PIXELS_PER_CHAR = 7; |
Line 72... | Line 78... | ||
72 | edit_box *new_textbox = (edit_box *)malloc(sizeof(edit_box)); |
78 | edit_box *new_textbox = (edit_box *)calloc(1, sizeof(edit_box)); |
73 | char *text_buffer = (char *)calloc(max_chars + 1, sizeof(char)); |
79 | char *text_buffer = (char *)calloc(max_chars + 2, sizeof(char)); // +2 as asked in box_lib src |
Line 74... | Line 80... | ||
74 | 80 | ||
Line 83... | Line 89... | ||
83 | new_textbox -> focus_border_color = kolibri_color_table.color_work_graph; |
89 | new_textbox -> focus_border_color = kolibri_color_table.color_work_graph; |
84 | new_textbox -> blur_border_color = 0x6a9480; |
90 | new_textbox -> blur_border_color = 0x6a9480; |
85 | new_textbox -> text_color = kolibri_color_table.color_work_text; /* Always black text when typing */ |
91 | new_textbox -> text_color = kolibri_color_table.color_work_text; /* Always black text when typing */ |
86 | new_textbox -> max = max_chars; |
92 | new_textbox -> max = max_chars; |
87 | new_textbox -> text = text_buffer; |
93 | new_textbox -> text = text_buffer; |
88 | new_textbox -> mouse_variable = 1; /* let the mouse take control? */ |
94 | new_textbox -> mouse_variable = editbox_interlock; |
89 | new_textbox -> flags = 0x00000000; |
95 | new_textbox -> flags = 0x00000000; |
90 | /* If these lines are uncommented, the executable will crash for no reason at start */ |
- | |
91 | /* Even though these lines are not ever read it ALWAYS causes a crash, even crashes MTDBG. What gives? */ |
- | |
92 | - | ||
93 | new_textbox -> size = 0; |
- | |
94 | new_textbox -> pos = 0; |
- | |
95 | new_textbox -> offset = 0; |
- | |
96 | new_textbox -> cl_curs_x = 0; |
- | |
97 | new_textbox -> cl_curs_y = 0; |
- | |
98 | new_textbox -> shift = 0; |
- | |
99 | new_textbox -> shift_old = 0; |
- | |
Line 100... | Line 96... | ||
100 | 96 | ||
101 | return new_textbox; |
97 | return new_textbox; |
Line 102... | Line 98... | ||
102 | } |
98 | } |