Patch level : 4.0

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Corretta e migliorata gestione campi read only


git-svn-id: svn://10.65.10.50/trunk@15195 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2007-04-06 14:46:40 +00:00
parent af7b085f90
commit 238527b5ba
9 changed files with 223 additions and 229 deletions

View File

@ -163,10 +163,10 @@ HIDDEN void paint_background(WINDOW win)
if (ADVANCED_GRAPHICS) if (ADVANCED_GRAPHICS)
{ // Disegna ombra { // Disegna ombra
const int k = max(BIGY/24, 1); const int k = max(BIGY/24, 1);
xvt_dwin_set_fore_color(win, DISABLED_COLOR); xvt_dwin_set_fore_color(win, MASK_LIGHT_COLOR);
xvt_dwin_draw_text(win, x+k, y+k, t, -1); xvt_dwin_draw_text(win, x+k, y+k, t, -1);
} }
xvt_dwin_set_fore_color(win, NORMAL_COLOR); xvt_dwin_set_fore_color(win, MASK_DARK_COLOR);
xvt_dwin_draw_text(win, x, y, t, -1); xvt_dwin_draw_text(win, x, y, t, -1);
xvtil_set_font(win, NULL, XVT_FS_NONE); xvtil_set_font(win, NULL, XVT_FS_NONE);

View File

