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;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (_status >= _max)
|
||||
@ -156,19 +165,6 @@ void TIndwin::update_bar()
|
||||
const int lasti = (b.bottom-b.top)/2;
|
||||
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;
|
||||
RCT g = b; g.bottom = cy;
|
||||
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)
|
||||
{
|
||||
const unsigned long elapsed_time = (clock() - _start_time)/CLOCKS_PER_SEC;
|
||||
const unsigned long total_time = (unsigned long)(elapsed_time / prc);
|
||||
unsigned long ss = total_time - elapsed_time;
|
||||
const unsigned long hh = ss / 3600;
|
||||
ss -= hh*3600;
|
||||
const unsigned long mm = ss / 60;
|
||||
ss -= mm *60;
|
||||
const unsigned long total_time = (unsigned long)(elapsed_time / prc + 0.5);
|
||||
TString8 str_res, str_tot;
|
||||
sec2str(total_time - elapsed_time, str_res);
|
||||
sec2str(total_time, str_tot);
|
||||
|
||||
TString80 n;
|
||||
n.format("%d%% - %s %02lu:%02lu:%02lu",
|
||||
int(prc*100.0+0.5), TR("Tempo residuo stimato"), hh, mm, ss);
|
||||
|
||||
n.format("%d%% - %s %s - %s %s", int(prc*100.0+0.5),
|
||||
TR("Tempo residuo"), (const char*)str_res, TR("Tempo totale"), (const char*)str_tot);
|
||||
b = r;
|
||||
b.top = b.bottom+2;
|
||||
b.bottom = b.top + CHARY;
|
||||
|
@ -54,6 +54,9 @@ protected:
|
||||
// @cmember Calcola il rettangolo della barra di attesa
|
||||
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
|
||||
virtual bool on_key(KEY k);
|
||||
|
||||
|
@ -17,6 +17,12 @@
|
||||
|
||||
static bool _print_aborted = false;
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#define SAFE_SCAN sscanf_s
|
||||
#else
|
||||
#define SAFE_SCAN sscanf
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utility
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1296,7 +1302,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
{
|
||||
COLOR col = COLOR_BLACK;
|
||||
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)
|
||||
win.hide_brush();
|
||||
else
|
||||
@ -1319,7 +1325,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
if (str.starts_with("<frame "))
|
||||
{
|
||||
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);
|
||||
win.log2dev(_rect, rct);
|
||||
continue;
|
||||
@ -1373,7 +1379,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
COLOR col = COLOR_BLACK;
|
||||
int width = 0;
|
||||
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)
|
||||
win.hide_pen();
|
||||
else
|
||||
@ -1418,15 +1424,15 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
}
|
||||
if (str.starts_with("<text_align "))
|
||||
{
|
||||
sscanf(str, "<text_align horizontal=%c vertical=%c />",
|
||||
&_horizontal_alignment, &_vertical_alignment);
|
||||
SAFE_SCAN(str, "<text_align horizontal=%c vertical=%c />",
|
||||
&_horizontal_alignment, &_vertical_alignment);
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<text_color"))
|
||||
{
|
||||
COLOR fore, back;
|
||||
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_opaque_text(opaque != 0);
|
||||
continue;
|
||||
@ -1478,7 +1484,7 @@ bool TBook::export_text(const TFilename& fname)
|
||||
if (str.starts_with("<frame "))
|
||||
{
|
||||
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;
|
||||
col = x * cpi() / res.x;
|
||||
wid = dx * cpi() / res.x;
|
||||
@ -1585,8 +1591,8 @@ bool TBook::export_text(const TFilename& fname)
|
||||
} else
|
||||
if (str.starts_with("<text_align "))
|
||||
{
|
||||
sscanf(str, "<text_align horizontal=%c vertical=%c />",
|
||||
&_horizontal_alignment, &_vertical_alignment);
|
||||
SAFE_SCAN(str, "<text_align horizontal=%c vertical=%c />",
|
||||
&_horizontal_alignment, &_vertical_alignment);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1669,7 +1675,7 @@ void TBook::split_file(int colonne)
|
||||
if (str.starts_with("<frame "))
|
||||
{
|
||||
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);
|
||||
} else
|
||||
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)
|
||||
: TBook(name), _report(NULL)
|
||||
{ }
|
||||
{ }
|
||||
|
Loading…
x
Reference in New Issue
Block a user