Rev 9719 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9719 | Rev 9727 | ||
---|---|---|---|
1 | //BOX_LIB - Asper |
1 | //BOX_LIB - Asper |
2 | #ifndef INCLUDE_BOX_LIB_H |
2 | #ifndef INCLUDE_BOX_LIB_H |
3 | #define INCLUDE_BOX_LIB_H |
3 | #define INCLUDE_BOX_LIB_H |
4 | 4 | ||
5 | #ifndef INCLUDE_KOLIBRI_H |
5 | #ifndef INCLUDE_KOLIBRI_H |
6 | #include "../lib/kolibri.h" |
6 | #include "../lib/kolibri.h" |
7 | #endif |
7 | #endif |
8 | 8 | ||
9 | #ifdef __COFF__ |
9 | #ifdef __COFF__ |
10 | extern dword edit_box_draw; |
10 | extern dword edit_box_draw; |
11 | extern dword edit_box_key_safe; |
11 | extern dword edit_box_key_safe; |
12 | extern dword edit_box_mouse; |
12 | extern dword edit_box_mouse; |
13 | extern dword edit_box_set_text; |
13 | extern dword edit_box_set_text; |
14 | 14 | ||
15 | extern dword scrollbar_v_draw; |
15 | extern dword scrollbar_v_draw; |
16 | extern dword scrollbar_v_mouse; |
16 | extern dword scrollbar_v_mouse; |
17 | extern dword scrollbar_h_draw; |
17 | extern dword scrollbar_h_draw; |
18 | extern dword scrollbar_h_mouse; |
18 | extern dword scrollbar_h_mouse; |
19 | 19 | ||
20 | extern dword PathShow_prepare; |
20 | extern dword PathShow_prepare; |
21 | extern dword PathShow_draw; |
21 | extern dword PathShow_draw; |
22 | 22 | ||
23 | extern dword progressbar_draw; |
23 | extern dword progressbar_draw; |
24 | extern dword progressbar_progress; |
24 | extern dword progressbar_progress; |
25 | 25 | ||
26 | extern dword frame_draw; |
26 | extern dword frame_draw; |
27 | 27 | ||
28 | /* |
28 | /* |
29 | Legacy support |
29 | Legacy support |
30 | For new programs need to use edit_box_key_safe |
30 | For new programs need to use edit_box_key_safe (or edit_box_key_c |
- | 31 | with a define below) |
|
31 | TODO: change in all cmm programs edit_box_key to edit_box_key_safe, |
32 | TODO: change in all cmm programs edit_box_key to edit_box_key_safe (edit_box_key_c) |
32 | after that delete #define below |
33 | See examples in eolite and imgedit |
- | 34 | ||
33 | 35 | This define changed all edit_box_key_c to edit_box_key_safe identifier's |
|
34 | */ |
36 | */ |
35 | #define edit_box_key edit_box_key_safe |
37 | #define edit_box_key_c edit_box_key_safe |
36 | 38 | ||
37 | #else |
39 | #else |
38 | #ifndef INCLUDE_DLL_H |
40 | #ifndef INCLUDE_DLL_H |
39 | #include "../lib/dll.h" |
41 | #include "../lib/dll.h" |
40 | #endif |
42 | #endif |
41 | 43 | ||
42 | dword boxlib = #aEdit_box_lib; |
44 | dword boxlib = #aEdit_box_lib; |
43 | char aEdit_box_lib[]="/sys/lib/box_lib.obj"; |
45 | char aEdit_box_lib[]="/sys/lib/box_lib.obj"; |
44 | 46 | ||
45 | dword box_lib_init = #aboxlib_init; |
47 | dword box_lib_init = #aboxlib_init; |
46 | 48 | ||
47 | dword edit_box_draw = #aEdit_box_draw; |
49 | dword edit_box_draw = #aEdit_box_draw; |
48 | dword edit_box_key = #aEdit_box_key; |
50 | dword edit_box_key = #aEdit_box_key; |
49 | dword edit_box_key_c = #aEdit_box_key_c; |
51 | dword edit_box_key_c = #aEdit_box_key_c; |
50 | dword edit_box_mouse = #aEdit_box_mouse; |
52 | dword edit_box_mouse = #aEdit_box_mouse; |
51 | dword edit_box_set_text = #aEdit_box_set_text; |
53 | dword edit_box_set_text = #aEdit_box_set_text; |
52 | 54 | ||
53 | dword scrollbar_v_draw = #aScrollbar_v_draw; |
55 | dword scrollbar_v_draw = #aScrollbar_v_draw; |
54 | dword scrollbar_v_mouse = #aScrollbar_v_mouse; |
56 | dword scrollbar_v_mouse = #aScrollbar_v_mouse; |
55 | dword scrollbar_h_draw = #aScrollbar_h_draw; |
57 | dword scrollbar_h_draw = #aScrollbar_h_draw; |
56 | dword scrollbar_h_mouse = #aScrollbar_h_mouse; |
58 | dword scrollbar_h_mouse = #aScrollbar_h_mouse; |
57 | 59 | ||
58 | dword PathShow_prepare = #aPathShow_prepare; |
60 | dword PathShow_prepare = #aPathShow_prepare; |
59 | dword PathShow_draw = #aPathShow_draw; |
61 | dword PathShow_draw = #aPathShow_draw; |
60 | 62 | ||
61 | dword progressbar_draw = #aProgressbar_draw; |
63 | dword progressbar_draw = #aProgressbar_draw; |
62 | dword progressbar_progress = #aProgressbar_progress; |
64 | dword progressbar_progress = #aProgressbar_progress; |
63 | 65 | ||
64 | dword frame_draw = #aFrame_draw; |
66 | dword frame_draw = #aFrame_draw; |
65 | 67 | ||
66 | $DD 2 dup 0 |
68 | $DD 2 dup 0 |
67 | 69 | ||
68 | char aEdit_box_draw [] = "edit_box"; |
70 | char aEdit_box_draw [] = "edit_box"; |
69 | char aEdit_box_key [] = "edit_box_key"; |
71 | char aEdit_box_key [] = "edit_box_key"; |
70 | char aEdit_box_key_c[] = "edit_box_key_safe"; |
72 | char aEdit_box_key_c[] = "edit_box_key_safe"; |
71 | char aEdit_box_mouse[] = "edit_box_mouse"; |
73 | char aEdit_box_mouse[] = "edit_box_mouse"; |
72 | char aEdit_box_set_text[] = "edit_box_set_text"; |
74 | char aEdit_box_set_text[] = "edit_box_set_text"; |
73 | 75 | ||
74 | char aboxlib_init[] = "lib_init"; |
76 | char aboxlib_init[] = "lib_init"; |
75 | char aScrollbar_v_draw [] = "scrollbar_v_draw"; |
77 | char aScrollbar_v_draw [] = "scrollbar_v_draw"; |
76 | char aScrollbar_v_mouse[] = "scrollbar_v_mouse"; |
78 | char aScrollbar_v_mouse[] = "scrollbar_v_mouse"; |
77 | char aScrollbar_h_draw [] = "scrollbar_h_draw"; |
79 | char aScrollbar_h_draw [] = "scrollbar_h_draw"; |
78 | char aScrollbar_h_mouse[] = "scrollbar_h_mouse"; |
80 | char aScrollbar_h_mouse[] = "scrollbar_h_mouse"; |
79 | 81 | ||
80 | char aPathShow_prepare [] = "PathShow_prepare"; |
82 | char aPathShow_prepare [] = "PathShow_prepare"; |
81 | char aPathShow_draw [] = "PathShow_draw"; |
83 | char aPathShow_draw [] = "PathShow_draw"; |
82 | 84 | ||
83 | char aProgressbar_draw [] = "progressbar_draw"; |
85 | char aProgressbar_draw [] = "progressbar_draw"; |
84 | char aProgressbar_progress[] = "progressbar_progress"; |
86 | char aProgressbar_progress[] = "progressbar_progress"; |
85 | 87 | ||
86 | char aFrame_draw[] = "frame_draw"; |
88 | char aFrame_draw[] = "frame_draw"; |
87 | #endif |
89 | #endif |
88 | 90 | ||
89 | struct PathShow_data |
91 | struct PathShow_data |
90 | { |
92 | { |
91 | dword type; |
93 | dword type; |
92 | word start_y; |
94 | word start_y; |
93 | word start_x; |
95 | word start_x; |
94 | word font_w; // 6 - for font 0, 8 - for font 1 |
96 | word font_w; // 6 - for font 0, 8 - for font 1 |
95 | word area_size_x; |
97 | word area_size_x; |
96 | dword font_number; // 0 - monospace, 1 - variable |
98 | dword font_number; // 0 - monospace, 1 - variable |
97 | dword background_flag; |
99 | dword background_flag; |
98 | dword font_color; |
100 | dword font_color; |
99 | dword background_color; |
101 | dword background_color; |
100 | dword text_pointer; |
102 | dword text_pointer; |
101 | dword work_area_pointer; |
103 | dword work_area_pointer; |
102 | dword temp_text_length; |
104 | dword temp_text_length; |
103 | }; |
105 | }; |
104 | /* |
106 | /* |
105 | char temp[128]; |
107 | char temp[128]; |
106 | PathShow_data PathShow = {0, 100,20, 6, 200, 0, 1, 0x0, 0xFFFfff, #email_text, #temp, 0}; |
108 | PathShow_data PathShow = {0, 100,20, 6, 200, 0, 1, 0x0, 0xFFFfff, #email_text, #temp, 0}; |
107 | PathShow_prepare stdcall(#PathShow); |
109 | PathShow_prepare stdcall(#PathShow); |
108 | PathShow_draw stdcall(#PathShow); |
110 | PathShow_draw stdcall(#PathShow); |
109 | */ |
111 | */ |
110 | 112 | ||
111 | //editbox flags |
113 | //editbox flags |
112 | #define ed_pass 1b |
114 | #define ed_pass 1b |
113 | #define ed_focus 10b //focused |
115 | #define ed_focus 10b //focused |
114 | #define ed_shift 100b //flag is set when Shift is pressed |
116 | #define ed_shift 100b //flag is set when Shift is pressed |
115 | #define ed_shift_on 1000b |
117 | #define ed_shift_on 1000b |
116 | #define ed_shift_bac 10000b //bit for Shift reset, if set the smth is selected |
118 | #define ed_shift_bac 10000b //bit for Shift reset, if set the smth is selected |
117 | #define ed_left_fl 100000b |
119 | #define ed_left_fl 100000b |
118 | #define ed_offset_fl 1000000b |
120 | #define ed_offset_fl 1000000b |
119 | #define ed_insert 10000000b |
121 | #define ed_insert 10000000b |
120 | #define ed_mouse_on 100000000b |
122 | #define ed_mouse_on 100000000b |
121 | #define ed_mouse_adn_b 100011000b |
123 | #define ed_mouse_adn_b 100011000b |
122 | #define ed_disabled 100000000000b |
124 | #define ed_disabled 100000000000b |
123 | #define ed_always_focus 100000000000000b |
125 | #define ed_always_focus 100000000000000b |
124 | #define ed_figure_only 1000000000000000b //numbers only |
126 | #define ed_figure_only 1000000000000000b //numbers only |
125 | #define ed_shift_cl 1111111111100011b |
127 | #define ed_shift_cl 1111111111100011b |
126 | #define ed_shift_mcl 1111111111111011b |
128 | #define ed_shift_mcl 1111111111111011b |
127 | #define ed_shift_off 1111111111111011b |
129 | #define ed_shift_off 1111111111111011b |
128 | #define ed_shift_on_off 1111111111110111b |
130 | #define ed_shift_on_off 1111111111110111b |
129 | #define ed_shift_bac_cl 1111111111101111b |
131 | #define ed_shift_bac_cl 1111111111101111b |
130 | #define ed_right_fl 1111111111011111b |
132 | #define ed_right_fl 1111111111011111b |
131 | #define ed_offset_cl 1111111110111111b |
133 | #define ed_offset_cl 1111111110111111b |
132 | #define ed_insert_cl 1111111101111111b |
134 | #define ed_insert_cl 1111111101111111b |
133 | #define ed_mouse_on_off 1111111011111111b |
135 | #define ed_mouse_on_off 1111111011111111b |
134 | 136 | ||
135 | struct edit_box{ |
137 | struct edit_box{ |
136 | dword width, left, top, |
138 | dword width, left, top, |
137 | bg_color, selec_color, focus_border_color, border_color, text_color, |
139 | bg_color, selec_color, focus_border_color, border_color, text_color, |
138 | max, |
140 | max, |
139 | text, |
141 | text, |
140 | mouse_variable, |
142 | mouse_variable, |
141 | flags, |
143 | flags, |
142 | size, pos, offset, |
144 | size, pos, offset, |
143 | cl_curs_x, cl_curs_y, |
145 | cl_curs_x, cl_curs_y, |
144 | shift, shift_old, |
146 | shift, shift_old, |
145 | height, char_width; |
147 | height, char_width; |
146 | }; |
148 | }; |
147 | 149 | ||
148 | :void EditBox_UpdateText(dword ed, _flags) |
150 | :void EditBox_UpdateText(dword ed, _flags) |
149 | { |
151 | { |
150 | dword ed_text; |
152 | dword ed_text; |
151 | ESI = ed; |
153 | ESI = ed; |
152 | //ESI.edit_box.offset = ESI.edit_box.shift = ESI.edit_box.shift_old = 0; //no need because of 7904 |
154 | //ESI.edit_box.offset = ESI.edit_box.shift = ESI.edit_box.shift_old = 0; //no need because of 7904 |
153 | ESI.edit_box.flags = _flags; |
155 | ESI.edit_box.flags = _flags; |
154 | ed_text = ESI.edit_box.text; |
156 | ed_text = ESI.edit_box.text; |
155 | //ESI.edit_box.pos = //no need because of 7904 |
157 | //ESI.edit_box.pos = //no need because of 7904 |
156 | ESI.edit_box.size = strlen(ed_text); |
158 | ESI.edit_box.size = strlen(ed_text); |
157 | } |
159 | } |
158 | 160 | ||
159 | :dword EditBox_Create(dword eb, left, top, width, maxlen, text, flags) |
161 | :dword EditBox_Create(dword eb, left, top, width, maxlen, text, flags) |
160 | { |
162 | { |
161 | ESDWORD[eb] = width; |
163 | ESDWORD[eb] = width; |
162 | ESDWORD[eb + 4] = left; |
164 | ESDWORD[eb + 4] = left; |
163 | ESDWORD[eb + 8] = top; |
165 | ESDWORD[eb + 8] = top; |
164 | ESDWORD[eb + 12] = 0xffffff; |
166 | ESDWORD[eb + 12] = 0xffffff; |
165 | ESDWORD[eb + 16] = 0x94AECE; |
167 | ESDWORD[eb + 16] = 0x94AECE; |
166 | ESDWORD[eb + 20] = 0xffffff; |
168 | ESDWORD[eb + 20] = 0xffffff; |
167 | ESDWORD[eb + 24] = 0xffffff; |
169 | ESDWORD[eb + 24] = 0xffffff; |
168 | ESDWORD[eb + 28] = 0x10000000; |
170 | ESDWORD[eb + 28] = 0x10000000; |
169 | ESDWORD[eb + 32] = maxlen; |
171 | ESDWORD[eb + 32] = maxlen; |
170 | ESDWORD[eb + 36] = text; |
172 | ESDWORD[eb + 36] = text; |
171 | ESDWORD[eb + 40] = 0; |
173 | ESDWORD[eb + 40] = 0; |
172 | ESDWORD[eb + 44] = flags; |
174 | ESDWORD[eb + 44] = flags; |
173 | ESDWORD[eb + 48] = 0; |
175 | ESDWORD[eb + 48] = 0; |
174 | ESDWORD[eb + 52] = 0; |
176 | ESDWORD[eb + 52] = 0; |
175 | } |
177 | } |
176 | 178 | ||
177 | struct scroll_bar |
179 | struct scroll_bar |
178 | { |
180 | { |
179 | word size_x, start_x, size_y, start_y; |
181 | word size_x, start_x, size_y, start_y; |
180 | dword btn_height, type, max_area, cur_area, position, |
182 | dword btn_height, type, max_area, cur_area, position, |
181 | bckg_col, frnt_col, line_col, redraw; |
183 | bckg_col, frnt_col, line_col, redraw; |
182 | word delta, delta2, r_size_x, r_start_x, r_size_y, r_start_y; |
184 | word delta, delta2, r_size_x, r_start_x, r_size_y, r_start_y; |
183 | dword m_pos, m_pos_2, m_keys, run_size, position2, work_size, all_redraw, ar_offset; |
185 | dword m_pos, m_pos_2, m_keys, run_size, position2, work_size, all_redraw, ar_offset; |
184 | }; |
186 | }; |
185 | 187 | ||
186 | struct progress_bar |
188 | struct progress_bar |
187 | { |
189 | { |
188 | dword value, |
190 | dword value, |
189 | left, top, |
191 | left, top, |
190 | width, height, |
192 | width, height, |
191 | style, |
193 | style, |
192 | min, max, |
194 | min, max, |
193 | back_color, progress_color, frame_color; |
195 | back_color, progress_color, frame_color; |
194 | }; |
196 | }; |
195 | 197 | ||
196 | struct frame |
198 | struct frame |
197 | { |
199 | { |
198 | dword type; |
200 | dword type; |
199 | word size_x; //start_x, size_x => Mario, WTF? Is this so complex to use x/y/w/h ? |
201 | word size_x; //start_x, size_x => Mario, WTF? Is this so complex to use x/y/w/h ? |
200 | word start_x; |
202 | word start_x; |
201 | word size_y; |
203 | word size_y; |
202 | word start_y; |
204 | word start_y; |
203 | dword ext_col; |
205 | dword ext_col; |
204 | dword int_col; |
206 | dword int_col; |
205 | dword flags; // see FR_FLAGS |
207 | dword flags; // see FR_FLAGS |
206 | dword text_pointer; |
208 | dword text_pointer; |
207 | dword text_position; // 0-up,1-bottom |
209 | dword text_position; // 0-up,1-bottom |
208 | dword font_number; // 0-monospace,1-variable |
210 | dword font_number; // 0-monospace,1-variable |
209 | dword font_size_y; |
211 | dword font_size_y; |
210 | dword font_color; |
212 | dword font_color; |
211 | dword font_backgr_color; |
213 | dword font_backgr_color; |
212 | }; |
214 | }; |
213 | 215 | ||
214 | // FR_FLAGS = [x][yyy][z] |
216 | // FR_FLAGS = [x][yyy][z] |
215 | // z - Caption |
217 | // z - Caption |
216 | // yyy - BorderStyle |
218 | // yyy - BorderStyle |
217 | // x - BackStyle |
219 | // x - BackStyle |
218 | #define FR_CAPTION 00001b // [z] |
220 | #define FR_CAPTION 00001b // [z] |
219 | #define FR_DOUBLE 00000b // [yyy] |
221 | #define FR_DOUBLE 00000b // [yyy] |
220 | #define FR_RAISED 00010b // [yyy] |
222 | #define FR_RAISED 00010b // [yyy] |
221 | #define FR_SUNKEN 00100b // [yyy] |
223 | #define FR_SUNKEN 00100b // [yyy] |
222 | #define FR_ETCHED 00110b // [yyy] |
224 | #define FR_ETCHED 00110b // [yyy] |
223 | #define FR_RIDGED 01000b // [yyy] |
225 | #define FR_RIDGED 01000b // [yyy] |
224 | #define FR_FILLED 10000b // [x] |
226 | #define FR_FILLED 10000b // [x] |
225 | 227 | ||
226 | :frame frame123 = { 0, 260, 10, 60, 16, NULL, 0xFFFfff, 1, NULL, 0, 1, 12, 0x000111, 0xCCCccc }; |
228 | :frame frame123 = { 0, 260, 10, 60, 16, NULL, 0xFFFfff, 1, NULL, 0, 1, 12, 0x000111, 0xCCCccc }; |
227 | :void DrawFrame(dword x,y,w,h,text) |
229 | :void DrawFrame(dword x,y,w,h,text) |
228 | { |
230 | { |
229 | frame123.font_color = sc.work_text; |
231 | frame123.font_color = sc.work_text; |
230 | frame123.ext_col = sc.line; |
232 | frame123.ext_col = sc.line; |
231 | frame123.int_col = sc.light; |
233 | frame123.int_col = sc.light; |
232 | frame123.font_backgr_color = sc.work; |
234 | frame123.font_backgr_color = sc.work; |
233 | 235 | ||
234 | frame123.start_x = x; |
236 | frame123.start_x = x; |
235 | frame123.start_y = y; |
237 | frame123.start_y = y; |
236 | frame123.size_x = w; |
238 | frame123.size_x = w; |
237 | frame123.size_y = h; |
239 | frame123.size_y = h; |
238 | frame123.text_pointer = text; |
240 | frame123.text_pointer = text; |
239 | if (!text) frame123.flags=0; else frame123.flags=FR_CAPTION; |
241 | if (!text) frame123.flags=0; else frame123.flags=FR_CAPTION; |
240 | frame_draw stdcall (#frame123); |
242 | frame_draw stdcall (#frame123); |
241 | } |
243 | } |
242 | 244 | ||
243 | 245 | ||
244 | #endif |
246 | #endif |