@ -1002,6 +1002,7 @@ unsigned long TControl::flags2attr(const char* flags) const
case 'C': attrib |= XI_ATR_HCENTER; break; case 'C': attrib |= XI_ATR_HCENTER; break;
case 'D': attrib &= ~XI_ATR_ENABLED; break; case 'D': attrib &= ~XI_ATR_ENABLED; break;
case 'H': attrib &= ~XI_ATR_VISIBLE; break; case 'H': attrib &= ~XI_ATR_VISIBLE; break;
case 'L': attrib |= XI_ATR_READONLY; break;
case 'R': attrib |= XI_ATR_RJUST; break; case 'R': attrib |= XI_ATR_RJUST; break;
default : break; default : break;
} }
@ -1348,8 +1349,8 @@ void TField_control::create(WINDOW win, short cid,
short left, short top, short width, short height, short maxlen, short left, short top, short width, short height, short maxlen,
const char* flags, const char* text, bool button) const char* flags, const char* text, bool button)
{ {
CHECK(!in_create, "Nested control creation");
in_create = true; in_create = true;
const short fcid = cid > 0 ? cid + 2000 : cid - 2000; const short fcid = cid > 0 ? cid + 2000 : cid - 2000;
XI_OBJ_DEF* frm_def = xi_add_form_def(NULL, fcid, fcid); XI_OBJ_DEF* frm_def = xi_add_form_def(NULL, fcid, fcid);
frm_def->app_data = (long)this; frm_def->app_data = (long)this;
@ -2242,7 +2243,7 @@ bool TDropDownList::select(int i, bool force)
{ {
if (_open) xi_set_text(_obj, ""); // Altrimenti a volte ridisegna male! if (_open) xi_set_text(_obj, ""); // Altrimenti a volte ridisegna male!
xi_set_text(_obj, (char*)_values.get(i)); xi_set_text(_obj, (char*)_values.get(i));
TListbox_control* listbox = (TListbox_control *)xi_get_app_data(_obj); TListbox_control* listbox = (TListbox_control*)xi_get_app_data(_obj);
listbox->notify_key(K_SPACE); listbox->notify_key(K_SPACE);
} }
else else

View File

@ -1,11 +1,8 @@
#include <defmask.h>
#include <form.h> #include <form.h>
#include <msksheet.h> #include <msksheet.h>
#include <printer.h> #include <printer.h>
#ifndef __DEFMASK_H
#include <defmask.h>
#endif
#include "../ba/bafrm.h" #include "../ba/bafrm.h"
// per lo sheet di edit campi // per lo sheet di edit campi
@ -628,8 +625,8 @@ void TPrint_section::print_on(TRectype& prof)
typedef struct typedef struct
{ {
char name_1[80]; // Fontname old TString80 name_1; // Fontname old
char name_2[80]; // Fontname new TString80 name_2; // Fontname new
int size_1; // size (height) of old font int size_1; // size (height) of old font
int size_2; // size (height) of new font int size_2; // size (height) of new font
real ratio; // ratio (width_old_font/width_new_font) real ratio; // ratio (width_old_font/width_new_font)
@ -642,9 +639,9 @@ BOOLEAN wpr(long data)
long width_old,width_new; long width_old,width_new;
TString spc(128, 'm'); TString spc(128, 'm');
xvtil_set_font(prwin,st->name_1, XVT_FS_NONE, st->size_1); xvtil_set_font(prwin,st->name_1, XVT_FS_NONE, st->size_1);
width_old = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 128); width_old = xvt_dwin_get_text_width(prwin, spc, spc.len());
xvtil_set_font(prwin,st->name_2, XVT_FS_NONE, st->size_2); xvtil_set_font(prwin,st->name_2, XVT_FS_NONE, st->size_2);
width_new = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 128); width_new = xvt_dwin_get_text_width(prwin,spc, spc.len());
st->ratio = (double)width_old / (double)width_new; st->ratio = (double)width_old / (double)width_new;
xvt_vobj_destroy(prwin); xvt_vobj_destroy(prwin);
@ -672,9 +669,9 @@ bool TPrint_section::repos_fields(const char* name, int size)
rt = TRUE; rt = TRUE;
s_data prm; s_data prm;
prm.size_1=ps.form().fontsize(); prm.size_1=ps.form().fontsize();
strcpy(prm.name_1,ps.form().fontname()); prm.name_1 = ps.form().fontname();
prm.size_2=size; prm.size_2=size;
strcpy(prm.name_2,name); prm.name_2 = name;
prm.ratio = 1.0; prm.ratio = 1.0;
// Next 3 lines may be changed // Next 3 lines may be changed
xvt_print_open(); xvt_print_open();

View File

@ -6,10 +6,13 @@
#include <diction.h> #include <diction.h>
#include <msksheet.h> #include <msksheet.h>
#include <prefix.h> #include <prefix.h>
#include <recarray.h>
#include <relation.h> #include <relation.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <user.h>
#define DLG_PAGETAGS 31000 #define DLG_PAGETAGS 31000
HIDDEN const char* const MASK_EXT = "msk"; HIDDEN const char* const MASK_EXT = "msk";
@ -99,27 +102,40 @@ TMask::TMask(const char* title, int pages, int cols, int rows,
cols, rows, title, this, pages > 1); cols, rows, title, this, pages > 1);
} }
void TMask::set_locking(TBit_array& read_only, TToken_string& list, bool on)
void TMask::set_locking(TBit_array & read_only, TToken_string & fields, bool on)
{ {
FOR_EACH_TOKEN(fields, fld) if (list.find('*') >= 0)
{ {
short id = 0; if (on)
if (real::is_natural(fld)) {
id = atoi(fld); read_only.set(fields());
read_only.set();
}
else
read_only.reset();
}
else else
{ {
TMask_field * f = find_by_fieldname(fld); FOR_EACH_TOKEN(list, fld)
if (f != NULL)
id = f->dlg();
}
if (id > 0)
{ {
const int pos = id2pos(id); const TFixed_string id(fld);
if (id[0] == '-' || id.ends_with("@")) // Gestione gruppi
{
const int grp = abs(atoi(fld));
FOR_EACH_MASK_FIELD((*this), pos, f)
{
if (f->in_group(grp))
read_only.set(pos, on);
}
}
else
{
const int pos = field2pos(fld);
if (pos >= 0) if (pos >= 0)
read_only.set(pos, on); read_only.set(pos, on);
} }
} }
}
} }
// @mfunc Legge la maschera da file // @mfunc Legge la maschera da file
@ -191,33 +207,43 @@ void TMask::read_mask(
TFilename prof; TFilename prof;
if (make_profile_name(prof)) if (make_profile_name(prof))
{ {
// Costruisce la lista dei gruppi di appartenenza dell'utente
TString_array users_and_groups;
for (TString u = user(); u.full(); u = cache().get(LF_USER, u, USR_GROUPNAME))
users_and_groups.add(u);
TConfig ini(prof); TConfig ini(prof);
TString16 para(user()); para << "_Locks"; FOR_EACH_ARRAY_ROW_BACK(users_and_groups, c, utonto)
if (ini.set_paragraph(para))
{ {
const int items = fields(); *utonto << "_Locks";
TBit_array read_only(items); if (ini.set_paragraph(*utonto))
TAuto_token_string fields(ini.get("Lock")); {
TBit_array read_only;
if (fields == "*") TAuto_token_string lfields(ini.get("Lock"));
read_only.set(); TAuto_token_string ufields(ini.get("Unlock"));
if (ufields.find("*")>=0)
{
set_locking(read_only, lfields, true);
}
else else
set_locking(read_only, fields);
fields = ini.get("Unlock");
set_locking(read_only, fields, false);
for (int j = 0; j < items; j++) if (read_only[j])
{ {
TMask_field& f = fld(j); set_locking(read_only, lfields, true);
if (f.is_loadable()) set_locking(read_only, ufields, false);
f.set_read_only(true);
}
}
} }
FOR_EACH_MASK_FIELD((*this), j, f)
{
if (f->is_loadable())
{
const bool ro = read_only[j];
if (f->read_only() != ro)
f->set_read_only(ro);
}
}
}
}
}
} }
} }
void TMask::add_field(TMask_field* f) void TMask::add_field(TMask_field* f)
@ -608,16 +634,32 @@ TMask_field& TMask::field(short id) const
return fld(pos); return fld(pos);
} }
TMask_field* TMask::find_by_fieldname(const char* fieldname) const int TMask::field2pos(const char* fieldname) const
{ {
for (int i = fields()-1; i >= 0; i--) const int id = atoi(fieldname);
int i;
for (i = fields()-1; i >= 0; i--)
{ {
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (id == 0)
{
const TFieldref* fr = f.field(); const TFieldref* fr = f.field();
if (fr && fr->name() == fieldname) if (fr != NULL && fr->name() == fieldname)
return &f; break;
} }
return NULL; else
{
if (f.dlg() == id)
break;
}
}
return i;
}
TMask_field* TMask::find_by_fieldname(const char* fieldname) const
{
const int i = field2pos(fieldname);
return i >= 0 ? &fld(i) : NULL;
} }
TEdit_field& TMask::efield(short id) const TEdit_field& TMask::efield(short id) const
@ -1520,43 +1562,29 @@ void TMask::show_default(
} else field(fld_id).show_default(); } else field(fld_id).show_default();
} }
void TMask::autoload(const TRelation& r) void TMask::autoload(const TRelation& r)
{ {
const int max = fields(); FOR_EACH_MASK_FIELD((*this), i, f) if (f->is_loadable())
for (int i = 0; i < max; i++) ((TLoadable_field*)f)->autoload(r);
{
TMask_field& f = fld(i);
if (f.is_loadable())
((TLoadable_field&)f).autoload(r);
}
} }
void TMask::autosave(TRelation& r) const void TMask::autosave(TRelation& r) const
{ {
const int max = fields(); FOR_EACH_MASK_FIELD((*this), i, f) if (f->is_loadable())
for (int i = 0; i < max; i++)
{ {
TMask_field& f = fld(i); bool save = f->shown();
if (f.is_loadable()) if (!save && f->is_editable())
{
TLoadable_field& l = (TLoadable_field&)f;
bool save = f.shown();
if (!save && f.is_editable())
{ {
// tenta di effettuare il save dei campi Edit hidden: // tenta di effettuare il save dei campi Edit hidden:
// salva il nuovo valore solo se il precedente era blank // salva il nuovo valore solo se il precedente era blank
TEditable_field& e = (TEditable_field&)f; if (f->field() != NULL)
if (e.field() != NULL)
{ {
const char* str = l.field()->read(r); const char* str = f->field()->read(r);
save = *str == '\0'; save = *str == '\0';
} }
} }
if (save) if (save)
l.autosave(r); ((TLoadable_field*)f)->autosave(r);
}
} }
} }
@ -2127,10 +2155,15 @@ void TMask::copy_values(
bool TMask::make_profile_name(TFilename& f) const bool TMask::make_profile_name(TFilename& f) const
{ {
f = source_file().name();
f.ext("ini");
if (!f.custom_path()) // Prova a cercare la configurazione in custom ...
{ // ... altrimenti riprova in config
f =::firm2dir(-1); // Directory dati f =::firm2dir(-1); // Directory dati
f.add("config"); // Directory config f.add("config"); // Directory config
f.add(source_file().name()); // Nome Maschera f.add(source_file().name()); // Nome Maschera
f.ext("ini"); // Estensione f.ext("ini"); // Estensione
}
return f.exist(); return f.exist();
} }

View File

@ -151,7 +151,7 @@ public:
virtual ~TMask(); virtual ~TMask();
// @cmember Imposta i bit di read_only // @cmember Imposta i bit di read_only
void set_locking(TBit_array & read_only, TToken_string & fields, bool on = true); void set_locking(TBit_array & read_only, TToken_string & fields, bool on);
// @cmember Legge la maschera da file // @cmember Legge la maschera da file
void read_mask(const char* name, int num, int max); void read_mask(const char* name, int num, int max);
@ -255,6 +255,8 @@ public:
// @cmember Converte un identificatore di campo nella sua posizione // @cmember Converte un identificatore di campo nella sua posizione
int id2pos(short id) const; int id2pos(short id) const;
// @cmember Cerca la posizione di un campo per nome
int field2pos(const char* fieldname) const;
// @cmember Ritorna il campo i-esimo della maschera // @cmember Ritorna il campo i-esimo della maschera
TMask_field& fld(int i) const TMask_field& fld(int i) const
{ return (TMask_field&)_field[i]; } { return (TMask_field&)_field[i]; }

View File

@ -12,14 +12,12 @@
#include <recset.h> #include <recset.h>
#include <relapp.h> #include <relapp.h>
#include <sheet.h> #include <sheet.h>
#include <tabutil.h>
#include <text.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <validate.h> #include <validate.h>
#include <virtkeyb.h> #include <virtkeyb.h>
#include <xvtility.h>
#include <nditte.h>
// @doc INTERNAL // @doc INTERNAL
@ -95,7 +93,7 @@ char TMask_field::TField_Flags::update(const char* f, bool reset)
case 'I': case 'I':
break; // reserved for sheetfield insert break; // reserved for sheetfield insert
case 'L': case 'L':
read_only = reset; break; read_only = !reset; break;
case 'M': case 'M':
roman = !reset; break; roman = !reset; break;
case 'P': case 'P':
@ -143,6 +141,7 @@ void TMask_field::update_flags(const char* f, bool reset)
_flags.update(f, reset); _flags.update(f, reset);
show(shown()); show(shown());
enable(enabled()); enable(enabled());
set_read_only(read_only());
} }
TMask_field::TMask_field(TMask* m) TMask_field::TMask_field(TMask* m)
@ -1720,7 +1719,6 @@ bool TBoolean_field::on_key(KEY key)
set_dirty(); set_dirty();
on_hit(); on_hit();
return TRUE; return TRUE;
break;
case K_F2: case K_F2:
if (!read_only()) if (!read_only())
{ {
@ -1728,7 +1726,6 @@ bool TBoolean_field::on_key(KEY key)
set_dirty(); set_dirty();
} }
return TRUE; return TRUE;
break;
default: default:
return TEditable_field::on_key(key); return TEditable_field::on_key(key);
} }
@ -3175,31 +3172,22 @@ bool TEdit_field::parse_item(TScanner& scanner)
int key = 1; int key = 1;
TRelation* r = NULL; TRelation* r = NULL;
const int logicnum = scanner.integer(); TString16 tablename = scanner.pop();
TString16 tabmaskname; const int logicnum = table2logic(tablename);
if (logicnum > 0) if (logicnum > 0)
{ {
TDir d; d.get(logicnum); TDir d; d.get(logicnum);
if (fexist(d.filename())) // Controlla l'esistenza del file if (fexist(d.filename())) // Controlla l'esistenza del file
r = new TRelation(logicnum);
#ifdef DBG
else
yesnofatal_box("Impossibile creare una USE sul file %s",d.filename());
#endif
}
else
{ {
tabmaskname = scanner.pop(); if (logicnum >= LF_TABGEN && logicnum <= LF_TAB)
#ifdef DBG r = new TRelation(tablename);
if (tabmaskname.len() > 4) else
return yesnofatal_box("'%s' non e' una tabella valida: %d", r = new TRelation(logicnum);
(const char*)tabmaskname, dlg());
#endif
TDir d; d.get(TTable::name2log(tabmaskname));
if (fexist(d.filename())) // Controlla l'esistenza del file
r = new TRelation(tabmaskname);
} }
}
else
error_box("Il campo %d usa il file o tabella non valida %s",
dlg(), (const char*)tablename);
if (scanner.popkey() == "KE") if (scanner.popkey() == "KE")
{ {
@ -3234,10 +3222,10 @@ bool TEdit_field::parse_item(TScanner& scanner)
} }
scanner.push(); scanner.push();
if (tabmaskname.not_empty()) if (tablename.not_empty())
{ {
tabmaskname.insert("MTB", 0); tablename.insert("MTB", 0);
browse()->set_insert(tabmaskname); browse()->set_insert(tablename);
} }
_check_enabled = TRUE; _check_enabled = TRUE;
} }
@ -3451,12 +3439,10 @@ void TEdit_field::set_read_only(bool r)
} }
} }
// Filtro magico sulle ditte esistenti // Filtro magico sulle ditte esistenti
HIDDEN bool firm_filter(const TRelation* rel) HIDDEN bool firm_filter(const TRelation* rel)
{ {
const long firm = rel->curr().get_long("CODDITTA"); const long firm = rel->curr().get_long(NDT_CODDITTA);
return prefix().exist(firm); return prefix().exist(firm);
} }

