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