3,6 → 3,8 |
#include "..\lib\kolibri.h" |
#include "..\lib\strings.h" |
#include "..\lib\figures.h" |
#include "..\lib\encoding.h" |
#include "..\lib\draw_buf.h" |
#include "..\lib\file_system.h" |
#include "..\lib\mem.h" |
#include "..\lib\dll.h" |
12,7 → 14,7 |
#include "..\lib\lib.obj\libio_lib.h" |
#include "..\lib\lib.obj\http.h" |
|
char header[]="New Downloader v0.4"; |
char header[]="New Downloader v0.5"; |
|
#ifdef LANG_RUS |
char accept_language[]= "Accept-Language: ru\n"; |
22,7 → 24,7 |
|
proc_info Form; |
#define WIN_W 400 |
#define WIN_H 240 |
#define WIN_H 220 |
system_colors sc; |
#define URL param |
|
37,9 → 39,7 |
dword http_transfer = 0; |
dword http_buffer; |
|
struct diagram { |
int x,y,w,h; |
} diagram; |
DrawBufer diagram; |
|
void main() |
{ |
55,7 → 55,7 |
if (!URL) strcpy(#URL, "http://builds.kolibrios.org/eng/latest-iso.7z"); |
address_box.size = address_box.pos = strlen(#URL); |
|
SetEventMask(0xa7); |
SetEventMask(0x27); //a7 |
loop() |
{ |
WaitEventTimeout(40); |
89,10 → 89,7 |
if (Form.status_window>2) return; |
if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
diagram.x = 20; |
diagram.y = 87; |
diagram.w = Form.cwidth - diagram.x - diagram.x; |
diagram.h = Form.cheight - diagram.y - 28; |
diagram.Init(20, 87, Form.cwidth - 40, Form.cheight - 87 - 28); |
Draw_Window(); |
break; |
|
132,23 → 129,22 |
void DrawSpeed() |
{ |
int i; |
int speed_in_position; |
int speed_in_position, speed_string; |
int max_speed, start_from; |
char bytes_received[70]; |
|
DrawBar(diagram.x, diagram.y, diagram.w, diagram.h+1, 0xFCF8F7); |
diagram.Fill(0xFCF8F7); |
max_speed = speed[speed_position]; |
if (speed_position < diagram.w) start_from = 0; else start_from = speed_position - diagram.w; |
if (speed_position < diagram.bufw) start_from = 0; else start_from = speed_position - diagram.bufw + 1; |
for (i = 0; i <= speed_position-start_from; i++) |
{ |
if (max_speed>0) |
{ |
speed_in_position = diagram.h - 2 * speed[i+start_from] / max_speed; |
PutPixel(diagram.x+i, diagram.h - speed_in_position + diagram.y, 0x00A3CB); |
ECX++; |
$int 64; |
speed_in_position = diagram.bufh - 1 * speed[i+start_from] / max_speed; |
diagram.DrawBar(i, diagram.bufh - speed_in_position, 1, speed_in_position, 0x00A3CB); |
} |
} |
diagram.Show(); |
if (speed_position==0) return; |
if (http_transfer > 0) |
{ |
158,29 → 154,37 |
{ |
strcpy(#bytes_received, "Downloading competle. "); |
} |
strcat(#bytes_received, itoa(speed[speed_position-1])); |
strcat(#bytes_received, " bytes received."); |
DrawBar(diagram.x, diagram.y + diagram.h + 10, diagram.w, 9, sc.work); |
WriteText(diagram.x, diagram.y + diagram.h + 10, 0x80, sc.work_text, #bytes_received); |
speed_string = ConvertSize(speed[speed_position-1]); |
strcat(#bytes_received, speed_string); |
strcat(#bytes_received, " received."); |
DrawBar(diagram.bufx, diagram.bufy + diagram.bufh + 10, diagram.bufw, 9, sc.work); |
WriteText(diagram.bufx, diagram.bufy + diagram.bufh + 10, 0x80, sc.work_text, #bytes_received); |
} |
|
void Draw_Window() |
{ |
DrawBar(0,0,Form.cwidth,Form.cheight,sc.work); //bg |
DrawCaptButton(diagram.x, 50, 120, 20, 301, sc.work_button, sc.work_button_text, "Start downloading"); |
if (http_transfer <= 0) |
{ |
DrawCaptButton(diagram.bufx, 50, 120, 20, 301, sc.work_button, sc.work_button_text, "Start downloading"); |
} |
else |
{ |
DrawCaptButton(diagram.bufx, 50, 120, 20, 302, sc.work_button, sc.work_button_text, "Stop downloading"); |
} |
if (http_transfer <= 0) && (speed_position>0) |
{ |
DrawCaptButton(diagram.x+130, 50, 120, 20, 305, sc.work_button, sc.work_button_text, "Show in folder"); |
DrawCaptButton(diagram.bufx+130, 50, 120, 20, 305, sc.work_button, sc.work_button_text, "Show in folder"); |
} |
WriteText(diagram.x, address_box.top + 4, 0x80, sc.work_text, "URL:"); |
address_box.left = strlen("URL:")*6 + 10 + diagram.x; |
address_box.width = Form.cwidth - address_box.left - diagram.x - 3; |
WriteText(diagram.bufx, address_box.top + 4, 0x80, sc.work_text, "URL:"); |
address_box.left = strlen("URL:")*6 + 10 + diagram.bufx; |
address_box.width = Form.cwidth - address_box.left - diagram.bufx - 3; |
address_box.offset=0; |
edit_box_draw stdcall(#address_box); |
DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,sc.work_graph); |
|
DrawRectangle(diagram.x-2, diagram.y-2, diagram.w+2, diagram.h+3, sc.work_graph); |
DrawRectangle(diagram.bufx-2, diagram.bufy-2, diagram.bufw+2, diagram.bufh+2, sc.work_graph); |
DrawSpeed(); |
} |
|