Rev 7806 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7806 | Rev 7910 | ||
---|---|---|---|
1 | #define MEMSIZE 4096 * 200 |
1 | #define MEMSIZE 4096 * 200 |
2 | 2 | ||
3 | //libraries |
3 | //libraries |
4 | #include "..\lib\gui.h" |
4 | #include "..\lib\gui.h" |
5 | #include "..\lib\draw_buf.h" |
5 | #include "..\lib\draw_buf.h" |
6 | #include "..\lib\list_box.h" |
6 | #include "..\lib\list_box.h" |
7 | #include "..\lib\cursor.h" |
7 | #include "..\lib\cursor.h" |
8 | #include "..\lib\collection.h" |
8 | #include "..\lib\collection.h" |
9 | #include "..\lib\random.h" |
9 | #include "..\lib\random.h" |
10 | #include "..\lib\clipboard.h" |
10 | #include "..\lib\clipboard.h" |
11 | 11 | ||
12 | // *.obj libraries |
12 | // *.obj libraries |
13 | #include "..\lib\obj\box_lib.h" |
13 | #include "..\lib\obj\box_lib.h" |
14 | #include "..\lib\obj\libio.h" |
14 | #include "..\lib\obj\libio.h" |
15 | #include "..\lib\obj\libimg.h" |
15 | #include "..\lib\obj\libimg.h" |
16 | #include "..\lib\obj\iconv.h" |
16 | #include "..\lib\obj\iconv.h" |
17 | #include "..\lib\obj\proc_lib.h" |
17 | #include "..\lib\obj\proc_lib.h" |
18 | 18 | ||
19 | //useful patterns |
19 | //useful patterns |
20 | #include "..\lib\patterns\simple_open_dialog.h" |
20 | #include "..\lib\patterns\simple_open_dialog.h" |
21 | #include "..\lib\patterns\toolbar_button.h" |
21 | #include "..\lib\patterns\toolbar_button.h" |
22 | 22 | ||
23 | char homepage[] = FROM "html\\homepage.htm""\0"; |
23 | char homepage[] = FROM "html\\homepage.htm""\0"; |
24 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
24 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
25 | 25 | ||
26 | char version[]="C-- Code View"; |
26 | char version[]="C-- Code View"; |
27 | char accept_language[]= "Accept-Language: en\n"; |
27 | char accept_language[]= "Accept-Language: en\n"; |
28 | 28 | ||
29 | #define URL_SERVICE_HOME "CodeView:home" |
29 | #define URL_SERVICE_HOME "CodeView:home" |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | proc_info Form; |
33 | proc_info Form; |
34 | 34 | ||
35 | 35 | ||
36 | dword TOOLBAR_H = 40; |
36 | dword TOOLBAR_H = 40; |
37 | dword STATUSBAR_H = 0; |
37 | dword STATUSBAR_H = 0; |
38 | 38 | ||
39 | 39 | ||
40 | bool debug_mode = false; |
40 | bool debug_mode = false; |
41 | 41 | ||
42 | bool open_in_a_new_window = false; |
42 | bool open_in_a_new_window = false; |
43 | 43 | ||
44 | enum { |
44 | enum { |
45 | REFRESH_BUTTON, |
45 | REFRESH_BUTTON, |
46 | EDIT_SOURCE, |
46 | EDIT_SOURCE, |
47 | OPEN_PAGE, |
47 | OPEN_PAGE, |
48 | }; |
48 | }; |
49 | 49 | ||
50 | #define URL_SIZE 4000; |
50 | #define URL_SIZE 4000; |
51 | #include "..\TWB\TWB.c" |
51 | #include "..\TWB\TWB.c" |
52 | TWebBrowser WB1; |
52 | TWebBrowser WB1; |
53 | #include "highlight_c.h" |
53 | #include "highlight_c.h" |
54 | 54 | ||
55 | char default_dir[] = "/rd/1"; |
55 | char default_dir[] = "/rd/1"; |
56 | od_filter filter2 = { 16, "C\0H\0C--\0H--\0CPP\0\0" }; |
56 | od_filter filter2 = { 16, "C\0H\0C--\0H--\0CPP\0\0" }; |
57 | 57 | ||
58 | char current_path[URL_SIZE+1]; |
58 | char current_path[URL_SIZE+1]; |
59 | char edit_path[URL_SIZE+1]; |
59 | char edit_path[URL_SIZE+1]; |
60 | int mouse_twb; |
60 | int mouse_twb; |
61 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#edit_path,#mouse_twb,2,19,19}; |
61 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#edit_path,#mouse_twb,2,19,19}; |
62 | 62 | ||
63 | #define SKIN_Y 24 |
63 | #define SKIN_Y 24 |
64 | 64 | ||
65 | void LoadLibraries() |
65 | void LoadLibraries() |
66 | { |
66 | { |
67 | load_dll(boxlib, #box_lib_init,0); |
67 | load_dll(boxlib, #box_lib_init,0); |
68 | load_dll(libio, #libio_init,1); |
68 | load_dll(libio, #libio_init,1); |
69 | load_dll(libimg, #libimg_init,1); |
69 | load_dll(libimg, #libimg_init,1); |
70 | load_dll(iconv_lib, #iconv_open,0); |
70 | load_dll(iconv_lib, #iconv_open,0); |
71 | load_dll(Proc_lib, #OpenDialog_init,0); |
71 | load_dll(Proc_lib, #OpenDialog_init,0); |
72 | OpenDialog_init stdcall (#o_dialog); |
72 | OpenDialog_init stdcall (#o_dialog); |
73 | } |
73 | } |
74 | 74 | ||
75 | void main() |
75 | void main() |
76 | { |
76 | { |
77 | int i, id; |
77 | int i, id; |
78 | LoadLibraries(); |
78 | LoadLibraries(); |
79 | if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME); |
79 | if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME); |
80 | WB1.list.SetFont(8, 14, 10011000b); |
80 | WB1.list.SetFont(8, 14, 10011000b); |
81 | WB1.list.no_selection = true; |
81 | WB1.list.no_selection = true; |
82 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
82 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
83 | loop() switch(WaitEvent()) |
83 | loop() switch(WaitEvent()) |
84 | { |
84 | { |
85 | case evMouse: |
85 | case evMouse: |
86 | edit_box_mouse stdcall (#address_box); |
86 | edit_box_mouse stdcall (#address_box); |
87 | mouse.get(); |
87 | mouse.get(); |
88 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
88 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
89 | scrollbar_v_mouse (#scroll_wv); |
89 | scrollbar_v_mouse (#scroll_wv); |
90 | if (WB1.list.first != scroll_wv.position) |
90 | if (WB1.list.first != scroll_wv.position) |
91 | { |
91 | { |
92 | WB1.list.first = scroll_wv.position; |
92 | WB1.list.first = scroll_wv.position; |
93 | WB1.DrawPage(); |
93 | WB1.DrawPage(); |
94 | break; |
94 | break; |
95 | } |
95 | } |
96 | break; |
96 | break; |
97 | 97 | ||
98 | case evButton: |
98 | case evButton: |
99 | id = GetButtonID(); |
99 | id = GetButtonID(); |
100 | if (1==id) ExitProcess(); |
100 | if (1==id) ExitProcess(); |
101 | if (OPEN_PAGE==id) EventOpenDialog(); |
101 | if (OPEN_PAGE==id) EventOpenDialog(); |
102 | break; |
102 | break; |
103 | 103 | ||
104 | case evKey: |
104 | case evKey: |
105 | GetKeys(); |
105 | GetKeys(); |
106 | 106 | ||
107 | if (SCAN_CODE_F5 == key_scancode) { |
107 | if (SCAN_CODE_F5 == key_scancode) { |
108 | OpenPage(#current_path); |
108 | OpenPage(#current_path); |
109 | } |
109 | } |
110 | if (SCAN_CODE_F3 == key_scancode) { |
110 | if (SCAN_CODE_F3 == key_scancode) { |
111 | RunProgram("/rd/1/tinypad", #current_path); |
111 | RunProgram("/rd/1/tinypad", #current_path); |
112 | } |
112 | } |
113 | 113 | ||
114 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
114 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
115 | if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;} |
115 | if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;} |
116 | } |
116 | } |
117 | 117 | ||
118 | if (address_box.flags & 0b10) |
118 | if (address_box.flags & 0b10) |
119 | { |
119 | { |
120 | if (key_ascii == ASCII_KEY_ENTER) { |
120 | if (key_ascii == ASCII_KEY_ENTER) { |
121 | OpenPage(#edit_path); |
121 | OpenPage(#edit_path); |
122 | } |
122 | } |
123 | else { |
123 | else { |
124 | EAX = key_editbox; |
124 | EAX = key_editbox; |
125 | edit_box_key stdcall(#address_box); |
125 | edit_box_key stdcall(#address_box); |
126 | } |
126 | } |
127 | } |
127 | } |
128 | else |
128 | else |
129 | { |
129 | { |
130 | #define KEY_SCROLL_N 11 |
130 | #define KEY_SCROLL_N 11 |
131 | if (SCAN_CODE_UP == key_scancode) for (i=0;i |
131 | if (SCAN_CODE_UP == key_scancode) for (i=0;i |
132 | if (SCAN_CODE_DOWN == key_scancode) for (i=0;i |
132 | if (SCAN_CODE_DOWN == key_scancode) for (i=0;i |
133 | if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
133 | if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
134 | } |
134 | } |
135 | break; |
135 | break; |
136 | 136 | ||
137 | case evReDraw: |
137 | case evReDraw: |
138 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,sc.work,0,0); |
138 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,sc.work,0,0); |
139 | GetProcessInfo(#Form, SelfInfo); |
139 | GetProcessInfo(#Form, SelfInfo); |
140 | sc.get(); |
140 | sc.get(); |
141 | if (Form.status_window>2) break; |
141 | if (Form.status_window>2) break; |
142 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
142 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
143 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
143 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
144 | SetElementSizes(); |
144 | SetElementSizes(); |
145 | draw_window(); |
145 | draw_window(); |
146 | break; |
146 | break; |
147 | } |
147 | } |
148 | } |
148 | } |
149 | 149 | ||
150 | void SetElementSizes() |
150 | void SetElementSizes() |
151 | { |
151 | { |
152 | address_box.top = TOOLBAR_H/2-10; |
152 | address_box.top = TOOLBAR_H/2-10; |
153 | address_box.left = address_box.top+43; |
153 | address_box.left = address_box.top+43; |
154 | address_box.width = Form.cwidth - address_box.left - address_box.left -14; |
154 | address_box.width = Form.cwidth - address_box.left - address_box.left -14; |
155 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
155 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
156 | Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H); |
156 | Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H); |
157 | WB1.list.wheel_size = 7 * BASIC_LINE_H; |
157 | WB1.list.wheel_size = 7 * BASIC_LINE_H; |
158 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
158 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
159 | WB1.list.visible = WB1.list.h; |
159 | WB1.list.visible = WB1.list.h; |
160 | if (WB1.list.w!=DrawBuf.bufw) { |
160 | if (WB1.list.w!=DrawBuf.bufw) { |
161 | DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700); |
161 | DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700); |
162 | OpenPage(#current_path); |
162 | OpenPage(#current_path); |
163 | } |
163 | } |
164 | } |
164 | } |
165 | 165 | ||
166 | void draw_window() |
166 | void draw_window() |
167 | { |
167 | { |
168 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, sc.work); |
168 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, sc.work); |
169 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
169 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
170 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph); |
170 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph); |
171 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,sc.work_graph); |
171 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,sc.work_graph); |
172 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, sc.work); |
172 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, sc.work); |
173 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph); |
173 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph); |
174 | DrawEditBoxWebView(); |
174 | DrawEditBoxWebView(); |
175 | if (!WB1.header) { |
175 | if (!WB1.header) { |
176 | OpenPage(#current_path); |
176 | OpenPage(#current_path); |
177 | } else { |
177 | } else { |
178 | WB1.DrawPage(); |
178 | WB1.DrawPage(); |
179 | DrawEditBoxWebView(); |
179 | DrawEditBoxWebView(); |
180 | } |
180 | } |
181 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
181 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
182 | DrawTopPanelButton(OPEN_PAGE, 10, address_box.top-3, 0); |
182 | DrawTopPanelButton(OPEN_PAGE, 10, address_box.top-3, 0, false); |
183 | } |
183 | } |
184 | 184 | ||
185 | 185 | ||
186 | void OpenPage(dword _path) |
186 | void OpenPage(dword _path) |
187 | { |
187 | { |
188 | dword buf, size; |
188 | dword buf, size; |
189 | strcpy(#current_path, _path); |
189 | strcpy(#current_path, _path); |
190 | if (streq(_path, URL_SERVICE_HOME)) { |
190 | if (streq(_path, URL_SERVICE_HOME)) { |
191 | LoadInternalPage(#homepage, sizeof(homepage)); |
191 | LoadInternalPage(#homepage, sizeof(homepage)); |
192 | return; |
192 | return; |
193 | } |
193 | } |
194 | file_size stdcall (_path); |
194 | file_size stdcall (_path); |
195 | if (EBX) |
195 | if (EBX) |
196 | { |
196 | { |
197 | size = EBX; |
197 | size = EBX; |
198 | buf = malloc(size); |
198 | buf = malloc(size); |
199 | ReadFile(0, size, buf, _path); |
199 | ReadFile(0, size, buf, _path); |
200 | ShowCodeSource(); |
200 | ShowCodeSource(); |
201 | free(buf); |
201 | free(buf); |
202 | return; |
202 | return; |
203 | } |
203 | } |
204 | LoadInternalPage(NULL,NULL); |
204 | LoadInternalPage(NULL,NULL); |
205 | } |
205 | } |
206 | 206 | ||
207 | DrawEditBoxWebView() |
207 | DrawEditBoxWebView() |
208 | { |
208 | { |
209 | int skin_x_offset; |
209 | int skin_x_offset; |
210 | DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
210 | DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
211 | DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
211 | DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
212 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#edit_path); |
212 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#edit_path); |
213 | address_box.offset = 0; |
213 | address_box.offset = 0; |
214 | edit_box_draw stdcall(#address_box); |
214 | edit_box_draw stdcall(#address_box); |
215 | skin_x_offset = 51; |
215 | skin_x_offset = 51; |
216 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
216 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
217 | } |
217 | } |
218 | 218 | ||
219 | void LoadInternalPage(dword _bufpos, _bufsize) |
219 | void LoadInternalPage(dword _bufpos, _bufsize) |
220 | { |
220 | { |
221 | if (!_bufpos) || (!_bufsize) { |
221 | if (!_bufpos) || (!_bufsize) { |
222 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
222 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
223 | return; |
223 | return; |
224 | } |
224 | } |
225 | strcpy(#edit_path, #current_path); |
225 | strcpy(#edit_path, #current_path); |
226 | DrawEditBoxWebView(); |
226 | DrawEditBoxWebView(); |
227 | 227 | ||
228 | WB1.list.first = 0; |
228 | WB1.list.first = 0; |
229 | WB1.ParseHtml(_bufpos, _bufsize); |
229 | WB1.ParseHtml(_bufpos, _bufsize); |
230 | WB1.DrawPage(); |
230 | WB1.DrawPage(); |
231 | } |
231 | } |
232 | 232 | ||
233 | void EventOpenDialog() |
233 | void EventOpenDialog() |
234 | { |
234 | { |
235 | OpenDialog_start stdcall (#o_dialog); |
235 | OpenDialog_start stdcall (#o_dialog); |
236 | if (o_dialog.status) { |
236 | if (o_dialog.status) { |
237 | OpenPage(#openfile_path); |
237 | OpenPage(#openfile_path); |
238 | } |
238 | } |
239 | } |
239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void DrawStatusBar() {return;}; |
242 | void DrawStatusBar() {return;}; |
243 | void EventClickLink() {return;}; |
243 | void EventClickLink() {return;}; |
244 | void EventShowLinkMenu() {return;}; |
244 | void EventShowLinkMenu() {return;}; |
245 | 245 | ||
246 | char anchor[256]; |
246 | char anchor[256]; |
247 | 247 | ||
248 | stop:280)>120)> |
248 | stop:280)>120)> |