View File

@ -23,8 +23,8 @@ word TIndwin::measure_text(TToken_string& s, word& maxlen) const
// Certified 70% // Certified 70%
TIndwin::TIndwin(long tot, const char* txt, bool cancel, bool bar, int div) TIndwin::TIndwin(long tot, const char* txt, bool cancel, bool bar, int div)
: _text(NULL), _cancel(NULL), : _text(NULL), _cancel(NULL), _gauge(NULL_WIN), _bar(0),
_bar(0), _flags(0x0), _max(tot), _status(0L) _flags(0x0), _max(tot), _status(0L)
{ {
TToken_string testo(txt, '\n'); TToken_string testo(txt, '\n');
word maxlen = div; word maxlen = div;
@ -43,8 +43,15 @@ TIndwin::TIndwin(long tot, const char* txt, bool cancel, bool bar, int div)
if (bar) if (bar)
{ {
RCT r; _text->get_rect(r); WIN_DEF wd; memset(&wd, 0, sizeof(wd));
wd.wtype = WC_HGAUGE;
RCT& r = wd.rct;
_text->get_rect(r);
_bar = r.bottom + CHARY; _bar = r.bottom + CHARY;
get_bar_rct(r);
_gauge = xvt_ctl_create_def(&wd, win(), tot);
} }
if (cancel) if (cancel)
@ -75,17 +82,13 @@ void TIndwin::set_text(
testo.replace('\n', '\r'); testo.replace('\n', '\r');
_text->set_caption(testo); _text->set_caption(testo);
#endif #endif
if (_bar)
{
RCT r; get_bar_rct(r);
xvt_dwin_invalidate_rect(win(), &r);
}
} }
void TIndwin::setmax(long m) void TIndwin::setmax(long m)
{ {
_max = m <= 0 ? 1 : m; _max = m <= 0 ? 1 : m;
if (_gauge)
xvt_sbar_set_range(_gauge, HVGAUGE, 0, _max);
_start_time = clock(); _start_time = clock();
} }
@ -146,32 +149,6 @@ void TIndwin::update_bar()
// Percentuale raggiunta finora // Percentuale raggiunta finora
const double prc = (double)_status / (double)_max; const double prc = (double)_status / (double)_max;
// Rettangolo contenente l'intera barra
RCT r; get_bar_rct(r);
set_font();
if (ADVANCED_GRAPHICS)
{
const WINDOW w = win();
RCT b = r;
// Rettangolo scavato
const int thick = 1;
xi_draw_3d_rect((XinWindow)w, (XinRect*)&b, TRUE, thick,
MASK_LIGHT_COLOR, MASK_BACK_COLOR, MASK_DARK_COLOR);
xvt_rect_inflate(&b, -thick, -thick);
b.right = b.left + int((b.right-b.left)*prc + 0.5);
const int lasti = (b.bottom-b.top)/2;
for (int i = 0; i <= lasti; i++)
{
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);
g = b; g.top = cy;
xvt_dwin_draw_gradient_linear(w, &g, BTN_DARK_COLOR, BTN_LIGHT_COLOR, 90);
}
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;
@ -184,10 +161,10 @@ void TIndwin::update_bar()
n.format("%d%% - %s %s - %s %s", int(prc*100.0+0.5), n.format("%d%% - %s %s - %s %s", int(prc*100.0+0.5),
TR("Tempo residuo"), str_res.get_buffer(), TR("Tempo residuo"), str_res.get_buffer(),
TR("Tempo totale"), str_tot.get_buffer()); TR("Tempo totale"), str_tot.get_buffer());
b = r; RCT b; get_bar_rct(b);
b.top = b.bottom+2; b.top = b.bottom+2; b.bottom = b.top + CHARY;
b.bottom = b.top + CHARY;
WINDOW w = win();
CBRUSH brush; brush.pat = PAT_SOLID; brush.color = MASK_BACK_COLOR; CBRUSH brush; brush.pat = PAT_SOLID; brush.color = MASK_BACK_COLOR;
xvt_dwin_set_cbrush(w, &brush); xvt_dwin_set_cbrush(w, &brush);
xvt_dwin_set_std_cpen(w, TL_PEN_HOLLOW); xvt_dwin_set_std_cpen(w, TL_PEN_HOLLOW);
@ -195,34 +172,34 @@ void TIndwin::update_bar()
xvt_dwin_set_clip(w, NULL); xvt_dwin_set_clip(w, NULL);
set_color(NORMAL_COLOR, MASK_BACK_COLOR); set_color(NORMAL_COLOR, MASK_BACK_COLOR);
set_opaque_text(TRUE); set_opaque_text(TRUE);
xvt_dwin_draw_text(w, r.left, r.bottom+CHARY-1, n, -1); set_font();
xvt_dwin_draw_text(w, b.left, b.bottom-1, n, -1);
} }
}
else
{
// Rettangolo in rilievo
RCT b = r;
b.right = b.left + int((r.right-r.left)*prc);
xi_draw_3d_rect((XinWindow)win(), (XinRect*)&b, FALSE, 2,
BTN_LIGHT_COLOR, BTN_BACK_COLOR, BTN_DARK_COLOR);
// Rettangolo scavato
b.left = b.right; b.right = r.right;
xi_draw_3d_rect((XinWindow)win(), (XinRect*)&b, TRUE, 2,
BTN_LIGHT_COLOR, BTN_BACK_COLOR, BTN_DARK_COLOR);
char n[8]; sprintf(n, "%d%%", int(prc * 100.0 + 0.5));
xvt_dwin_draw_text(win(), r.left+r.right/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1);
}
check_stop(); check_stop();
} }
void TIndwin::update() void TIndwin::update()
{ {
if (_bar) if (_gauge != NULL_WIN)
update_bar(); update_bar();
} }
bool TIndwin::setstatus(long l)
{
if (l < 0)
{
NFCHECK("Negative progind status");
l = 0;
}
_status = l > _max ? _max : l;
if (_gauge != NULL_WIN)
xvt_sbar_set_pos(_gauge, HVGAUGE, _status);
return !iscancelled();
}
bool TIndwin::on_key(KEY k) bool TIndwin::on_key(KEY k)
{ {
if (k == K_ESC && _cancel) if (k == K_ESC && _cancel)
@ -248,22 +225,16 @@ TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
bool TProgind::setstatus(long l) bool TProgind::setstatus(long l)
{ {
if (l < 0) const bool ok = TIndwin::setstatus(l);
{
NFCHECK("Negative progind status");
l = 0;
}
_status = l > _max ? _max : l; if (ok && clock() > _next_update)
if (clock() > _next_update)
{ {
update(); update();
do_events(); do_events();
_next_update = clock()+CLOCKS_PER_SEC; // Prossimo aggiornamento tra un secondo _next_update = clock()+CLOCKS_PER_SEC; // Prossimo aggiornamento tra un secondo
} }
return !iscancelled(); return ok;
} }
// TTimerind ------------------------------------------------------------ // TTimerind ------------------------------------------------------------

View File

@ -33,6 +33,7 @@ class TIndwin : public TWindow
// @cmember:(INTERNAL) Bottone "Annulla" // @cmember:(INTERNAL) Bottone "Annulla"
TControl* _cancel; TControl* _cancel;
// @cmember:(INTERNAL) Movimento della barra e percentuale // @cmember:(INTERNAL) Movimento della barra e percentuale
WINDOW _gauge;
int _bar; int _bar;
// @cmember:(INTERNAL) ora inizio elaborazione // @cmember:(INTERNAL) ora inizio elaborazione
unsigned long _start_time; unsigned long _start_time;
@ -92,6 +93,8 @@ public:
// @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);
// @cmember Costruttore // @cmember Costruttore
TIndwin(long max, const char* txt, bool cancel = TRUE, bool bar = TRUE, int div = 60); TIndwin(long max, const char* txt, bool cancel = TRUE, bool bar = TRUE, int div = 60);
// @cmember Distruttore // @cmember Distruttore
@ -111,7 +114,7 @@ class TProgind : public TIndwin
// @access Public Member // @access Public Member
public: public:
// @cmember Setta lo stato della barra d'attesa // @cmember Setta lo stato della barra d'attesa
bool setstatus(long l); virtual bool setstatus(long l);
// @cmember Aggiorna la barra d'attesa aggiungendo l'incremento fatto dell'applicazione // @cmember Aggiorna la barra d'attesa aggiungendo l'incremento fatto dell'applicazione
bool addstatus(long l) bool addstatus(long l)
{ return setstatus(_status+l); } { return setstatus(_status+l); }

View File

@ -1,5 +1,6 @@
#define USR_USERNAME "USERNAME" #define USR_USERNAME "USERNAME"
#define USR_USERDESC "USERDESC" #define USR_USERDESC "USERDESC"
#define USR_GROUPNAME "GROUPNAME"
#define USR_PASSWORD "PASSWORD" #define USR_PASSWORD "PASSWORD"
#define USR_DATAPWD "DATAPWD" #define USR_DATAPWD "DATAPWD"
#define USR_ISGROUP "ISGROUP" #define USR_ISGROUP "ISGROUP"