Correzioni su TDistrib in modo da gestire al meglio casi limite con totali nulli
git-svn-id: svn://10.65.10.50/branches/R_10_00@22922 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
de92695865
commit
b8d35eb40b
@ -57,9 +57,7 @@ public:
|
|||||||
// @cmember Ritorna il numero di oggetti nel contenitore
|
// @cmember Ritorna il numero di oggetti nel contenitore
|
||||||
virtual long objects( ) const pure;
|
virtual long objects( ) const pure;
|
||||||
// @cmember Ritorna true se il contenitore e' vuoto
|
// @cmember Ritorna true se il contenitore e' vuoto
|
||||||
virtual bool empty() const
|
virtual bool empty() const { return objects( ) == 0; }
|
||||||
|
|
||||||
{ return objects( ) == 0; }
|
|
||||||
|
|
||||||
// @cmember Cerca il successivo elemento che soddisfa la <t OPERATION_FUNCTION>
|
// @cmember Cerca il successivo elemento che soddisfa la <t OPERATION_FUNCTION>
|
||||||
virtual void for_each( OPERATION_FUNCTION );
|
virtual void for_each( OPERATION_FUNCTION );
|
||||||
|
@ -17,11 +17,8 @@
|
|||||||
#define XVT_INCL_NATIVE
|
#define XVT_INCL_NATIVE
|
||||||
#include <xvt.h>
|
#include <xvt.h>
|
||||||
#define S4OFF_REPORT
|
#define S4OFF_REPORT
|
||||||
|
//#define S4DLL
|
||||||
#if XVT_OS == XVT_OS_WIN32
|
//#define S4WIN32
|
||||||
#define S4DLL
|
|
||||||
#define S4WIN32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <d4all.h>
|
#include <d4all.h>
|
||||||
#include <codeb.h>
|
#include <codeb.h>
|
||||||
|
@ -1874,14 +1874,13 @@ void TPushbutton_control::update()
|
|||||||
{
|
{
|
||||||
XinWindow win = xi_get_window(_obj);
|
XinWindow win = xi_get_window(_obj);
|
||||||
XI_RCT rct; xi_get_rect(_obj, &rct); // = _obj->v.btn->rct;
|
XI_RCT rct; xi_get_rect(_obj, &rct); // = _obj->v.btn->rct;
|
||||||
|
xi_set_clip(win, &rct);
|
||||||
|
|
||||||
|
xi_draw_3d_rect(win, &rct, _obj->v.btn->down, 2, BTN_LIGHT_COLOR, BTN_BACK_COLOR, BTN_DARK_COLOR);
|
||||||
|
|
||||||
xi_inflate_rect(&rct, -3);
|
xi_inflate_rect(&rct, -3);
|
||||||
xi_set_clip(win, &rct);
|
xi_set_clip(win, &rct);
|
||||||
|
|
||||||
/*if (CAMPI_SCAVATI)
|
|
||||||
xi_draw_shaded_rect(win, &rct, _obj->v.btn->down, 2, BTN_LIGHT_COLOR, BTN_BACK_COLOR, BTN_DARK_COLOR);
|
|
||||||
else*/
|
|
||||||
xi_draw_3d_rect(win, &rct, _obj->v.btn->down, 2, BTN_LIGHT_COLOR, BTN_BACK_COLOR, BTN_DARK_COLOR);
|
|
||||||
|
|
||||||
const int bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up;
|
const int bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up;
|
||||||
if (bmp > 0)
|
if (bmp > 0)
|
||||||
{
|
{
|
||||||
@ -1891,6 +1890,7 @@ void TPushbutton_control::update()
|
|||||||
xvt_rect_offset(&dst, 2, 2);
|
xvt_rect_offset(&dst, 2, 2);
|
||||||
i.draw((WINDOW)win, dst);
|
i.draw((WINDOW)win, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
xi_set_clip(win, NULL);
|
xi_set_clip(win, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -945,6 +945,8 @@ bool TForm_subsection::print_body(sec_print_mode showfields)
|
|||||||
bool again=TRUE;
|
bool again=TRUE;
|
||||||
while (again && group_expr==_section->eval_expr(*_condexpr,_file_id).as_string())
|
while (again && group_expr==_section->eval_expr(*_condexpr,_file_id).as_string())
|
||||||
{
|
{
|
||||||
|
if (printer().frozen())
|
||||||
|
break;
|
||||||
form().match_result(_file_id);
|
form().match_result(_file_id);
|
||||||
if (!_bigskip || i==0)
|
if (!_bigskip || i==0)
|
||||||
{
|
{
|
||||||
@ -3702,9 +3704,8 @@ bool TForm::print(
|
|||||||
if ((_char_to_pos != '\0' || ((_ipx +_ipy+_fpx) != 0)) && // Se i parametri di posizionamento sono settati e
|
if ((_char_to_pos != '\0' || ((_ipx +_ipy+_fpx) != 0)) && // Se i parametri di posizionamento sono settati e
|
||||||
(_x != 0 || _y != 0)) // cosi' pure gli offset genera un errore.
|
(_x != 0 || _y != 0)) // cosi' pure gli offset genera un errore.
|
||||||
{
|
{
|
||||||
error_box(TR("Non e' possibile settare contemporaneamente gli offset"
|
return error_box(TR("Non e' possibile settare contemporaneamente gli offset"
|
||||||
" e i parametri di posizionamento del modulo."));
|
" e i parametri di posizionamento del modulo."));
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
TPrinter& pr = printer();
|
TPrinter& pr = printer();
|
||||||
if (_frompage) pr.set_from_page(_frompage);
|
if (_frompage) pr.set_from_page(_frompage);
|
||||||
|
@ -3410,28 +3410,37 @@ int TRectype::compare_key(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
HIDDEN bool fld_empty(const char* s, int len, bool number)
|
HIDDEN bool fld_empty(const char* s, int len, bool /* number */)
|
||||||
{
|
{
|
||||||
if (s && *s)
|
if (s && *s && len > 0)
|
||||||
{
|
{
|
||||||
for (; len; s++, len--)
|
for (; len; s++, len--) if (*s != ' ')
|
||||||
if (*s != ' ') return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HIDDEN int fld_cmp(const char* a, const char* b, int len, bool number)
|
HIDDEN int fld_cmp(const char* a, const char* b, int len, bool number)
|
||||||
{
|
{
|
||||||
int i;
|
int res = memcmp(a, b, len);
|
||||||
for (i = 0; i < len && *a == *b; b++, a++, i++);
|
if (res == 0)
|
||||||
if (i == len) return 0;
|
return res;
|
||||||
int res = *a - *b;
|
|
||||||
|
int i = 0;
|
||||||
|
if (number) // Aggiunta del 11-02-2014: ignoro spazi e zeri iniziali dei numeri
|
||||||
|
for (; i < len && (*a==' ' || *a=='0') && (*b==' ' || *b=='0'); b++, a++, i++);
|
||||||
|
|
||||||
|
for (; i < len && *a == *b; b++, a++, i++);
|
||||||
|
if (i == len)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
res = *a - *b;
|
||||||
if (number)
|
if (number)
|
||||||
{
|
{
|
||||||
b -= i;
|
b -= i;
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fld_empty(b, len - i, number) ? 0 : res;
|
return fld_empty(b, len - i, number) ? 0 : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3615,7 +3624,7 @@ word TRectype::get_word(const char* fieldname) const
|
|||||||
|
|
||||||
real TRectype::get_real(const char* fieldname) const
|
real TRectype::get_real(const char* fieldname) const
|
||||||
{
|
{
|
||||||
real r(get_str(fieldname));
|
const real r(get_str(fieldname));
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,7 +1200,8 @@ bool TPrint_application::print_one (
|
|||||||
TPrinter& prn = printer();
|
TPrinter& prn = printer();
|
||||||
|
|
||||||
if ((_prind && _prind->iscancelled()) || prn.frozen())
|
if ((_prind && _prind->iscancelled()) || prn.frozen())
|
||||||
if (_cancelled = cancel_hook()) return FALSE;
|
if (_cancelled = cancel_hook())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!_print_defined)
|
if (!_print_defined)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1,382 +1,422 @@
|
|||||||
#include "xvt.h"
|
#include "xvt.h"
|
||||||
#include "xinclude.h"
|
#include "xinclude.h"
|
||||||
|
|
||||||
#include <colors.h>
|
#include <colors.h>
|
||||||
#include <diction.h>
|
#include <diction.h>
|
||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
#include <controls.h>
|
#include <controls.h>
|
||||||
#include <reprint.h>
|
#include <reprint.h>
|
||||||
#include <urldefid.h>
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
int TIndwin::_indwin_count = 0;
|
// TIndwin
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
word TIndwin::measure_text(TToken_string& s, word& maxlen) const
|
|
||||||
{
|
int TIndwin::_indwin_count = 0;
|
||||||
word lines = 0;
|
|
||||||
FOR_EACH_TOKEN(s, t)
|
word TIndwin::measure_text(TToken_string& s, word& maxlen) const
|
||||||
{
|
{
|
||||||
const word l = strlen(t);
|
word lines = 0;
|
||||||
if (l > maxlen) maxlen = l;
|
FOR_EACH_TOKEN(s, t)
|
||||||
lines++;
|
{
|
||||||
}
|
const word l = strlen(t);
|
||||||
return lines;
|
if (l > maxlen) maxlen = l;
|
||||||
}
|
lines++;
|
||||||
|
}
|
||||||
// Certified 70%
|
return lines;
|
||||||
TIndwin::TIndwin(long tot, const char* txt, bool cancel, bool bar, int div)
|
}
|
||||||
: _gauge(NULL_WIN), _can_cancel(cancel), _bar_top(0),
|
|
||||||
_flags(0x0), _max(tot), _status(0L)
|
// Certified 70%
|
||||||
{
|
TIndwin::TIndwin(long tot, const char* txt, bool cancel, bool bar, int div)
|
||||||
TToken_string testo(txt, '\n');
|
: _gauge(NULL_WIN), _can_cancel(cancel), _bar_top(0),
|
||||||
word maxlen = div;
|
_flags(0x0), _max(tot), _status(0L)
|
||||||
const word lines = measure_text(testo, maxlen);
|
{
|
||||||
|
TToken_string testo(txt, '\n');
|
||||||
const int hor = min(maxlen+3, 78);
|
word maxlen = div;
|
||||||
const int ver = lines+3 + (bar ? 2 : 0);
|
const word lines = measure_text(testo, maxlen);
|
||||||
const int y = _indwin_count == 0 ? 3 : 12;
|
|
||||||
|
const int hor = min(maxlen+3, 78);
|
||||||
long flags = WSF_INVISIBLE;
|
const int ver = lines+3 + (bar ? 2 : 0);
|
||||||
if (_can_cancel)
|
const int y = _indwin_count == 0 ? 3 : 12;
|
||||||
flags |= WSF_CLOSE;
|
|
||||||
create(-1, y, hor, ver, TR("Elaborazione in corso"), flags, WD_MODAL);
|
long flags = WSF_INVISIBLE;
|
||||||
attach_interface(win(), MASK_BACK_COLOR); // Mette eventuale texture
|
if (_can_cancel)
|
||||||
|
flags |= WSF_CLOSE;
|
||||||
_bar_top = (lines+1)*ROWY;
|
create(-1, y, hor, ver, TR("Elaborazione in corso"), flags, WD_MODAL);
|
||||||
|
attach_interface(win(), MASK_BACK_COLOR); // Mette eventuale texture
|
||||||
set_text(testo);
|
|
||||||
|
_bar_top = (lines+1)*ROWY;
|
||||||
if (bar)
|
|
||||||
{
|
set_text(testo);
|
||||||
XVT_COLOR_COMPONENT xcc[4];
|
|
||||||
memset(xcc, 0, sizeof(xcc));
|
if (bar)
|
||||||
xcc[0].type = XVT_COLOR_BACKGROUND;
|
{
|
||||||
xcc[0].color = MASK_BACK_COLOR;
|
XVT_COLOR_COMPONENT xcc[4];
|
||||||
xcc[1].type = XVT_COLOR_BLEND;
|
memset(xcc, 0, sizeof(xcc));
|
||||||
xcc[1].color = BTN_LIGHT_COLOR;
|
xcc[0].type = XVT_COLOR_BACKGROUND;
|
||||||
xcc[2].type = XVT_COLOR_BORDER;
|
xcc[0].color = MASK_BACK_COLOR;
|
||||||
xcc[2].color = BTN_DARK_COLOR;
|
xcc[1].type = XVT_COLOR_BLEND;
|
||||||
|
xcc[1].color = BTN_LIGHT_COLOR;
|
||||||
WIN_DEF wd; memset(&wd, 0, sizeof(wd));
|
xcc[2].type = XVT_COLOR_BORDER;
|
||||||
wd.wtype = WC_HGAUGE;
|
xcc[2].color = BTN_DARK_COLOR;
|
||||||
get_bar_rct(wd.rct);
|
|
||||||
wd.ctlcolors = xcc;
|
WIN_DEF wd; memset(&wd, 0, sizeof(wd));
|
||||||
_gauge = xvt_ctl_create_def(&wd, win(), tot);
|
wd.wtype = WC_HGAUGE;
|
||||||
}
|
get_bar_rct(wd.rct);
|
||||||
|
wd.ctlcolors = xcc;
|
||||||
open_modal();
|
_gauge = xvt_ctl_create_def(&wd, win(), tot);
|
||||||
|
}
|
||||||
_indwin_count++;
|
|
||||||
setmax(tot);
|
open_modal();
|
||||||
}
|
|
||||||
|
_indwin_count++;
|
||||||
// @doc EXTERNAL
|
setmax(tot);
|
||||||
|
}
|
||||||
// @mfunc Setta il testo della finestra
|
|
||||||
void TIndwin::set_text(
|
// @doc EXTERNAL
|
||||||
const char* t) // @parm Testo della finestra
|
|
||||||
|
// @mfunc Setta il testo della finestra
|
||||||
// @comm Si puo' chiamare questa funzione per cambiare il testo, ma
|
void TIndwin::set_text(
|
||||||
// le dimensioni della finestra sono calcolate sul primo testo
|
const char* t) // @parm Testo della finestra
|
||||||
// passato, quindi occorre dimensionare correttamente il primo passato
|
|
||||||
// (es. inserire degli spazi) quando se ne prevede uno piu' lungo.
|
// @comm Si puo' chiamare questa funzione per cambiare il testo, ma
|
||||||
{
|
// le dimensioni della finestra sono calcolate sul primo testo
|
||||||
_text.destroy();
|
// passato, quindi occorre dimensionare correttamente il primo passato
|
||||||
TToken_string txt(t, '\n');
|
// (es. inserire degli spazi) quando se ne prevede uno piu' lungo.
|
||||||
FOR_EACH_TOKEN(txt, tok)
|
{
|
||||||
_text.add(tok);
|
_text.destroy();
|
||||||
|
TToken_string txt(t, '\n');
|
||||||
RCT r; get_txt_rct(r);
|
FOR_EACH_TOKEN(txt, tok)
|
||||||
xvt_dwin_invalidate_rect(win(), &r);
|
_text.add(tok);
|
||||||
}
|
|
||||||
|
RCT r; get_txt_rct(r);
|
||||||
void TIndwin::setmax(long m)
|
xvt_dwin_invalidate_rect(win(), &r);
|
||||||
{
|
}
|
||||||
_max = m <= 0 ? 1 : m;
|
|
||||||
if (_gauge)
|
void TIndwin::setmax(long m)
|
||||||
xvt_sbar_set_range(_gauge, HVGAUGE, 0, _max);
|
{
|
||||||
_start_time = clock();
|
_max = m <= 0 ? 1 : m;
|
||||||
}
|
if (_gauge)
|
||||||
|
xvt_sbar_set_range(_gauge, HVGAUGE, 0, _max);
|
||||||
TIndwin::~TIndwin()
|
_start_time = clock();
|
||||||
{
|
}
|
||||||
if (is_open())
|
|
||||||
close_modal();
|
TIndwin::~TIndwin()
|
||||||
_indwin_count--;
|
{
|
||||||
}
|
if (is_open())
|
||||||
|
close_modal();
|
||||||
bool TIndwin::can_be_closed() const
|
_indwin_count--;
|
||||||
{
|
}
|
||||||
const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED);
|
|
||||||
if (!ok) error_box(TR("Attendere la fine dell'operazione prima di chiudere l'applicazione"));
|
bool TIndwin::can_be_closed() const
|
||||||
return ok;
|
{
|
||||||
}
|
const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED);
|
||||||
|
if (!ok) error_box(TR("Attendere la fine dell'operazione prima di chiudere l'applicazione"));
|
||||||
KEY TIndwin::check_stop()
|
return ok;
|
||||||
{
|
}
|
||||||
KEY k = 0;
|
|
||||||
if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED))
|
KEY TIndwin::check_stop()
|
||||||
{
|
{
|
||||||
k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC;
|
KEY k = 0;
|
||||||
if (is_running())
|
if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED))
|
||||||
stop_run(k);
|
{
|
||||||
}
|
k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC;
|
||||||
return k;
|
if (is_running())
|
||||||
}
|
stop_run(k);
|
||||||
|
}
|
||||||
void TIndwin::get_bar_rct(RCT& r) const
|
return k;
|
||||||
{
|
}
|
||||||
xvt_vobj_get_client_rect(win(), &r);
|
|
||||||
r.left += CHARX;
|
void TIndwin::get_bar_rct(RCT& r) const
|
||||||
r.right -= CHARX;
|
{
|
||||||
r.top = _bar_top;
|
xvt_vobj_get_client_rect(win(), &r);
|
||||||
r.bottom = r.top + ROWY;
|
r.left += CHARX;
|
||||||
}
|
r.right -= CHARX;
|
||||||
|
r.top = _bar_top;
|
||||||
void TIndwin::get_txt_rct(RCT& r) const
|
r.bottom = r.top + ROWY;
|
||||||
{
|
}
|
||||||
get_bar_rct(r);
|
|
||||||
r.bottom = r.top - ROWY/2;
|
void TIndwin::get_txt_rct(RCT& r) const
|
||||||
r.top = ROWY/2;
|
{
|
||||||
}
|
get_bar_rct(r);
|
||||||
|
r.bottom = r.top - ROWY/2;
|
||||||
void TIndwin::sec2str(unsigned long ss, TString& str) const
|
r.top = ROWY/2;
|
||||||
{
|
}
|
||||||
const unsigned long hh = ss / 3600;
|
|
||||||
ss -= hh*3600;
|
void TIndwin::sec2str(unsigned long ss, TString& str) const
|
||||||
const unsigned long mm = ss / 60;
|
{
|
||||||
ss -= mm *60;
|
const unsigned long hh = ss / 3600;
|
||||||
str.format("%02ld:%02ld:%02ld", hh, mm, ss);
|
ss -= hh*3600;
|
||||||
}
|
const unsigned long mm = ss / 60;
|
||||||
|
ss -= mm *60;
|
||||||
void TIndwin::update_bar()
|
str.format("%02ld:%02ld:%02ld", hh, mm, ss);
|
||||||
{
|
}
|
||||||
if (_status >= _max)
|
|
||||||
{
|
void TIndwin::update_bar()
|
||||||
_status = _max;
|
{
|
||||||
_flags |= IND_FINISHED;
|
if (_status >= _max)
|
||||||
}
|
{
|
||||||
|
_status = _max;
|
||||||
// Percentuale raggiunta finora
|
_flags |= IND_FINISHED;
|
||||||
const double prc = (double)_status / (double)_max;
|
}
|
||||||
if (prc > 0)
|
|
||||||
{
|
// Percentuale raggiunta finora
|
||||||
const unsigned long elapsed_time = (clock() - _start_time)/CLOCKS_PER_SEC;
|
const double prc = (double)_status / (double)_max;
|
||||||
const unsigned long total_time = (unsigned long)(elapsed_time / prc + 0.5);
|
if (prc > 0)
|
||||||
TString16 str_ela, str_res, str_tot;
|
{
|
||||||
sec2str(elapsed_time, str_ela);
|
const unsigned long elapsed_time = (clock() - _start_time)/CLOCKS_PER_SEC;
|
||||||
sec2str(total_time - elapsed_time, str_res);
|
const unsigned long total_time = (unsigned long)(elapsed_time / prc + 0.5);
|
||||||
sec2str(total_time, str_tot);
|
TString16 str_ela, str_res, str_tot;
|
||||||
|
sec2str(elapsed_time, str_ela);
|
||||||
TString80 n;
|
sec2str(total_time - elapsed_time, str_res);
|
||||||
n.format("%d%% - %s %s - %s %s - %s %s", int(prc*100.0+0.5),
|
sec2str(total_time, str_tot);
|
||||||
TR("Trascorso"), str_ela.get_buffer(),
|
|
||||||
TR("Stimato"), str_tot.get_buffer(),
|
TString80 n;
|
||||||
TR("Residuo"), str_res.get_buffer()
|
n.format("%d%% - %s %s - %s %s - %s %s", int(prc*100.0+0.5),
|
||||||
);
|
TR("Trascorso"), str_ela.get_buffer(),
|
||||||
RCT b; get_bar_rct(b);
|
TR("Stimato"), str_tot.get_buffer(),
|
||||||
b.top = b.bottom+2; b.bottom = b.top + CHARY;
|
TR("Residuo"), str_res.get_buffer()
|
||||||
|
);
|
||||||
WINDOW w = win();
|
RCT b; get_bar_rct(b);
|
||||||
CBRUSH brush; brush.pat = PAT_SOLID; brush.color = MASK_BACK_COLOR;
|
b.top = b.bottom+2; b.bottom = b.top + CHARY;
|
||||||
xvt_dwin_set_cbrush(w, &brush);
|
|
||||||
xvt_dwin_set_std_cpen(w, TL_PEN_HOLLOW);
|
WINDOW w = win();
|
||||||
xvt_dwin_draw_rect(w, &b);
|
CBRUSH brush; brush.pat = PAT_SOLID; brush.color = MASK_BACK_COLOR;
|
||||||
xvt_dwin_set_clip(w, NULL);
|
xvt_dwin_set_cbrush(w, &brush);
|
||||||
set_color(PROMPT_COLOR, MASK_BACK_COLOR);
|
xvt_dwin_set_std_cpen(w, TL_PEN_HOLLOW);
|
||||||
set_opaque_text(TRUE);
|
xvt_dwin_draw_rect(w, &b);
|
||||||
set_font();
|
xvt_dwin_set_clip(w, NULL);
|
||||||
xvt_dwin_draw_text(w, b.left, b.bottom-1, n, -1);
|
set_color(PROMPT_COLOR, MASK_BACK_COLOR);
|
||||||
}
|
set_opaque_text(TRUE);
|
||||||
check_stop();
|
set_font();
|
||||||
}
|
xvt_dwin_draw_text(w, b.left, b.bottom-1, n, -1);
|
||||||
|
}
|
||||||
void TIndwin::update_txt()
|
check_stop();
|
||||||
{
|
}
|
||||||
RCT r; get_txt_rct(r);
|
|
||||||
|
void TIndwin::update_txt()
|
||||||
WINDOW w = win();
|
{
|
||||||
CBRUSH brush; brush.pat = PAT_SOLID; brush.color = MASK_BACK_COLOR;
|
RCT r; get_txt_rct(r);
|
||||||
xvt_dwin_set_cbrush(w, &brush);
|
|
||||||
xvt_dwin_set_std_cpen(w, TL_PEN_HOLLOW);
|
WINDOW w = win();
|
||||||
xvt_dwin_draw_rect(w, &r);
|
CBRUSH brush; brush.pat = PAT_SOLID; brush.color = MASK_BACK_COLOR;
|
||||||
xvt_dwin_set_clip(w, NULL);
|
xvt_dwin_set_cbrush(w, &brush);
|
||||||
set_color(PROMPT_COLOR, MASK_BACK_COLOR);
|
xvt_dwin_set_std_cpen(w, TL_PEN_HOLLOW);
|
||||||
set_opaque_text(TRUE);
|
xvt_dwin_draw_rect(w, &r);
|
||||||
set_font();
|
xvt_dwin_set_clip(w, NULL);
|
||||||
advanced_draw_paragraph(w, _text, r, 'L', 'C', CHARY);
|
set_color(PROMPT_COLOR, MASK_BACK_COLOR);
|
||||||
}
|
set_opaque_text(TRUE);
|
||||||
|
set_font();
|
||||||
void TIndwin::update()
|
advanced_draw_paragraph(w, _text, r, 'L', 'C', CHARY);
|
||||||
{
|
}
|
||||||
//clear(MASK_BACK_COLOR); // Già fatto da xi_interface
|
|
||||||
|
void TIndwin::update()
|
||||||
if (_gauge != NULL_WIN)
|
{
|
||||||
update_bar();
|
//clear(MASK_BACK_COLOR); // Già fatto da xi_interface
|
||||||
|
|
||||||
if (!_text.empty())
|
if (_gauge != NULL_WIN)
|
||||||
update_txt();
|
update_bar();
|
||||||
}
|
|
||||||
|
if (!_text.empty())
|
||||||
bool TIndwin::setstatus(long l)
|
update_txt();
|
||||||
{
|
}
|
||||||
if (l < 0)
|
|
||||||
{
|
bool TIndwin::setstatus(long l)
|
||||||
NFCHECK("Negative progind status");
|
{
|
||||||
l = 0;
|
if (l < 0)
|
||||||
}
|
{
|
||||||
|
NFCHECK("Negative progind status");
|
||||||
_status = l > _max ? _max : l;
|
l = 0;
|
||||||
|
}
|
||||||
if (_can_cancel && !xvt_vobj_is_valid(win()))
|
|
||||||
{
|
_status = l > _max ? _max : l;
|
||||||
_gauge = NULL_WIN;
|
|
||||||
on_key(K_ESC);
|
if (_can_cancel && !xvt_vobj_is_valid(win()))
|
||||||
}
|
{
|
||||||
if (_gauge != NULL_WIN)
|
_gauge = NULL_WIN;
|
||||||
xvt_sbar_set_pos(_gauge, HVGAUGE, _status);
|
on_key(K_ESC);
|
||||||
|
}
|
||||||
return !iscancelled();
|
if (_gauge != NULL_WIN)
|
||||||
}
|
xvt_sbar_set_pos(_gauge, HVGAUGE, _status);
|
||||||
|
|
||||||
bool TIndwin::on_key(KEY k)
|
return !iscancelled();
|
||||||
{
|
}
|
||||||
if (k == K_ESC && _can_cancel)
|
|
||||||
{
|
bool TIndwin::on_key(KEY k)
|
||||||
_flags |= IND_CANCELLED;
|
{
|
||||||
check_stop();
|
if (k == K_ESC && _can_cancel)
|
||||||
}
|
{
|
||||||
return true; // Ignora tutti gli altri tasti, senza chiamare TWindow::on_key(k)
|
_flags |= IND_CANCELLED;
|
||||||
}
|
check_stop();
|
||||||
|
}
|
||||||
bool TIndwin::stop_run(KEY k)
|
return true; // Ignora tutti gli altri tasti, senza chiamare TWindow::on_key(k)
|
||||||
{
|
}
|
||||||
if (k == K_ESC)
|
|
||||||
{
|
bool TIndwin::stop_run(KEY k)
|
||||||
if (_can_cancel)
|
{
|
||||||
_flags |= IND_CANCELLED;
|
if (k == K_ESC)
|
||||||
else
|
{
|
||||||
return false;
|
if (_can_cancel)
|
||||||
}
|
_flags |= IND_CANCELLED;
|
||||||
return TWindow::stop_run(k);
|
else
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
return TWindow::stop_run(k);
|
||||||
// TProgind --------------------------------------------------------------
|
}
|
||||||
|
|
||||||
TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
|
|
||||||
: TIndwin(max, txt, cancel, bar, div), _next_update(0)
|
///////////////////////////////////////////////////////////
|
||||||
{}
|
// TProgind
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
bool TProgind::setstatus(long l)
|
|
||||||
{
|
TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
|
||||||
const bool ok = TIndwin::setstatus(l);
|
: TIndwin(max, txt, cancel, bar, div), _next_update(0)
|
||||||
const clock_t c = clock();
|
{}
|
||||||
if (ok && c > _next_update)
|
|
||||||
{
|
bool TProgind::setstatus(long l)
|
||||||
update();
|
{
|
||||||
do_events();
|
const bool ok = TIndwin::setstatus(l);
|
||||||
_next_update = c+CLOCKS_PER_SEC; // Prossimo aggiornamento tra un secondo
|
const clock_t c = clock();
|
||||||
}
|
if (ok && c > _next_update)
|
||||||
|
{
|
||||||
return ok;
|
update();
|
||||||
}
|
do_events();
|
||||||
|
_next_update = c+CLOCKS_PER_SEC; // Prossimo aggiornamento tra un secondo
|
||||||
// TTimerind ------------------------------------------------------------
|
}
|
||||||
|
|
||||||
long TTimerind::handler(WINDOW w, EVENT* e)
|
return ok;
|
||||||
{
|
}
|
||||||
switch(e->type)
|
|
||||||
{
|
// TTimerind ------------------------------------------------------------
|
||||||
case E_CREATE:
|
|
||||||
case E_UPDATE:
|
long TTimerind::handler(WINDOW w, EVENT* e)
|
||||||
if (_timer_id == 0L && _interval > 0)
|
{
|
||||||
_timer_id = xvt_timer_create(w, _interval);
|
switch(e->type)
|
||||||
break;
|
{
|
||||||
case E_TIMER:
|
case E_CREATE:
|
||||||
if (e->v.timer.id == _timer_id)
|
case E_UPDATE:
|
||||||
{
|
if (_timer_id == 0L && _interval > 0)
|
||||||
_status += _interval;
|
_timer_id = xvt_timer_create(w, _interval);
|
||||||
force_update();
|
break;
|
||||||
}
|
case E_TIMER:
|
||||||
break;
|
if (e->v.timer.id == _timer_id)
|
||||||
default:
|
{
|
||||||
break;
|
_status += _interval;
|
||||||
}
|
force_update();
|
||||||
return TIndwin::handler(w,e);
|
}
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
TTimerind::TTimerind(long msec, const char* txt, bool cancel, bool bar, int div, int i)
|
break;
|
||||||
: TIndwin(msec, txt, cancel, bar, div), _timer_id(0), _interval(i)
|
}
|
||||||
{ }
|
return TIndwin::handler(w,e);
|
||||||
|
}
|
||||||
TTimerind::~TTimerind()
|
|
||||||
{
|
TTimerind::TTimerind(long msec, const char* txt, bool cancel, bool bar, int div, int i)
|
||||||
if (_timer_id)
|
: TIndwin(msec, txt, cancel, bar, div), _timer_id(0), _interval(i)
|
||||||
xvt_timer_destroy(_timer_id);
|
{ }
|
||||||
}
|
|
||||||
|
TTimerind::~TTimerind()
|
||||||
// C-style binding
|
{
|
||||||
// uses static pointer for single instance of TIndwin
|
if (_timer_id)
|
||||||
|
xvt_timer_destroy(_timer_id);
|
||||||
static TIndwin* __indwin__p = NULL;
|
}
|
||||||
|
|
||||||
void progind_create(long m, const char* t, bool b, bool c, int n)
|
///////////////////////////////////////////////////////////
|
||||||
{
|
// TProgress_monitor
|
||||||
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
///////////////////////////////////////////////////////////
|
||||||
__indwin__p = new TProgind(m,t,b,c,n);
|
|
||||||
}
|
bool TProgress_monitor::set_status(long n)
|
||||||
|
{
|
||||||
bool progind_set_status(long l)
|
// Aggiunsto timer iniziale se necessario
|
||||||
{
|
if (_status <= 0 && n <= 0)
|
||||||
return ((TProgind*)__indwin__p)->setstatus(l);
|
_start = clock();
|
||||||
}
|
|
||||||
|
// Se sono passati 1 secondi e sono a meno di metà lavoro allora crea la TProgind
|
||||||
void progind_cancel()
|
if (_pi == NULL && n < _total/2 && (clock() - _start) >= CLOCKS_PER_SEC)
|
||||||
{
|
{
|
||||||
__indwin__p->cancel();
|
_pi = new TProgind(_total, _txt, _cancellable);
|
||||||
}
|
_pi->set_start_time(_start);
|
||||||
|
}
|
||||||
bool progind_iscancelled()
|
// Aggiorna la TProgind associata, sempre che esista
|
||||||
{
|
_status = min(n, _total);
|
||||||
return __indwin__p->iscancelled();
|
return _pi == NULL || _pi->setstatus(_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool progind_isfinished()
|
TProgress_monitor::TProgress_monitor(long items, const char* txt, bool cancancel)
|
||||||
{
|
: _total(items), _txt(txt), _status(0), _cancellable(cancancel), _pi(NULL), _start(clock())
|
||||||
return __indwin__p->isfinished();
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void progind_destroy()
|
TProgress_monitor::~TProgress_monitor()
|
||||||
{
|
{
|
||||||
delete __indwin__p;
|
// Distruggi la TProgind o la clessidra, a seconda del caso
|
||||||
__indwin__p = NULL;
|
if (_pi != NULL)
|
||||||
}
|
delete _pi;
|
||||||
|
}
|
||||||
void timerind_create(long l, const char* title, bool bar, bool cancel,
|
|
||||||
int divisions, int interval)
|
///////////////////////////////////////////////////////////
|
||||||
{
|
// C-style bindings
|
||||||
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
///////////////////////////////////////////////////////////
|
||||||
__indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval);
|
|
||||||
}
|
// uses static pointer for single instance of TIndwin
|
||||||
|
static TIndwin* __indwin__p = NULL;
|
||||||
void timerind_cancel()
|
|
||||||
{
|
void progind_create(long m, const char* t, bool b, bool c, int n)
|
||||||
__indwin__p->cancel();
|
{
|
||||||
}
|
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
||||||
|
__indwin__p = new TProgind(m,t,b,c,n);
|
||||||
bool timerind_iscancelled()
|
}
|
||||||
{
|
|
||||||
return __indwin__p->iscancelled();
|
bool progind_set_status(long l)
|
||||||
}
|
{
|
||||||
|
return ((TProgind*)__indwin__p)->setstatus(l);
|
||||||
bool timerind_isfinished()
|
}
|
||||||
{
|
|
||||||
return __indwin__p->isfinished();
|
void progind_cancel()
|
||||||
}
|
{
|
||||||
|
__indwin__p->cancel();
|
||||||
void timerind_destroy()
|
}
|
||||||
{
|
|
||||||
delete __indwin__p;
|
bool progind_iscancelled()
|
||||||
__indwin__p = NULL;
|
{
|
||||||
}
|
return __indwin__p->iscancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool progind_isfinished()
|
||||||
|
{
|
||||||
|
return __indwin__p->isfinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
void progind_destroy()
|
||||||
|
{
|
||||||
|
delete __indwin__p;
|
||||||
|
__indwin__p = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void timerind_create(long l, const char* title, bool bar, bool cancel,
|
||||||
|
int divisions, int interval)
|
||||||
|
{
|
||||||
|
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
||||||
|
__indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void timerind_cancel()
|
||||||
|
{
|
||||||
|
__indwin__p->cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool timerind_iscancelled()
|
||||||
|
{
|
||||||
|
return __indwin__p->iscancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool timerind_isfinished()
|
||||||
|
{
|
||||||
|
return __indwin__p->isfinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
void timerind_destroy()
|
||||||
|
{
|
||||||
|
delete __indwin__p;
|
||||||
|
__indwin__p = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,180 +1,209 @@
|
|||||||
#ifndef __PROGIND_H
|
#ifndef __PROGIND_H
|
||||||
#define __PROGIND_H
|
#define __PROGIND_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#ifndef __WINDOW_H
|
#ifndef __WINDOW_H
|
||||||
#include <window.h>
|
#include <window.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CONTROLS_H
|
#ifndef __CONTROLS_H
|
||||||
class TControl;
|
class TControl;
|
||||||
class TField_control;
|
class TField_control;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
|
|
||||||
// @class TIndwin | Classe base per la gestione delle finestre con le barre di attesa
|
// @class TIndwin | Classe base per la gestione delle finestre con le barre di attesa
|
||||||
//
|
//
|
||||||
// @base public | TWindow
|
// @base public | TWindow
|
||||||
class TIndwin : public TWindow
|
class TIndwin : public TWindow
|
||||||
// @author:(INTERNAL) Villa
|
// @author:(INTERNAL) Villa
|
||||||
{
|
{
|
||||||
// @access:(INTERNAL) Private Member
|
// @access:(INTERNAL) Private Member
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// @ccost:(INTERNAL) IND_CANCELLED | 0x01 | Controlla se e' stato premuto il tasto "Annulla"
|
// @ccost:(INTERNAL) IND_CANCELLED | 0x01 | Controlla se e' stato premuto il tasto "Annulla"
|
||||||
IND_CANCELLED = 0x01,
|
IND_CANCELLED = 0x01,
|
||||||
// @ccost:(INTERNAL) IND_FINISHED | 0x02 | Controlla se l'operazione e' terminata
|
// @ccost:(INTERNAL) IND_FINISHED | 0x02 | Controlla se l'operazione e' terminata
|
||||||
IND_FINISHED= 0x02 };
|
IND_FINISHED= 0x02 };
|
||||||
|
|
||||||
TString_array _text;
|
TString_array _text;
|
||||||
short _bar_top;
|
short _bar_top;
|
||||||
bool _can_cancel;
|
bool _can_cancel;
|
||||||
|
|
||||||
// @cmember:(INTERNAL) Movimento della barra e percentuale
|
// @cmember:(INTERNAL) Movimento della barra e percentuale
|
||||||
WINDOW _gauge;
|
WINDOW _gauge;
|
||||||
// @cmember:(INTERNAL) ora inizio elaborazione
|
// @cmember:(INTERNAL) ora inizio elaborazione
|
||||||
unsigned long _start_time;
|
clock_t _start_time;
|
||||||
|
|
||||||
// @cmember:(INTERNAL) Flag che indica quali operazioni sono state effettuate
|
// @cmember:(INTERNAL) Flag che indica quali operazioni sono state effettuate
|
||||||
byte _flags;
|
byte _flags;
|
||||||
|
|
||||||
static int _indwin_count;
|
static int _indwin_count;
|
||||||
|
|
||||||
// @access Protected Member
|
// @access Protected Member
|
||||||
protected:
|
protected:
|
||||||
// @cmember Massimo valore da ricercare
|
// @cmember Massimo valore da ricercare
|
||||||
long _max;
|
long _max;
|
||||||
// @cmember Stato corrente dell'esecuzione (settato dell'utente)
|
// @cmember Stato corrente dell'esecuzione (settato dell'utente)
|
||||||
long _status;
|
long _status;
|
||||||
// @cmember Ritorna il numero di linee necessarie per scrivere il testo nella finestra
|
// @cmember Ritorna il numero di linee necessarie per scrivere il testo nella finestra
|
||||||
word measure_text(TToken_string& t, word& len) const;
|
word measure_text(TToken_string& t, word& len) const;
|
||||||
|
|
||||||
// @cmember Calcola il rettangolo della barra di attesa
|
// @cmember Calcola il rettangolo della barra di attesa
|
||||||
virtual void get_bar_rct(RCT& r) const;
|
virtual void get_bar_rct(RCT& r) const;
|
||||||
// @cmember Calcola il rettangolo del testo
|
// @cmember Calcola il rettangolo del testo
|
||||||
virtual void get_txt_rct(RCT& r) const;
|
virtual void get_txt_rct(RCT& r) const;
|
||||||
|
|
||||||
// @cmember converte secondi in una stringa nel formato hh:mm:ss
|
// @cmember converte secondi in una stringa nel formato hh:mm:ss
|
||||||
void sec2str(unsigned long ss, TString& str) const;
|
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);
|
||||||
virtual bool stop_run(KEY k);
|
virtual bool stop_run(KEY k);
|
||||||
|
|
||||||
// @cmember Aggiorna la barra di attesa (chiama update_bar)
|
// @cmember Aggiorna la barra di attesa (chiama update_bar)
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
// @cmember Aggiorna la barra di attesa
|
// @cmember Aggiorna la barra di attesa
|
||||||
virtual void update_bar();
|
virtual void update_bar();
|
||||||
virtual void update_txt();
|
virtual void update_txt();
|
||||||
|
|
||||||
// @cmember Controlla se ha terminato la barra di attesa
|
// @cmember Controlla se ha terminato la barra di attesa
|
||||||
KEY check_stop();
|
KEY check_stop();
|
||||||
|
|
||||||
// @access Public Member
|
// @access Public Member
|
||||||
public:
|
public:
|
||||||
// @cmember Controlla se e' stato premuto il tasto "Annulla"
|
// @cmember Controlla se e' stato premuto il tasto "Annulla"
|
||||||
bool iscancelled() const { return (_flags & IND_CANCELLED) != 0; }
|
bool iscancelled() const { return (_flags & IND_CANCELLED) != 0; }
|
||||||
// @cmember Controlla se e' finito l'operazione
|
// @cmember Controlla se e' finito l'operazione
|
||||||
bool isfinished() const { return (_flags & IND_FINISHED) != 0; }
|
bool isfinished() const { return (_flags & IND_FINISHED) != 0; }
|
||||||
// @cmember Ritorna lo stato dell'operazione (quantita' dell'applicazione gia' fatta)
|
// @cmember Ritorna lo stato dell'operazione (quantita' dell'applicazione gia' fatta)
|
||||||
long status() const { return _status; }
|
long status() const { return _status; }
|
||||||
// @cmember Ferma l'operazione (chiude la finestra)
|
// @cmember Ferma l'operazione (chiude la finestra)
|
||||||
void cancel()
|
void cancel()
|
||||||
{ _flags |= IND_CANCELLED; do_events(); check_stop(); }
|
{ _flags |= IND_CANCELLED; do_events(); check_stop(); }
|
||||||
|
|
||||||
// @cmember Controlla se l'operazione puo' essere chiusa
|
// @cmember Controlla se l'operazione puo' essere chiusa
|
||||||
virtual bool can_be_closed() const;
|
virtual bool can_be_closed() const;
|
||||||
|
|
||||||
// @cmember Setta il testo della finestra
|
// @cmember Setta il testo della finestra
|
||||||
void set_text(const char* t);
|
void set_text(const char* t);
|
||||||
|
|
||||||
// @cmember Setta il valore massimo della barra d'attesa
|
// @cmember Setta il valore massimo della barra d'attesa
|
||||||
void setmax(long m);
|
void setmax(long m);
|
||||||
|
|
||||||
virtual bool setstatus(long l);
|
virtual bool setstatus(long l);
|
||||||
|
|
||||||
// @cmember Costruttore
|
// @cmember Forza il timer d'inizio (serve solo a TProgress_monitor)
|
||||||
TIndwin(long max, const char* txt, bool cancel = TRUE, bool bar = TRUE, int div = 60);
|
void set_start_time(unsigned long st) { _start_time = st; }
|
||||||
// @cmember Distruttore
|
|
||||||
virtual ~TIndwin();
|
// @cmember Costruttore
|
||||||
};
|
TIndwin(long max, const char* txt, bool cancel = TRUE, bool bar = TRUE, int div = 60);
|
||||||
|
// @cmember Distruttore
|
||||||
// @doc EXTERNAL
|
virtual ~TIndwin();
|
||||||
|
};
|
||||||
// @class TProgind | Classe per la gestione della barra di attesa di una applicazione
|
|
||||||
//
|
// @doc EXTERNAL
|
||||||
// @base public | TIndwin
|
|
||||||
class TProgind : public TIndwin
|
// @class TProgind | Classe per la gestione della barra di attesa di una applicazione
|
||||||
// @author:(INTERNAL) Villa
|
//
|
||||||
{
|
// @base public | TIndwin
|
||||||
clock_t _next_update;
|
class TProgind : public TIndwin
|
||||||
|
// @author:(INTERNAL) Villa
|
||||||
// @access Public Member
|
{
|
||||||
public:
|
clock_t _next_update;
|
||||||
// @cmember Setta lo stato della barra d'attesa
|
|
||||||
virtual bool setstatus(long l);
|
// @access Public Member
|
||||||
// @cmember Aggiorna la barra d'attesa aggiungendo l'incremento fatto dell'applicazione
|
public:
|
||||||
bool addstatus(long l)
|
// @cmember Setta lo stato della barra d'attesa
|
||||||
{ return setstatus(_status+l); }
|
virtual bool setstatus(long l);
|
||||||
// @cmember Costruttore
|
// @cmember Aggiorna la barra d'attesa aggiungendo l'incremento fatto dell'applicazione
|
||||||
TProgind(long max, const char* txt = NULL, bool cancel = TRUE, bool bar = TRUE, int div = 60);
|
bool addstatus(long l)
|
||||||
// @cmember Distruttore
|
{ return setstatus(_status+l); }
|
||||||
virtual ~TProgind()
|
// @cmember Costruttore
|
||||||
{}
|
TProgind(long max, const char* txt = NULL, bool cancel = TRUE, bool bar = TRUE, int div = 60);
|
||||||
};
|
// @cmember Distruttore
|
||||||
|
virtual ~TProgind()
|
||||||
// @doc EXTERNAL
|
{}
|
||||||
|
};
|
||||||
// @class TTimerind | Classe per la definizione di una barra d'attesa gestita
|
|
||||||
// dal tempo e non dallo stato dell'applicazione
|
// @doc EXTERNAL
|
||||||
//
|
|
||||||
// @base public | TIndwin
|
// @class TTimerind | Classe per la definizione di una barra d'attesa gestita
|
||||||
class TTimerind : public TIndwin
|
// dal tempo e non dallo stato dell'applicazione
|
||||||
// @author:(INTERNAL) Villa
|
//
|
||||||
{
|
// @base public | TIndwin
|
||||||
// @access:(INTERNAL) Private Member
|
class TTimerind : public TIndwin
|
||||||
|
// @author:(INTERNAL) Villa
|
||||||
// @cmember:(INTERNAL) Intervallo di tempo
|
{
|
||||||
int _interval;
|
// @access:(INTERNAL) Private Member
|
||||||
// @cmember:(INTERNAL) Indice di tempo
|
|
||||||
long _timer_id;
|
// @cmember:(INTERNAL) Intervallo di tempo
|
||||||
|
int _interval;
|
||||||
// @access Protected Member
|
// @cmember:(INTERNAL) Indice di tempo
|
||||||
protected:
|
long _timer_id;
|
||||||
// @cmember Gestisce gli eventi della finestra
|
|
||||||
virtual long handler(WINDOW w, EVENT* e);
|
// @access Protected Member
|
||||||
|
protected:
|
||||||
// @access Public Member
|
// @cmember Gestisce gli eventi della finestra
|
||||||
public:
|
virtual long handler(WINDOW w, EVENT* e);
|
||||||
// @cmember Costruttore
|
|
||||||
TTimerind(long msec, const char* txt = NULL, bool cancel = TRUE, bool bar = TRUE, int div = 10, int interval = 1000);
|
// @access Public Member
|
||||||
// @cmember Distruttore
|
public:
|
||||||
virtual ~TTimerind();
|
// @cmember Costruttore
|
||||||
};
|
TTimerind(long msec, const char* txt = NULL, bool cancel = TRUE, bool bar = TRUE, int div = 10, int interval = 1000);
|
||||||
|
// @cmember Distruttore
|
||||||
#endif
|
virtual ~TTimerind();
|
||||||
|
};
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
// @doc EXTERNAL
|
||||||
#endif
|
|
||||||
// Non commentate perche' destinate a sparire
|
// @class TProgress_monitor | Classe per gestire intelligentemente clessidra o barra di attesa
|
||||||
void progind_create(long, const char*, bool, bool, int);
|
//
|
||||||
bool progind_set_status(long s);
|
// @base public | TObject
|
||||||
void progind_cancel();
|
class TProgress_monitor : public TObject
|
||||||
bool progind_iscancelled();
|
{
|
||||||
bool progind_isfinished();
|
long _total, _status;
|
||||||
void progind_destroy();
|
TString _txt;
|
||||||
void timerind_create(long, const char*, bool, bool, int, int);
|
bool _cancellable;
|
||||||
void timerind_cancel();
|
TProgind* _pi;
|
||||||
bool timerind_iscancelled();
|
clock_t _start;
|
||||||
bool timerind_isfinished();
|
|
||||||
void timerind_destroy();
|
public:
|
||||||
|
virtual bool set_status(long n);
|
||||||
#ifdef __cplusplus
|
bool add_status(long i = 1) { return set_status(_status+i); }
|
||||||
}
|
|
||||||
#endif
|
// deprecated TProgind compatibility methods
|
||||||
|
bool setstatus(long n) { return set_status(n); }
|
||||||
#endif /* __PROGIND_H */
|
bool addstatus(long n) { return add_status(n); }
|
||||||
|
|
||||||
|
TProgress_monitor(long items, const char* txt, bool cancellable = true);
|
||||||
|
~TProgress_monitor();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
// Non commentate perche' destinate a sparire
|
||||||
|
void progind_create(long, const char*, bool, bool, int);
|
||||||
|
bool progind_set_status(long s);
|
||||||
|
void progind_cancel();
|
||||||
|
bool progind_iscancelled();
|
||||||
|
bool progind_isfinished();
|
||||||
|
void progind_destroy();
|
||||||
|
void timerind_create(long, const char*, bool, bool, int, int);
|
||||||
|
void timerind_cancel();
|
||||||
|
bool timerind_iscancelled();
|
||||||
|
bool timerind_isfinished();
|
||||||
|
void timerind_destroy();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __PROGIND_H */
|
||||||
|
@ -1696,14 +1696,19 @@ real TGeneric_distrib::get ()
|
|||||||
{
|
{
|
||||||
_ready = true;
|
_ready = true;
|
||||||
CHECK (_current < _slices.items(), "TGeneric_distrib: too many gets");
|
CHECK (_current < _slices.items(), "TGeneric_distrib: too many gets");
|
||||||
real & currslice = (real &) _slices[_current++];
|
const real & currslice = (real &) _slices[_current++];
|
||||||
real r = currslice;
|
real r = currslice;
|
||||||
if (_tot != _totslices)
|
if (_tot != _totslices)
|
||||||
{
|
{
|
||||||
if (_tot < 1E9 && currslice < 1E9)
|
if (currslice != _totslices) // Caso normale
|
||||||
r = (_tot * currslice) / _totslices;
|
{
|
||||||
|
if (abs(_tot) < 1E9 && abs(currslice) < 1E9)
|
||||||
|
r = _tot * currslice / _totslices;
|
||||||
|
else
|
||||||
|
r *= (_tot / _totslices);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
r *= (_tot / _totslices);
|
r = _tot; // Caso limite che risolve (_totslices==0) && (_tot != 0)
|
||||||
}
|
}
|
||||||
r.round (_decs);
|
r.round (_decs);
|
||||||
_tot -= r;
|
_tot -= r;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <dongle.h>
|
#include <dongle.h>
|
||||||
#include <modaut.h>
|
#include <modaut.h>
|
||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
|
#include <recarray.h>
|
||||||
#include <recset.h>
|
#include <recset.h>
|
||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
@ -359,7 +360,7 @@ bool TRecordset::save_as_dbf(const char* table, int mode)
|
|||||||
char dirname[_MAX_PATH];
|
char dirname[_MAX_PATH];
|
||||||
char name[_MAX_FNAME];
|
char name[_MAX_FNAME];
|
||||||
char ext[_MAX_EXT];
|
char ext[_MAX_EXT];
|
||||||
xvt_fsys_parse_pathname (table, volume, dirname, name, ext, NULL);
|
xvt_fsys_parse_pathname(table, volume, dirname, name, ext, NULL);
|
||||||
|
|
||||||
const int logicnum = table2logic(name);
|
const int logicnum = table2logic(name);
|
||||||
|
|
||||||
@ -384,20 +385,18 @@ bool TRecordset::save_as_dbf(const char* table, int mode)
|
|||||||
mode = 0x1;
|
mode = 0x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TLocalisamfile* pisam = NULL;
|
TBaseisamfile* pisam = NULL;
|
||||||
if (logicnum >= LF_USER)
|
if (logicnum >= LF_USER)
|
||||||
{
|
{
|
||||||
if (*dirname)
|
if (*dirname)
|
||||||
pisam = new TIsamtempfile(logicnum, table);
|
pisam = new TIsamtempfile(logicnum, table);
|
||||||
else
|
else
|
||||||
pisam = new TLocalisamfile(logicnum);
|
pisam = new TFast_isamfile(logicnum);
|
||||||
}
|
}
|
||||||
if (pisam == NULL)
|
if (pisam == NULL)
|
||||||
return error_box("Impossibile creare il file %s", table);
|
return error_box("Impossibile creare il file %s", table);
|
||||||
|
|
||||||
TLocalisamfile& isam = *pisam;
|
TBaseisamfile& isam = *pisam;
|
||||||
|
|
||||||
TProgind pi(items(), TR("Esportazione in corso..."));
|
|
||||||
TRectype& rec = isam.curr();
|
TRectype& rec = isam.curr();
|
||||||
|
|
||||||
TString_array names;
|
TString_array names;
|
||||||
@ -415,10 +414,12 @@ bool TRecordset::save_as_dbf(const char* table, int mode)
|
|||||||
names.add(EMPTY_STRING);
|
names.add(EMPTY_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TProgress_monitor pi(items(), TR("Esportazione in corso..."), true);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
for (bool go = move_first(); go; go = move_next())
|
for (bool go = move_first(); go; go = move_next())
|
||||||
{
|
{
|
||||||
pi.addstatus(1);
|
if (!pi.add_status())
|
||||||
|
break;
|
||||||
rec.zero();
|
rec.zero();
|
||||||
FOR_EACH_ARRAY_ROW(names, j, name) if (name->not_empty())
|
FOR_EACH_ARRAY_ROW(names, j, name) if (name->not_empty())
|
||||||
rec.put(*name, get(j).as_string());
|
rec.put(*name, get(j).as_string());
|
||||||
@ -985,7 +986,7 @@ const TString& TCursor_parser::line()
|
|||||||
{
|
{
|
||||||
if (_pushed.not_empty())
|
if (_pushed.not_empty())
|
||||||
return pop();
|
return pop();
|
||||||
char* buff = _token.get_buffer(256);
|
char* buff = _token.get_buffer(512);
|
||||||
_instr.getline(buff, _token.size());
|
_instr.getline(buff, _token.size());
|
||||||
return _token;
|
return _token;
|
||||||
}
|
}
|
||||||
|
@ -837,7 +837,7 @@ int TRelation_application::delete_mode()
|
|||||||
keep_running = FALSE;
|
keep_running = FALSE;
|
||||||
if (tasto == K_DEL && sht.checked() == 0)
|
if (tasto == K_DEL && sht.checked() == 0)
|
||||||
{
|
{
|
||||||
error_box(TR("Non e' stato selezionato nessun elemento"));
|
error_box(TR("Non è stato selezionato nessun elemento"));
|
||||||
sht.select(0);
|
sht.select(0);
|
||||||
keep_running = TRUE;
|
keep_running = TRUE;
|
||||||
}
|
}
|
||||||
@ -1216,6 +1216,9 @@ int TRelation_application::rewrite(const TMask& m)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* TRelation_application::record_description(const TRelation& r) const
|
||||||
|
{ return r.file().description(); }
|
||||||
|
|
||||||
// @doc INTERNAL
|
// @doc INTERNAL
|
||||||
|
|
||||||
// @mfunc Cancella il record corrente
|
// @mfunc Cancella il record corrente
|
||||||
@ -1230,10 +1233,10 @@ bool TRelation_application::relation_remove()
|
|||||||
TRelation& r = *get_relation();
|
TRelation& r = *get_relation();
|
||||||
r.restore_status();
|
r.restore_status();
|
||||||
if (protected_record(r))
|
if (protected_record(r))
|
||||||
return warning_box(TR("Elemento non eliminabile"));
|
return warning_box(FR("%s non eliminabile"), record_description(r));
|
||||||
|
|
||||||
if (_curr_transaction == TRANSACTION_DELETE ||
|
if (_curr_transaction == TRANSACTION_DELETE ||
|
||||||
delete_box(FR("Confermare l'eliminazione del record %s"), r.file().description()))
|
delete_box(FR("Confermare eliminazione %s"), record_description(r)))
|
||||||
{
|
{
|
||||||
r.restore_status();
|
r.restore_status();
|
||||||
const bool ok = remove();
|
const bool ok = remove();
|
||||||
|
@ -241,6 +241,8 @@ protected:
|
|||||||
virtual void sheet2ini(TSheet_field &sheet,TConfig& ini);
|
virtual void sheet2ini(TSheet_field &sheet,TConfig& ini);
|
||||||
virtual void ini2mask(TConfig& ini, TMask& m, bool query);
|
virtual void ini2mask(TConfig& ini, TMask& m, bool query);
|
||||||
virtual bool mask2mail(const TMask& m);
|
virtual bool mask2mail(const TMask& m);
|
||||||
|
// @cmember Breve descrizione del tipo documento corrente
|
||||||
|
virtual const char* record_description(const TRelation& r) const;
|
||||||
|
|
||||||
// @access Public Member
|
// @access Public Member
|
||||||
public:
|
public:
|
||||||
|
@ -2776,10 +2776,10 @@ void TReport::report2mask(TMask & m) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TVariant & string2var(TVariant & v, const TFieldref * r, const TString & val)
|
TVariant& string2var(TVariant& v, const TFieldref& r, const TString& val)
|
||||||
{
|
{
|
||||||
const int from = r->from();
|
const int from = r.from();
|
||||||
int to = r->to();
|
int to = r.to();
|
||||||
|
|
||||||
if (from > 0 || to > 0)
|
if (from > 0 || to > 0)
|
||||||
{
|
{
|
||||||
@ -2838,7 +2838,7 @@ void TReport::mask2report(const TMask & m)
|
|||||||
get_usr_val(name, var);
|
get_usr_val(name, var);
|
||||||
if (val.empty())
|
if (val.empty())
|
||||||
val = is_final ? MAX_STRING : "";
|
val = is_final ? MAX_STRING : "";
|
||||||
string2var(var, ref, val);
|
string2var(var, *ref, val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -612,7 +612,6 @@ public:
|
|||||||
virtual bool set_recordset(const TString& sql);
|
virtual bool set_recordset(const TString& sql);
|
||||||
virtual bool set_recordset(TRecordset* sql);
|
virtual bool set_recordset(TRecordset* sql);
|
||||||
virtual TRecordset* recordset() const { return _recordset; }
|
virtual TRecordset* recordset() const { return _recordset; }
|
||||||
bool evaluate_atom(const char* atom, TVariant& var);
|
|
||||||
bool evaluate(const char* expr, TVariant& var, TFieldtypes force_type);
|
bool evaluate(const char* expr, TVariant& var, TFieldtypes force_type);
|
||||||
|
|
||||||
const TString& prescript() const;
|
const TString& prescript() const;
|
||||||
|
@ -2737,20 +2737,34 @@ void TReport_book::add_doc(const TString& name)
|
|||||||
TReport* eminem = new TReport;
|
TReport* eminem = new TReport;
|
||||||
if (eminem->load(name))
|
if (eminem->load(name))
|
||||||
{
|
{
|
||||||
TReport* rep = _report; // Salvo variabile globale
|
TFilename msk = _report->filename().name();
|
||||||
|
msk.ext("msk");
|
||||||
if (rep->use_mask())
|
if (_report->use_mask() && msk.custom_path())
|
||||||
{
|
{
|
||||||
TFilename msk = rep->filename().name();
|
TMask m(msk);
|
||||||
msk.ext("msk");
|
_report->report2mask(m);
|
||||||
if (msk.custom_path())
|
eminem->mask2report(m);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TRecordset* mainset = _report->recordset();
|
||||||
|
TRecordset* recset = eminem->recordset();
|
||||||
|
if (mainset && recset)
|
||||||
{
|
{
|
||||||
TMask m(msk);
|
const TString_array& vars = mainset->variables();
|
||||||
rep->report2mask(m);
|
FOR_EACH_ARRAY_ROW(vars, i, name)
|
||||||
eminem->mask2report(m);
|
recset->set_var(*name, mainset->get_var(*name));
|
||||||
|
if (main_app().name().starts_with("ve1"))
|
||||||
|
{
|
||||||
|
recset->set_var("#PROVV", mainset->get("PROVV"));
|
||||||
|
recset->set_var("#ANNO", mainset->get("ANNO"));
|
||||||
|
recset->set_var("#CODNUM", mainset->get("CODNUM"));
|
||||||
|
recset->set_var("#NDOC", mainset->get("NDOC"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TReport* rep = _report; // Salvo variabile globale
|
||||||
add(*eminem, true);
|
add(*eminem, true);
|
||||||
_report = rep; // Ripristino variabile globale
|
_report = rep; // Ripristino variabile globale
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ TString & TVariable_field::get() const
|
|||||||
{
|
{
|
||||||
if (_in_get)
|
if (_in_get)
|
||||||
fatal_box("Recursive get in %s", (const char *) _name);
|
fatal_box("Recursive get in %s", (const char *) _name);
|
||||||
((TVariable_field *) this)->_in_get = TRUE;
|
((TVariable_field *) this)->_in_get = true;
|
||||||
if (_e)
|
if (_e)
|
||||||
{
|
{
|
||||||
CHECK(_rec, "NULL Record pointer with an expression");
|
CHECK(_rec, "NULL Record pointer with an expression");
|
||||||
@ -80,8 +80,8 @@ TString & TVariable_field::get() const
|
|||||||
CHECK(_rec, "NULL Record pointer with a function");
|
CHECK(_rec, "NULL Record pointer with a function");
|
||||||
v = _getfunc(*_rec);
|
v = _getfunc(*_rec);
|
||||||
}
|
}
|
||||||
((TVariable_field *) this)->_in_get = FALSE;
|
((TVariable_field*) this)->_in_get = false;
|
||||||
((TVariable_field *) this)->set_clean();
|
((TVariable_field*) this)->set_clean();
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user