Patch level : 4.0
Files correlati : agalib Ricompilazione Demo : [ ] Commento : progind.cpp: aggiunto tempo totale oltre a quello residuo reprint: eliminati warning relativi all'uso della "pericolosa" sscanf git-svn-id: svn://10.65.10.50/trunk@15155 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0270efe4ef
commit
27209d4ef2
@ -127,6 +127,15 @@ RCT* TIndwin::get_bar_rct(RCT& r) const
|
|||||||
return &r;
|
return &r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TIndwin::sec2str(unsigned long ss, TString& str) const
|
||||||
|
{
|
||||||
|
const unsigned long hh = ss / 3600;
|
||||||
|
ss -= hh*3600;
|
||||||
|
const unsigned long mm = ss / 60;
|
||||||
|
ss -= mm *60;
|
||||||
|
str.format("%02ld:%02ld:%02ld", hh, mm, ss);
|
||||||
|
}
|
||||||
|
|
||||||
void TIndwin::update_bar()
|
void TIndwin::update_bar()
|
||||||
{
|
{
|
||||||
if (_status >= _max)
|
if (_status >= _max)
|
||||||
@ -156,19 +165,6 @@ void TIndwin::update_bar()
|
|||||||
const int lasti = (b.bottom-b.top)/2;
|
const int lasti = (b.bottom-b.top)/2;
|
||||||
for (int i = 0; i <= lasti; i++)
|
for (int i = 0; i <= lasti; i++)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
set_pen(blend_colors(FOCUS_BACK_COLOR, MASK_BACK_COLOR, double(i) / double(lasti)));
|
|
||||||
PNT pt = { b.top+i, b.left };
|
|
||||||
xvt_dwin_draw_set_pos(w, pt);
|
|
||||||
pt.h = b.right;
|
|
||||||
xvt_dwin_draw_line(w, pt);
|
|
||||||
|
|
||||||
pt.h = b.left;
|
|
||||||
pt.v = b.bottom-i-1;
|
|
||||||
xvt_dwin_draw_set_pos(w, pt);
|
|
||||||
pt.h = b.right;
|
|
||||||
xvt_dwin_draw_line(w, pt);
|
|
||||||
*/
|
|
||||||
const short cy = b.top + (b.bottom-b.top)/4;
|
const short cy = b.top + (b.bottom-b.top)/4;
|
||||||
RCT g = b; g.bottom = cy;
|
RCT g = b; g.bottom = cy;
|
||||||
xvt_dwin_draw_gradient_linear(w, &g, BTN_LIGHT_COLOR, BTN_BACK_COLOR, 90);
|
xvt_dwin_draw_gradient_linear(w, &g, BTN_LIGHT_COLOR, BTN_BACK_COLOR, 90);
|
||||||
@ -179,16 +175,14 @@ void TIndwin::update_bar()
|
|||||||
if (prc > 0)
|
if (prc > 0)
|
||||||
{
|
{
|
||||||
const unsigned long elapsed_time = (clock() - _start_time)/CLOCKS_PER_SEC;
|
const unsigned long elapsed_time = (clock() - _start_time)/CLOCKS_PER_SEC;
|
||||||
const unsigned long total_time = (unsigned long)(elapsed_time / prc);
|
const unsigned long total_time = (unsigned long)(elapsed_time / prc + 0.5);
|
||||||
unsigned long ss = total_time - elapsed_time;
|
TString8 str_res, str_tot;
|
||||||
const unsigned long hh = ss / 3600;
|
sec2str(total_time - elapsed_time, str_res);
|
||||||
ss -= hh*3600;
|
sec2str(total_time, str_tot);
|
||||||
const unsigned long mm = ss / 60;
|
|
||||||
ss -= mm *60;
|
|
||||||
TString80 n;
|
TString80 n;
|
||||||
n.format("%d%% - %s %02lu:%02lu:%02lu",
|
n.format("%d%% - %s %s - %s %s", int(prc*100.0+0.5),
|
||||||
int(prc*100.0+0.5), TR("Tempo residuo stimato"), hh, mm, ss);
|
TR("Tempo residuo"), (const char*)str_res, TR("Tempo totale"), (const char*)str_tot);
|
||||||
|
|
||||||
b = r;
|
b = r;
|
||||||
b.top = b.bottom+2;
|
b.top = b.bottom+2;
|
||||||
b.bottom = b.top + CHARY;
|
b.bottom = b.top + CHARY;
|
||||||
|
@ -54,6 +54,9 @@ protected:
|
|||||||
// @cmember Calcola il rettangolo della barra di attesa
|
// @cmember Calcola il rettangolo della barra di attesa
|
||||||
RCT* get_bar_rct(RCT& r) const;
|
RCT* get_bar_rct(RCT& r) const;
|
||||||
|
|
||||||
|
// @cmember converte secondi in una stringa nel formato hh:mm:ss
|
||||||
|
void sec2str(unsigned long ss, TString& str) const;
|
||||||
|
|
||||||
// @cmember Gestisce gli eventi tasto della finestra
|
// @cmember Gestisce gli eventi tasto della finestra
|
||||||
virtual bool on_key(KEY k);
|
virtual bool on_key(KEY k);
|
||||||
|
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
|
|
||||||
static bool _print_aborted = false;
|
static bool _print_aborted = false;
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1400
|
||||||
|
#define SAFE_SCAN sscanf_s
|
||||||
|
#else
|
||||||
|
#define SAFE_SCAN sscanf
|
||||||
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Utility
|
// Utility
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -1296,7 +1302,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
|||||||
{
|
{
|
||||||
COLOR col = COLOR_BLACK;
|
COLOR col = COLOR_BLACK;
|
||||||
PAT_STYLE pat = PAT_SOLID;
|
PAT_STYLE pat = PAT_SOLID;
|
||||||
sscanf(str, "<brush color=%u pattern=%u />", &col, &pat);
|
SAFE_SCAN(str, "<brush color=%u pattern=%u />", &col, &pat);
|
||||||
if (pat <= PAT_HOLLOW)
|
if (pat <= PAT_HOLLOW)
|
||||||
win.hide_brush();
|
win.hide_brush();
|
||||||
else
|
else
|
||||||
@ -1319,7 +1325,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
|||||||
if (str.starts_with("<frame "))
|
if (str.starts_with("<frame "))
|
||||||
{
|
{
|
||||||
long x, y, dx, dy;
|
long x, y, dx, dy;
|
||||||
sscanf(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
|
SAFE_SCAN(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
|
||||||
_rect.set(x, y, dx, dy);
|
_rect.set(x, y, dx, dy);
|
||||||
win.log2dev(_rect, rct);
|
win.log2dev(_rect, rct);
|
||||||
continue;
|
continue;
|
||||||
@ -1373,7 +1379,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
|||||||
COLOR col = COLOR_BLACK;
|
COLOR col = COLOR_BLACK;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
PEN_STYLE style = P_SOLID;
|
PEN_STYLE style = P_SOLID;
|
||||||
sscanf(str, "<pen color=%u width=%d style=%u />", &col, &width, &style);
|
SAFE_SCAN(str, "<pen color=%u width=%d style=%u />", &col, &width, &style);
|
||||||
if (width < 0)
|
if (width < 0)
|
||||||
win.hide_pen();
|
win.hide_pen();
|
||||||
else
|
else
|
||||||
@ -1418,15 +1424,15 @@ bool TBook::print_page(TWindow& win, size_t page)
|
|||||||
}
|
}
|
||||||
if (str.starts_with("<text_align "))
|
if (str.starts_with("<text_align "))
|
||||||
{
|
{
|
||||||
sscanf(str, "<text_align horizontal=%c vertical=%c />",
|
SAFE_SCAN(str, "<text_align horizontal=%c vertical=%c />",
|
||||||
&_horizontal_alignment, &_vertical_alignment);
|
&_horizontal_alignment, &_vertical_alignment);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (str.starts_with("<text_color"))
|
if (str.starts_with("<text_color"))
|
||||||
{
|
{
|
||||||
COLOR fore, back;
|
COLOR fore, back;
|
||||||
int opaque;
|
int opaque;
|
||||||
sscanf(str, "<text_color fore=%u back=%u opaque=%d />", &fore, &back, &opaque);
|
SAFE_SCAN(str, "<text_color fore=%u back=%u opaque=%d />", &fore, &back, &opaque);
|
||||||
win.set_color(fore, back);
|
win.set_color(fore, back);
|
||||||
win.set_opaque_text(opaque != 0);
|
win.set_opaque_text(opaque != 0);
|
||||||
continue;
|
continue;
|
||||||
@ -1478,7 +1484,7 @@ bool TBook::export_text(const TFilename& fname)
|
|||||||
if (str.starts_with("<frame "))
|
if (str.starts_with("<frame "))
|
||||||
{
|
{
|
||||||
long x, y, dx, dy;
|
long x, y, dx, dy;
|
||||||
sscanf(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
|
SAFE_SCAN(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
|
||||||
row = y * lpi() / res.y;
|
row = y * lpi() / res.y;
|
||||||
col = x * cpi() / res.x;
|
col = x * cpi() / res.x;
|
||||||
wid = dx * cpi() / res.x;
|
wid = dx * cpi() / res.x;
|
||||||
@ -1585,8 +1591,8 @@ bool TBook::export_text(const TFilename& fname)
|
|||||||
} else
|
} else
|
||||||
if (str.starts_with("<text_align "))
|
if (str.starts_with("<text_align "))
|
||||||
{
|
{
|
||||||
sscanf(str, "<text_align horizontal=%c vertical=%c />",
|
SAFE_SCAN(str, "<text_align horizontal=%c vertical=%c />",
|
||||||
&_horizontal_alignment, &_vertical_alignment);
|
&_horizontal_alignment, &_vertical_alignment);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1669,7 +1675,7 @@ void TBook::split_file(int colonne)
|
|||||||
if (str.starts_with("<frame "))
|
if (str.starts_with("<frame "))
|
||||||
{
|
{
|
||||||
long x, y, dx, dy;
|
long x, y, dx, dy;
|
||||||
sscanf(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
|
SAFE_SCAN(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
|
||||||
str.format("<frame x=%ld y=%ld dx=%ld dy=%ld />", x-rct_page.x, y, dx, dy);
|
str.format("<frame x=%ld y=%ld dx=%ld dy=%ld />", x-rct_page.x, y, dx, dy);
|
||||||
} else
|
} else
|
||||||
if (str.starts_with("</page "))
|
if (str.starts_with("</page "))
|
||||||
@ -2636,4 +2642,4 @@ bool TReport_book::on_link(const TReport_link& lnk)
|
|||||||
|
|
||||||
TReport_book::TReport_book(const char* name)
|
TReport_book::TReport_book(const char* name)
|
||||||
: TBook(name), _report(NULL)
|
: TBook(name), _report(NULL)
|
||||||
{ }
|
{ }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user