Rev 6152 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6152 | Rev 6216 | ||
---|---|---|---|
1 | #define MEMSIZE 4096*60 |
1 | #define MEMSIZE 4096*60 |
2 | 2 | ||
3 | #include "../lib/font.h" |
3 | #include "../lib/font.h" |
4 | #include "../lib/io.h" |
4 | #include "../lib/io.h" |
5 | #include "../lib/gui.h" |
5 | #include "../lib/gui.h" |
6 | #include "../lib/list_box.h" |
6 | #include "../lib/list_box.h" |
7 | #include "../lib/menu.h" |
7 | #include "../lib/menu.h" |
8 | #include "../lib/obj/box_lib.h" |
8 | #include "../lib/obj/box_lib.h" |
9 | #include "../lib/obj/libini.h" |
9 | #include "../lib/obj/libini.h" |
10 | #include "../lib/obj/iconv.h" |
10 | #include "../lib/obj/iconv.h" |
11 | #include "../lib/obj/proc_lib.h" |
11 | #include "../lib/obj/proc_lib.h" |
12 | #include "../lib/obj/http.h" |
12 | #include "../lib/obj/http.h" |
13 | #include "../lib/cursor.h" |
13 | #include "../lib/cursor.h" |
14 | #include "../lib/patterns/libimg_load_skin.h" |
14 | #include "../lib/patterns/libimg_load_skin.h" |
15 | #include "../lib/patterns/simple_open_dialog.h" |
15 | #include "../lib/patterns/simple_open_dialog.h" |
16 | #include "../lib/patterns/history.h" |
16 | #include "../lib/patterns/history.h" |
17 | #include "../lib/patterns/http_downloader.h" |
17 | #include "../lib/patterns/http_downloader.h" |
18 | 18 | ||
19 | char default_dir[] = "/rd/1"; |
19 | char default_dir[] = "/rd/1"; |
20 | od_filter filter2 = {0,0}; |
20 | od_filter filter2 = {0,0}; |
21 | 21 | ||
22 | char accept_language[]= "Accept-Language: ru\n"; |
22 | char accept_language[]= "Accept-Language: ru\n"; |
23 | 23 | ||
24 | #define TOOLBAR_H 36 |
24 | #define TOOLBAR_H 36 |
25 | #define TOOLBAR_ICON_WIDTH 26 |
25 | #define TOOLBAR_ICON_WIDTH 26 |
26 | #define TOOLBAR_ICON_HEIGHT 24 |
26 | #define TOOLBAR_ICON_HEIGHT 24 |
27 | 27 | ||
28 | #define DEFAULT_EDITOR "/sys/tinypad" |
28 | #define DEFAULT_EDITOR "/sys/tinypad" |
29 | #define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt" |
29 | #define DEFAULT_PREVIEW_PATH "/tmp0/1/aelia_preview.txt" |
30 | 30 | ||
31 | //ATTENTION: each page must have '\0' character at the end of the file |
31 | //ATTENTION: each page must have '\0' character at the end of the file |
32 | char buidin_page_home[] = FROM "buidin_pages\\home.htm"; |
32 | char buidin_page_home[] = FROM "buidin_pages\\home.htm"; |
33 | char buidin_page_about[] = FROM "buidin_pages\\about.htm"; |
33 | char buidin_page_about[] = FROM "buidin_pages\\about.htm"; |
34 | char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm"; |
34 | char buidin_page_not_found[] = FROM "buidin_pages\\not_found.htm"; |
35 | 35 | ||
36 | #define UML 4096*2 |
36 | #define UML 4096*2 |
37 | 37 | ||
38 | scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
38 | scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
39 | llist list; |
39 | llist list; |
40 | 40 | ||
41 | proc_info Form; |
41 | proc_info Form; |
42 | char title[4196]; |
42 | char title[4196]; |
43 | 43 | ||
44 | enum { |
44 | enum { |
45 | OPEN_FILE, |
45 | OPEN_FILE, |
46 | MAGNIFY_MINUS, |
46 | MAGNIFY_MINUS, |
47 | MAGNIFY_PLUS, |
47 | MAGNIFY_PLUS, |
48 | CHANGE_ENCODING, |
48 | CHANGE_ENCODING, |
49 | RUN_EDIT, |
49 | RUN_EDIT, |
50 | GO_BACK, |
50 | GO_BACK, |
51 | GO_FORWARD, |
51 | GO_FORWARD, |
52 | SANDWICH |
52 | SANDWICH |
53 | }; |
53 | }; |
54 | 54 | ||
55 | char address[UML]="http://"; |
55 | char address[UML]="http://"; |
56 | int mouse_address_box; |
56 | int mouse_address_box; |
57 | edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,#mouse_address_box,2,19,19}; |
57 | edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,#mouse_address_box,2,19,19}; |
58 | 58 | ||
59 | CustomCursor CursorPointer; |
59 | CustomCursor CursorPointer; |
60 | dword CursorFile = FROM "pointer.cur"; |
60 | dword CursorFile = FROM "pointer.cur"; |
61 | 61 | ||
62 | #include "favicon.h" |
62 | #include "favicon.h" |
63 | #include "ini.h" |
63 | #include "ini.h" |
- | 64 | #include "tag.h" |
|
64 | #include "gui.h" |
65 | #include "gui.h" |
65 | #include "label.h" |
66 | #include "label.h" |
66 | #include "link.h" |
67 | #include "link.h" |
67 | #include "prepare_page.h" |
68 | #include "prepare_page.h" |
68 | //#include "special_symbols.h" |
69 | //#include "special_symbols.h" |
69 | 70 | ||
70 | #define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nAbout" |
71 | #define SANDWICH_MENU "Refresh page\nEdit page\nHistory\nAbout" |
71 | 72 | ||
72 | void InitDlls() |
73 | void InitDlls() |
73 | { |
74 | { |
74 | load_dll(boxlib, #box_lib_init, 0); |
75 | load_dll(boxlib, #box_lib_init, 0); |
75 | load_dll(libHTTP, #http_lib_init, 1); |
76 | load_dll(libHTTP, #http_lib_init, 1); |
76 | load_dll(libio, #libio_init, 1); |
77 | load_dll(libio, #libio_init, 1); |
77 | load_dll(libimg, #libimg_init, 1); |
78 | load_dll(libimg, #libimg_init, 1); |
78 | //load_dll(libini, #lib_init, 1); |
79 | //load_dll(libini, #lib_init, 1); |
79 | load_dll(iconv_lib, #iconv_open, 0); |
80 | load_dll(iconv_lib, #iconv_open, 0); |
80 | load_dll(Proc_lib, #OpenDialog_init,0); |
81 | load_dll(Proc_lib, #OpenDialog_init,0); |
81 | } |
82 | } |
82 | 83 | ||
83 | 84 | ||
84 | void main() |
85 | void main() |
85 | { |
86 | { |
86 | InitDlls(); |
87 | InitDlls(); |
87 | OpenDialog_init stdcall (#o_dialog); |
88 | OpenDialog_init stdcall (#o_dialog); |
88 | CursorPointer.Load(#CursorFile); |
89 | CursorPointer.Load(#CursorFile); |
89 | label.init(DEFAULT_FONT); |
90 | label.init(DEFAULT_FONT); |
90 | Libimg_LoadImage(#skin, abspath("toolbar.png")); |
91 | Libimg_LoadImage(#skin, abspath("toolbar.png")); |
91 | LoadIniSettings(); |
92 | LoadIniSettings(); |
92 | list.no_selection = true; |
93 | list.no_selection = true; |
93 | SetEventMask(10000000000000000000000001100111b); |
94 | SetEventMask(10000000000000000000000001100111b); |
94 | loop() |
95 | loop() |
95 | { |
96 | { |
96 | switch(WaitEvent()) |
97 | switch(WaitEvent()) |
97 | { |
98 | { |
98 | case evMouse: |
99 | case evMouse: |
99 | HandleMouseEvent(); |
100 | HandleMouseEvent(); |
100 | break; |
101 | break; |
101 | case evKey: |
102 | case evKey: |
102 | HandleKeyEvent(); |
103 | HandleKeyEvent(); |
103 | break; |
104 | break; |
104 | case evButton: |
105 | case evButton: |
105 | HandleButtonEvent(); |
106 | HandleButtonEvent(); |
106 | break; |
107 | break; |
107 | case evReDraw: |
108 | case evReDraw: |
108 | draw_window(); |
109 | draw_window(); |
109 | if (menu.list.cur_y>=10) && (menu.list.cur_y<20) { |
110 | if (menu.list.cur_y>=10) && (menu.list.cur_y<20) { |
110 | encoding = menu.list.cur_y - 10; |
111 | encoding = menu.list.cur_y - 10; |
111 | EventPageRefresh(); |
112 | EventPageRefresh(); |
112 | menu.list.cur_y = 0; |
113 | menu.list.cur_y = 0; |
113 | } |
114 | } |
114 | if (menu.list.cur_y>=20) { |
115 | if (menu.list.cur_y>=20) { |
115 | menu.list.cur_y-=20; |
116 | menu.list.cur_y-=20; |
116 | if (menu.list.cur_y==0) EventPageRefresh(); |
117 | if (menu.list.cur_y==0) EventPageRefresh(); |
117 | if (menu.list.cur_y==1) EventRunEdit(); |
118 | if (menu.list.cur_y==1) EventRunEdit(); |
118 | if (menu.list.cur_y==2) EventShowHistory(); |
119 | if (menu.list.cur_y==2) EventShowHistory(); |
119 | if (menu.list.cur_y==3) EventShowInfo(); |
120 | if (menu.list.cur_y==3) EventShowInfo(); |
120 | menu.list.cur_y = 0; |
121 | menu.list.cur_y = 0; |
121 | } |
122 | } |
122 | } |
123 | } |
123 | } |
124 | } |
124 | } |
125 | } |
125 | 126 | ||
126 | 127 | ||
127 | void HandleButtonEvent() |
128 | void HandleButtonEvent() |
128 | { |
129 | { |
129 | byte btn = GetButtonID(); |
130 | byte btn = GetButtonID(); |
130 | if (btn==1) { |
131 | if (btn==1) { |
131 | SaveIniSettings(); |
132 | SaveIniSettings(); |
132 | ExitProcess(); |
133 | ExitProcess(); |
133 | } |
134 | } |
134 | switch(btn-10) |
135 | switch(btn-10) |
135 | { |
136 | { |
136 | case GO_BACK: |
137 | case GO_BACK: |
137 | EventGoBack(); |
138 | EventGoBack(); |
138 | break; |
139 | break; |
139 | case GO_FORWARD: |
140 | case GO_FORWARD: |
140 | EventGoForward(); |
141 | EventGoForward(); |
141 | break; |
142 | break; |
142 | case OPEN_FILE: |
143 | case OPEN_FILE: |
143 | EventOpenDialog(); |
144 | EventOpenDialog(); |
144 | break; |
145 | break; |
145 | case MAGNIFY_PLUS: |
146 | case MAGNIFY_PLUS: |
146 | EventMagnifyPlus(); |
147 | EventMagnifyPlus(); |
147 | break; |
148 | break; |
148 | case MAGNIFY_MINUS: |
149 | case MAGNIFY_MINUS: |
149 | EventMagnifyMinus(); |
150 | EventMagnifyMinus(); |
150 | break; |
151 | break; |
151 | case CHANGE_ENCODING: |
152 | case CHANGE_ENCODING: |
152 | EventChangeEncoding(); |
153 | EventChangeEncoding(); |
153 | break; |
154 | break; |
154 | case RUN_EDIT: |
155 | case RUN_EDIT: |
155 | EventRunEdit(); |
156 | EventRunEdit(); |
156 | break; |
157 | break; |
157 | case SANDWICH: |
158 | case SANDWICH: |
158 | EventShowSandwichMenu(); |
159 | EventShowSandwichMenu(); |
159 | break; |
160 | break; |
160 | } |
161 | } |
161 | } |
162 | } |
162 | 163 | ||
163 | 164 | ||
164 | void HandleKeyEvent() |
165 | void HandleKeyEvent() |
165 | { |
166 | { |
166 | GetKeys(); |
167 | GetKeys(); |
167 | switch (key_scancode) |
168 | switch (key_scancode) |
168 | { |
169 | { |
169 | case 059: |
170 | case 059: |
170 | EventShowInfo(); |
171 | EventShowInfo(); |
171 | return; |
172 | return; |
172 | case SCAN_CODE_ENTER: |
173 | case SCAN_CODE_ENTER: |
173 | EventOpenAddress(#address); |
174 | EventOpenAddress(#address); |
174 | return; |
175 | return; |
175 | case SCAN_CODE_BS: |
176 | case SCAN_CODE_BS: |
176 | if (! address_box.flags & 0b10) { |
177 | if (! address_box.flags & 0b10) { |
177 | EventGoBack(); |
178 | EventGoBack(); |
178 | return; |
179 | return; |
179 | } |
180 | } |
180 | } |
181 | } |
181 | if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) { |
182 | if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) { |
182 | switch (key_scancode) |
183 | switch (key_scancode) |
183 | { |
184 | { |
184 | case 024: //O |
185 | case 024: //O |
185 | EventOpenDialog(); |
186 | EventOpenDialog(); |
186 | break; |
187 | break; |
187 | case SCAN_CODE_UP: |
188 | case SCAN_CODE_UP: |
188 | EventMagnifyPlus(); |
189 | EventMagnifyPlus(); |
189 | break; |
190 | break; |
190 | case SCAN_CODE_DOWN: |
191 | case SCAN_CODE_DOWN: |
191 | EventMagnifyMinus(); |
192 | EventMagnifyMinus(); |
192 | break; |
193 | break; |
193 | case 018: //E |
194 | case 018: //E |
194 | EventRunEdit(); |
195 | EventRunEdit(); |
195 | break; |
196 | break; |
196 | case 035: //H |
197 | case 035: //H |
197 | EventShowHistory(); |
198 | EventShowHistory(); |
198 | break; |
199 | break; |
199 | case SCAN_CODE_TAB: |
200 | case SCAN_CODE_TAB: |
200 | EventChangeEncoding(); |
201 | EventChangeEncoding(); |
201 | break; |
202 | break; |
202 | } |
203 | } |
203 | return; |
204 | return; |
204 | } |
205 | } |
205 | if (list.ProcessKey(key_scancode)) { |
206 | if (list.ProcessKey(key_scancode)) { |
206 | DrawPage(); |
207 | DrawPage(); |
207 | return; |
208 | return; |
208 | } |
209 | } |
209 | if (key_ascii != 0x0d) |
210 | if (key_ascii != 0x0d) |
210 | && (key_ascii != ASCII_KEY_PGDN) |
211 | && (key_ascii != ASCII_KEY_PGDN) |
211 | && (key_ascii != ASCII_KEY_PGUP) { |
212 | && (key_ascii != ASCII_KEY_PGUP) { |
212 | EAX = key_ascii << 8; |
213 | EAX = key_ascii << 8; |
213 | edit_box_key stdcall(#address_box); |
214 | edit_box_key stdcall(#address_box); |
214 | } |
215 | } |
215 | } |
216 | } |
216 | 217 | ||
217 | 218 | ||
218 | void HandleMouseEvent() |
219 | void HandleMouseEvent() |
219 | { |
220 | { |
220 | edit_box_mouse stdcall (#address_box); |
221 | edit_box_mouse stdcall (#address_box); |
221 | mouse.get(); |
222 | mouse.get(); |
222 | list.wheel_size = 7; |
223 | list.wheel_size = 7; |
223 | link.hover(); |
224 | link.hover(); |
224 | if (list.MouseScroll(mouse.vert)) { |
225 | if (list.MouseScroll(mouse.vert)) { |
225 | DrawPage(); |
226 | DrawPage(); |
226 | return; |
227 | return; |
227 | } |
228 | } |
228 | scrollbar_v_mouse (#scroll); |
229 | scrollbar_v_mouse (#scroll); |
229 | if (list.first != scroll.position) { |
230 | if (list.first != scroll.position) { |
230 | list.first = scroll.position; |
231 | list.first = scroll.position; |
231 | DrawPage(); |
232 | DrawPage(); |
232 | } |
233 | } |
233 | } |
234 | } |
234 | 235 | ||
235 | 236 | ||
236 | /* ----------------------------------------------------- */ |
237 | /* ----------------------------------------------------- */ |
237 | 238 | ||
238 | void EventOpenDialog() |
239 | void EventOpenDialog() |
239 | { |
240 | { |
240 | OpenDialog_start stdcall (#o_dialog); |
241 | OpenDialog_start stdcall (#o_dialog); |
241 | if (o_dialog.status) EventOpenAddress(#openfile_path); |
242 | if (o_dialog.status) EventOpenAddress(#openfile_path); |
242 | } |
243 | } |
243 | 244 | ||
244 | void EventOpenAddress(dword _new_address) |
245 | void EventOpenAddress(dword _new_address) |
245 | { |
246 | { |
246 | char temp[UML]; |
247 | char temp[UML]; |
247 | char favicon_address[UML]; |
248 | char favicon_address[UML]; |
248 | if (!ESBYTE[_new_address]) return; |
249 | if (!ESBYTE[_new_address]) return; |
249 | debugln("===================================="); |
250 | debugln("===================================="); |
250 | debug("address: "); |
251 | debug("address: "); |
251 | debugln(_new_address); |
252 | debugln(_new_address); |
252 | strlcpy(#address, _new_address, UML); |
253 | strlcpy(#address, _new_address, UML); |
253 | strlwr(#address); |
254 | strlwr(#address); |
254 | DrawAddressBox(); |
255 | DrawAddressBox(); |
255 | 256 | ||
256 | /* |
257 | /* |
257 | There could be several possible types of addresses: |
258 | There could be several possible types of addresses: |
258 | - build in page |
259 | - build in page |
259 | - local file |
260 | - local file |
260 | - url |
261 | - url |
261 | So we need to detect what incoming address is |
262 | So we need to detect what incoming address is |
262 | and then halndle it in the propper way. |
263 | and then halndle it in the propper way. |
263 | */ |
264 | */ |
264 | 265 | ||
265 | io.buffer_data = 0; |
266 | io.buffer_data = 0; |
266 | favicon.get(NULL); |
267 | favicon.get(NULL); |
267 | 268 | ||
268 | // - build in page |
269 | // - build in page |
269 | if (!strncmp(#address,"aelia:",6)) { |
270 | if (!strncmp(#address,"aelia:",6)) { |
270 | debugln("this is buildin page"); |
271 | debugln("this is buildin page"); |
271 | if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home; |
272 | if (!strcmp(#address,"aelia:home")) io.buffer_data = #buidin_page_home; |
272 | if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about; |
273 | if (!strcmp(#address,"aelia:about")) io.buffer_data = #buidin_page_about; |
273 | if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory(); |
274 | if (!strcmp(#address,"aelia:history")) io.buffer_data = MakePageWithHistory(); |
274 | } |
275 | } |
275 | // - local file |
276 | // - local file |
276 | else if (check_is_the_adress_local(#address)==true) { |
277 | else if (check_is_the_adress_local(#address)==true) { |
277 | debugln("this is local address"); |
278 | debugln("this is local address"); |
278 | io.read(#address); |
279 | io.read(#address); |
279 | } |
280 | } |
280 | // - url |
281 | // - url |
281 | else { |
282 | else { |
282 | debugln("this is url"); |
283 | debugln("this is url"); |
283 | if (strncmp(#address,"http://",7)!=0) { |
284 | if (strncmp(#address,"http://",7)!=0) { |
284 | strcpy(#temp, "http://"); |
285 | strcpy(#temp, "http://"); |
285 | strlcpy(#temp, #address, UML); |
286 | strlcpy(#temp, #address, UML); |
286 | strlcpy(#address, #temp, UML); |
287 | strlcpy(#address, #temp, UML); |
287 | DrawAddressBox(); |
288 | DrawAddressBox(); |
288 | } |
289 | } |
289 | if (!downloader.Start(#address)) { |
290 | if (!downloader.Start(#address)) { |
290 | downloader.Stop(); |
291 | downloader.Stop(); |
291 | } else { |
292 | } else { |
292 | while (downloader.state!=STATE_COMPLETED) |
293 | while (downloader.state!=STATE_COMPLETED) |
293 | { |
294 | { |
294 | downloader.MonitorProgress(); |
295 | downloader.MonitorProgress(); |
295 | if (downloader.data_full_size>0) |
296 | if (downloader.data_full_size>0) |
296 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE*downloader.data_downloaded_size/downloader.data_full_size); |
297 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE*downloader.data_downloaded_size/downloader.data_full_size); |
297 | else |
298 | else |
298 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2); |
299 | DrawProgress(STEP_2_COUNT_PAGE_HEIGHT-STEP_1_DOWNLOAD_PAGE/2); |
299 | } |
300 | } |
300 | strcpy(#address,downloader.url); |
301 | strcpy(#address,downloader.url); |
301 | DrawAddressBox(); |
302 | DrawAddressBox(); |
302 | io.buffer_data = downloader.bufpointer; |
303 | io.buffer_data = downloader.bufpointer; |
303 | get_absolute_url(#favicon_address, #address, "/favicon.ico"); |
304 | get_absolute_url(#favicon_address, #address, "/favicon.ico"); |
304 | favicon.get(#favicon_address); |
305 | favicon.get(#favicon_address); |
305 | } |
306 | } |
306 | } |
307 | } |
307 | 308 | ||
308 | if (!io.buffer_data) { |
309 | if (!io.buffer_data) { |
309 | debugln("page not found"); |
310 | debugln("page not found"); |
310 | io.buffer_data = #buidin_page_not_found; |
311 | io.buffer_data = #buidin_page_not_found; |
311 | } |
312 | } |
312 | 313 | ||
313 | history.add(#address); |
314 | history.add(#address); |
314 | favicon.draw(address_box.left-18, address_box.top-1); |
315 | favicon.draw(address_box.left-18, address_box.top-1); |
315 | 316 | ||
316 | /* |
317 | /* |
317 | Great! So we have the page in our buffer. |
318 | Great! So we have the page in our buffer. |
318 | We don't know is it a plain text or html. |
319 | We don't know is it a plain text or html. |
319 | So we need to parse it and draw. |
320 | So we need to parse it and draw. |
320 | */ |
321 | */ |
321 | 322 | ||
322 | list.KeyHome(); |
323 | list.KeyHome(); |
323 | list.ClearList(); |
324 | list.ClearList(); |
324 | PreparePage(); |
325 | PreparePage(); |
325 | } |
326 | } |
326 | 327 | ||
327 | void EventMagnifyPlus() |
328 | void EventMagnifyPlus() |
328 | { |
329 | { |
329 | label.size.pt++; |
330 | label.size.pt++; |
330 | if(!label.changeSIZE()) |
331 | if(!label.changeSIZE()) |
331 | label.size.pt--; |
332 | label.size.pt--; |
332 | else |
333 | else |
333 | PreparePage(); |
334 | PreparePage(); |
334 | } |
335 | } |
335 | 336 | ||
336 | void EventMagnifyMinus() |
337 | void EventMagnifyMinus() |
337 | { |
338 | { |
338 | label.size.pt--; |
339 | label.size.pt--; |
339 | if(!label.changeSIZE()) |
340 | if(!label.changeSIZE()) |
340 | label.size.pt++; |
341 | label.size.pt++; |
341 | else |
342 | else |
342 | PreparePage(); |
343 | PreparePage(); |
343 | } |
344 | } |
344 | 345 | ||
345 | void EventRunEdit() |
346 | void EventRunEdit() |
346 | { |
347 | { |
347 | if (check_is_the_adress_local(history.current())==true) { |
348 | if (check_is_the_adress_local(history.current())==true) { |
348 | io.run(DEFAULT_EDITOR, history.current()); |
349 | io.run(DEFAULT_EDITOR, history.current()); |
349 | } |
350 | } |
350 | else { |
351 | else { |
351 | //io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check |
352 | //io.write(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); // <--- doesn't work, smth odd, need to check |
352 | WriteFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); |
353 | WriteFile(strlen(io.buffer_data), io.buffer_data, DEFAULT_PREVIEW_PATH); |
353 | io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH); |
354 | io.run(DEFAULT_EDITOR, DEFAULT_PREVIEW_PATH); |
354 | } |
355 | } |
355 | } |
356 | } |
356 | 357 | ||
357 | void EventChangeEncoding() |
358 | void EventChangeEncoding() |
358 | { |
359 | { |
359 | menu.selected = encoding + 1; |
360 | menu.selected = encoding + 1; |
360 | menu.show(Form.left+Form.cwidth-97,Form.top+TOOLBAR_H+skin_height-6, 130, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10); |
361 | menu.show(Form.left+Form.cwidth-97,Form.top+TOOLBAR_H+skin_height-6, 130, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10); |
361 | } |
362 | } |
362 | 363 | ||
363 | void EventShowInfo() { |
364 | void EventShowInfo() { |
364 | EventOpenAddress("aelia:about"); |
365 | EventOpenAddress("aelia:about"); |
365 | } |
366 | } |
366 | 367 | ||
367 | void EventShowHistory() |
368 | void EventShowHistory() |
368 | { |
369 | { |
369 | EventOpenAddress("aelia:history"); |
370 | EventOpenAddress("aelia:history"); |
370 | } |
371 | } |
371 | 372 | ||
372 | void EventGoBack() |
373 | void EventGoBack() |
373 | { |
374 | { |
374 | if (history.back()) EventOpenAddress(history.current()); |
375 | if (history.back()) EventOpenAddress(history.current()); |
375 | } |
376 | } |
376 | 377 | ||
377 | void EventGoForward() |
378 | void EventGoForward() |
378 | { |
379 | { |
379 | if (history.forward()) EventOpenAddress(history.current()); |
380 | if (history.forward()) EventOpenAddress(history.current()); |
380 | } |
381 | } |
381 | 382 | ||
382 | void EventShowSandwichMenu() |
383 | void EventShowSandwichMenu() |
383 | { |
384 | { |
384 | menu.selected = 0; |
385 | menu.selected = 0; |
385 | menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20); |
386 | menu.show(Form.left+Form.cwidth-130,Form.top+TOOLBAR_H+skin_height-10, 130, SANDWICH_MENU, 20); |
386 | } |
387 | } |
387 | 388 | ||
388 | void EventPageRefresh() |
389 | void EventPageRefresh() |
389 | { |
390 | { |
390 | EventOpenAddress(history.current()); |
391 | EventOpenAddress(history.current()); |
391 | } |
392 | } |
392 | 393 | ||
393 | /* ------------------------------------------- */ |
394 | /* ------------------------------------------- */ |
394 | 395 | ||
395 | 396 | ||
396 | void draw_window() |
397 | void draw_window() |
397 | { |
398 | { |
398 | DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title); |
399 | DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title); |
399 | GetProcessInfo(#Form, SelfInfo); |
400 | GetProcessInfo(#Form, SelfInfo); |
400 | if (Form.status_window>2) return; |
401 | if (Form.status_window>2) return; |
401 | 402 | ||
402 | if (Form.width < 200) { MoveSize(OLD,OLD,200,OLD); return; } |
403 | if (Form.width < 200) { MoveSize(OLD,OLD,200,OLD); return; } |
403 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } |
404 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } |
404 | 405 | ||
405 | DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1); |
406 | DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 2, 0xe1e1e1); |
406 | DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece); |
407 | DrawBar(0, TOOLBAR_H - 2, Form.cwidth, 1, 0xcecece); |
407 | DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F); |
408 | DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F); |
408 | 409 | ||
409 | DrawToolbarButton(GO_BACK, 8); |
410 | DrawToolbarButton(GO_BACK, 8); |
410 | DrawToolbarButton(GO_FORWARD, 33); |
411 | DrawToolbarButton(GO_FORWARD, 33); |
411 | DrawToolbarButton(OPEN_FILE, 68); |
412 | DrawToolbarButton(OPEN_FILE, 68); |
412 | DrawToolbarButton(MAGNIFY_PLUS, Form.cwidth - 125); |
413 | DrawToolbarButton(MAGNIFY_PLUS, Form.cwidth - 125); |
413 | DrawToolbarButton(MAGNIFY_MINUS, Form.cwidth - 100); |
414 | DrawToolbarButton(MAGNIFY_MINUS, Form.cwidth - 100); |
414 | DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64); |
415 | DrawToolbarButton(CHANGE_ENCODING, Form.cwidth - 64); |
415 | DrawToolbarButton(SANDWICH, Form.cwidth - 31); |
416 | DrawToolbarButton(SANDWICH, Form.cwidth - 31); |
416 | 417 | ||
417 | DrawAddressBox(); |
418 | DrawAddressBox(); |
418 | 419 | ||
419 | if ((Form.cwidth-scroll.size_x-1 == list.w) && |
420 | if ((Form.cwidth-scroll.size_x-1 == list.w) && |
420 | (Form.cheight-TOOLBAR_H == list.h) && |
421 | (Form.cheight-TOOLBAR_H == list.h) && |
421 | (list.count) |
422 | (list.count) |
422 | ) |
423 | ) |
423 | { |
424 | { |
424 | DrawPage(); |
425 | DrawPage(); |
425 | } |
426 | } |
426 | else |
427 | else |
427 | { |
428 | { |
428 | if (!label.raw) { //this code need to be run |
429 | if (!label.raw) { //this code need to be run |
429 | if (param) EventOpenAddress(#param); //only once at browser sturtup |
430 | if (param) EventOpenAddress(#param); //only once at browser sturtup |
430 | else EventOpenAddress("aelia:home"); |
431 | else EventOpenAddress("aelia:home"); |
431 | } |
432 | } |
432 | else PreparePage(); |
433 | else PreparePage(); |
433 | } |
434 | } |
434 | 435 | ||
435 | DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col); |
436 | DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col); |
436 | } |
437 | } |
437 | 438 | ||
438 | void DrawPage() |
439 | void DrawPage() |
439 | { |
440 | { |
440 | list.CheckDoesValuesOkey(); |
441 | list.CheckDoesValuesOkey(); |
441 | if (list.count) _PutImage(list.x,list.y,list.w,list.h,list.first*list.item_h*list.w*3 + label.raw); |
442 | if (list.count) _PutImage(list.x,list.y,list.w,list.h,list.first*list.item_h*list.w*3 + label.raw); |
442 | DrawScroller(); |
443 | DrawScroller(); |
443 | } |
444 | } |
444 | 445 | ||
445 | void DrawAddressBox() |
446 | void DrawAddressBox() |
446 | { |
447 | { |
447 | address_box.left = 97+19; |
448 | address_box.left = 97+19; |
448 | address_box.top = 11; |
449 | address_box.top = 11; |
449 | address_box.width = Form.cwidth - address_box.left - 138; |
450 | address_box.width = Form.cwidth - address_box.left - 138; |
450 | DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C); |
451 | DrawRectangle(address_box.left-4-19, address_box.top-5, address_box.width+6+19, 23, 0x8C8C8C); |
451 | DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color); |
452 | DrawWideRectangle(address_box.left-3-19, address_box.top-3, address_box.width+5+19, 21, 4, address_box.color); |
452 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address); |
453 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#address); |
453 | address_box.offset = 0; |
454 | address_box.offset = 0; |
454 | edit_box_draw stdcall(#address_box); |
455 | edit_box_draw stdcall(#address_box); |
455 | favicon.draw(address_box.left-18, address_box.top-1); |
456 | favicon.draw(address_box.left-18, address_box.top-1); |
456 | DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff); |
457 | DrawBar(address_box.left-2, address_box.top+1, 2, 13, 0xFFFfff); |
457 | }>>--->><>20)> |
458 | }>>--->><>20)> |