forked from KolibriOS/kolibrios
New Downloader: v0.5
git-svn-id: svn://kolibrios.org@4666 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
54b03fbe7b
commit
99f3b47240
@ -679,7 +679,7 @@ void TWebBrowser::NewLine(int left1, top1)
|
||||
{
|
||||
if (text_align == ALIGN_CENTER) DrawBuf.AlignCenter(left1,top1,list.w,list.line_h,stolbec * 6);
|
||||
if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(left1,top1,list.w,list.line_h,stolbec * 6);
|
||||
PutPaletteImage(buf_data+8, list.w, list.line_h, left1-5, top1, 32,0);
|
||||
DrawBuf.Show();
|
||||
DrawBuf.Fill(bg_color);
|
||||
}
|
||||
stroka++;
|
||||
|
@ -227,7 +227,7 @@ void SetElementSizes()
|
||||
WB1.list.SetSizes(0, 44, Form.width - 10 - scroll_wv.size_x, Form.cheight - 44, 0, 10);
|
||||
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
|
||||
WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
|
||||
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h, WB1.list.line_h);
|
||||
WB1.DrawBuf.Init(WB1.list.x, WB1.list.line_h, WB1.list.w, WB1.list.h);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@ char header[]="New Downloader v0.4";
|
||||
|
||||
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 bufsize;
|
||||
dword http_transfer = 0;
|
||||
dword http_buffer;
|
||||
|
||||
struct diagram {
|
||||
int x,y,w,h;
|
||||
} diagram;
|
||||
DrawBufer diagram;
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -55,7 +55,7 @@ void main()
|
||||
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 @@ void main()
|
||||
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 main()
|
||||
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 @@ void DrawSpeed()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -607,7 +607,7 @@ void Line_ReDraw(dword color, filenum){
|
||||
if (! TestBit(attr, 4) ) //file or folder?
|
||||
{
|
||||
Put_icon(off+_strrchr(off,'.'), files.x+3, files.line_h/2-7+y, color, 0);
|
||||
WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size
|
||||
WriteText(7-strlen(ConvertSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertSize(ESDWORD[off-8])); //size
|
||||
}
|
||||
else
|
||||
if (!strcmp("..",off))
|
||||
|
@ -2,33 +2,39 @@
|
||||
dword buf_data;
|
||||
|
||||
struct DrawBufer {
|
||||
int bufx, bufy, bufw, bufh, buf_line_h;
|
||||
int bufx, bufy, bufw, bufh;
|
||||
|
||||
void Init();
|
||||
void Show();
|
||||
void Fill();
|
||||
void Skew();
|
||||
void DrawBar();
|
||||
void PutPixel();
|
||||
void AlignCenter();
|
||||
void AlignRight();
|
||||
};
|
||||
|
||||
void DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh, i_buf_line_h)
|
||||
void DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh)
|
||||
{
|
||||
bufx = i_bufx;
|
||||
bufy = i_bufy;
|
||||
bufw = i_bufw;
|
||||
bufh = i_bufh;
|
||||
buf_line_h = i_buf_line_h;
|
||||
free(buf_data);
|
||||
buf_data = malloc(bufw * buf_line_h +4 * 4 + 8); //+1 for good luck
|
||||
buf_data = malloc(bufw * bufh * 4 + 8); //+1 for good luck
|
||||
ESDWORD[buf_data] = bufw;
|
||||
ESDWORD[buf_data+4] = buf_line_h;
|
||||
ESDWORD[buf_data+4] = bufh;
|
||||
}
|
||||
|
||||
void DrawBufer::Show()
|
||||
{
|
||||
PutPaletteImage(buf_data+8, bufw, bufh, bufx, bufy, 32,0);
|
||||
}
|
||||
|
||||
void DrawBufer::Fill(dword fill_color)
|
||||
{
|
||||
int i;
|
||||
int max_i = bufw * buf_line_h + 4 * 4 + buf_data +8;
|
||||
int max_i = bufw * bufh * 4 + buf_data + 8;
|
||||
for (i=buf_data+8; i<max_i; i+=4) ESDWORD[i] = fill_color;
|
||||
}
|
||||
|
||||
@ -41,6 +47,12 @@ void DrawBufer::DrawBar(dword x, y, w, h, color)
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBufer::PutPixel(dword x, y, color)
|
||||
{
|
||||
int pos = y*bufw+x*4+8+buf_data;
|
||||
ESDWORD[pos] = color;
|
||||
}
|
||||
|
||||
char shift[]={8,8,4,4};
|
||||
void DrawBufer::Skew(dword x, y, w, h)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ inline fastcall void utf8rutodos( ESI)
|
||||
}
|
||||
|
||||
|
||||
:dword ConvertMemSize(unsigned int bytes)
|
||||
:dword ConvertSize(unsigned int bytes)
|
||||
{
|
||||
unsigned char size_prefix[8], size_nm[4];
|
||||
if (bytes>=1073741824) strcpy(#size_nm, " Gb");
|
||||
|
Loading…
Reference in New Issue
Block a user