Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : automask.cpp Corretta espressione condizionale che non si compila bene a 16 bit maskfld.h Sostituito set_hotkey con set_exit_key relapp.cpp Corretta abilitazione dei bottoni in base ai permessi sheet.cpp Corretta gestione bototni Elimina e Nuovo git-svn-id: svn://10.65.10.50/trunk@7570 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1855e56994
commit
d4ca44125c
@ -63,7 +63,7 @@ TField_event TAutomask::key2event(TMask_field& f, KEY key) const
|
|||||||
if (f.is_kind_of(CLASS_BUTTON_FIELD))
|
if (f.is_kind_of(CLASS_BUTTON_FIELD))
|
||||||
fe = fe_button;
|
fe = fe_button;
|
||||||
else
|
else
|
||||||
fe = wm.is_running() ? fe_modify : fe = fe_init;
|
fe = wm.is_running() ? fe_modify : fe_init;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case K_ENTER:
|
case K_ENTER:
|
||||||
|
@ -517,7 +517,7 @@ public:
|
|||||||
KEY exit_key() const
|
KEY exit_key() const
|
||||||
{ return _exit_key; }
|
{ return _exit_key; }
|
||||||
|
|
||||||
void set_hot_key(KEY k) { _virtual_key = _exit_key = k; }
|
void set_exit_key(KEY k) { _exit_key = k; }
|
||||||
void set_bmp(short up, short dn);
|
void set_bmp(short up, short dn);
|
||||||
void set_native_icon(unsigned icon);
|
void set_native_icon(unsigned icon);
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ public:
|
|||||||
void set_warning(const char* w);
|
void set_warning(const char* w);
|
||||||
const char* get_warning() const;
|
const char* get_warning() const;
|
||||||
|
|
||||||
virtual void show(bool on);
|
virtual void show(bool on = TRUE);
|
||||||
|
|
||||||
virtual void set_prompt(const char* p);
|
virtual void set_prompt(const char* p);
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ void TRelation_application::set_toolbar(bool all)
|
|||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
{
|
{
|
||||||
const int mode = _mask->mode();
|
const int mode = _mask->mode();
|
||||||
bool enabdel = mode != MODE_INS && can_edit;
|
bool enabdel = (mode == MODE_QUERY) || (mode == MODE_MOD && can_edit);
|
||||||
if (enabdel && mode == MODE_MOD)
|
if (enabdel && mode == MODE_MOD)
|
||||||
{
|
{
|
||||||
TRelation& r = *get_relation();
|
TRelation& r = *get_relation();
|
||||||
@ -509,19 +509,104 @@ int TRelation_application::delete_mode()
|
|||||||
{
|
{
|
||||||
TEdit_field& fld = get_search_field();
|
TEdit_field& fld = get_search_field();
|
||||||
TBrowse* brw = fld.browse();
|
TBrowse* brw = fld.browse();
|
||||||
|
if (brw)
|
||||||
brw->do_input(TRUE);
|
|
||||||
|
|
||||||
TCursor* cur = brw ? brw->cursor() : NULL;
|
|
||||||
|
|
||||||
if (cur)
|
|
||||||
{
|
{
|
||||||
|
brw->do_input(TRUE);
|
||||||
|
TCursor& cur = *brw->cursor();
|
||||||
|
|
||||||
TToken_string head(brw->head());
|
TToken_string head(brw->head());
|
||||||
head.insert("@1|", 0);
|
head.insert("@1|", 0);
|
||||||
TToken_string items(brw->items());
|
TToken_string items(brw->items());
|
||||||
items.insert(" |", 0);
|
items.insert(" |", 0);
|
||||||
TCursor_sheet sht(cur, items, "Eliminazione", head, 0, 1);
|
|
||||||
if (sht.run() == K_ENTER)
|
TPointer_array keys;
|
||||||
|
int tab1 = 0, tab2 = 0, y = 0;
|
||||||
|
for (int kf = 0; ; kf++)
|
||||||
|
{
|
||||||
|
TEditable_field* e = _mask->get_key_field(1, kf == 0);
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
|
if (e->shown())
|
||||||
|
{
|
||||||
|
keys.add(e);
|
||||||
|
if (e->enabled())
|
||||||
|
{
|
||||||
|
const int len = strlen(e->prompt());
|
||||||
|
if (len > tab1) tab1 = len;
|
||||||
|
const int size = e->size();
|
||||||
|
if (size > tab2) tab2 = size;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tab1 += 5;
|
||||||
|
tab2 += tab1+2;
|
||||||
|
|
||||||
|
TCursor_sheet sht(&cur, items, "Eliminazione", head, 0x4, y);
|
||||||
|
|
||||||
|
y = -1; // Posizione del campo precedente
|
||||||
|
TString prompt; // Prompt del campo corrente
|
||||||
|
for(int k = 0; k < keys.items(); k++)
|
||||||
|
{
|
||||||
|
TEditable_field& e = (TEditable_field&)keys[k];
|
||||||
|
if (e.enabled())
|
||||||
|
{
|
||||||
|
const short id = 1000+e.dlg();
|
||||||
|
prompt = "Da "; prompt << e.prompt();
|
||||||
|
sht.add_static(DLG_NULL, 0, prompt, 1, ++y);
|
||||||
|
TString16 flags;
|
||||||
|
if (e.automagic()) flags << 'A';
|
||||||
|
if (e.roman()) flags << 'M';
|
||||||
|
if (e.right_justified()) flags << 'R';
|
||||||
|
if (e.uppercase()) flags << 'U';
|
||||||
|
if (e.zerofilled()) flags << 'Z';
|
||||||
|
switch (e.class_id())
|
||||||
|
{
|
||||||
|
case CLASS_DATE_FIELD:
|
||||||
|
sht.add_date(id, 0, "", tab1, y, flags);
|
||||||
|
sht.add_date(id+1000, 0, "A ", tab2, y, flags);
|
||||||
|
break;
|
||||||
|
case CLASS_REAL_FIELD:
|
||||||
|
sht.add_number(id, 0, "", tab1, y, e.size(), flags);
|
||||||
|
sht.add_number(id+1000, 0, "A ", tab2, y, e.size(), flags);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sht.add_string(id, 0, "", tab1, y, e.size(), flags);
|
||||||
|
sht.add_string(id+1000, 0, "A ", tab2, y, e.size(), flags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int tasto;
|
||||||
|
while ((tasto = sht.run()) == K_ENTER)
|
||||||
|
{
|
||||||
|
TRectype rec_from(cur.file().num()), rec_to(cur.file().num());
|
||||||
|
for(int k = 0; k < keys.items(); k++)
|
||||||
|
{
|
||||||
|
TEditable_field& e = (TEditable_field&)keys[k];
|
||||||
|
const TFieldref* ref = e.field();
|
||||||
|
if (ref)
|
||||||
|
{
|
||||||
|
const TString& fr = e.enabled() ? sht.get(e.dlg()+1000) : e.get();
|
||||||
|
ref->write(fr, rec_from);
|
||||||
|
const TString& to = e.enabled() ? sht.get(e.dlg()+2000) : e.get();
|
||||||
|
if (to.not_empty()) ref->write(to, rec_to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur.curr() = rec_from;
|
||||||
|
cur.read();
|
||||||
|
while (cur.file().status() == NOERR && cur.curr() <= rec_to)
|
||||||
|
{
|
||||||
|
sht.check(cur.pos());
|
||||||
|
++cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tasto == K_DEL)
|
||||||
{
|
{
|
||||||
long deleting = sht.checked();
|
long deleting = sht.checked();
|
||||||
if (deleting == 0)
|
if (deleting == 0)
|
||||||
@ -529,22 +614,29 @@ int TRelation_application::delete_mode()
|
|||||||
sht.check(sht.selected());
|
sht.check(sht.selected());
|
||||||
deleting++;
|
deleting++;
|
||||||
}
|
}
|
||||||
TString msg(80);
|
TString msg;
|
||||||
msg = "Confermate l'eliminazione de";
|
msg = "Confermate l'eliminazione de";
|
||||||
if (deleting == 1)
|
if (deleting == 1)
|
||||||
msg << "l documento selezionato?";
|
msg << "l documento selezionato?";
|
||||||
else
|
else
|
||||||
msg << "i " << deleting << " documenti selezionati?";
|
msg << "i " << deleting << " documenti selezionati?";
|
||||||
if (yesno_box(msg))
|
|
||||||
|
bool can_delete = yesno_box(msg);
|
||||||
|
if (can_delete && deleting > 100)
|
||||||
|
{
|
||||||
|
msg.insert("ATTENZIONE: ", 0);
|
||||||
|
can_delete = yesno_box(msg);
|
||||||
|
}
|
||||||
|
if (can_delete)
|
||||||
{
|
{
|
||||||
TWait_cursor hourglass;
|
TWait_cursor hourglass;
|
||||||
long skipped = 0; // Record non cancellati perche' protetti
|
long skipped = 0; // Record non cancellati perche' protetti
|
||||||
cur->freeze(TRUE); // Congelo il cursore altrimenti si riaggiorna troppo
|
cur.freeze(TRUE); // Congelo il cursore altrimenti si riaggiorna troppo
|
||||||
for (long pos = 0; deleting > 0; pos++)
|
for (long pos = 0; deleting > 0; pos++)
|
||||||
{
|
{
|
||||||
if (sht.checked(pos))
|
if (sht.checked(pos))
|
||||||
{
|
{
|
||||||
*cur = pos;
|
cur = pos;
|
||||||
brw->do_output();
|
brw->do_output();
|
||||||
bool can_delete = FALSE;
|
bool can_delete = FALSE;
|
||||||
if (find(1))
|
if (find(1))
|
||||||
@ -564,7 +656,7 @@ int TRelation_application::delete_mode()
|
|||||||
deleting--;
|
deleting--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur->freeze(FALSE);
|
cur.freeze(FALSE);
|
||||||
if (skipped > 0)
|
if (skipped > 0)
|
||||||
{
|
{
|
||||||
if (skipped == 1)
|
if (skipped == 1)
|
||||||
|
@ -216,6 +216,7 @@ TSheet_control::TSheet_control(
|
|||||||
l->scroll_bar_button = TRUE;
|
l->scroll_bar_button = TRUE;
|
||||||
l->white_space_color = MASK_DARK_COLOR;
|
l->white_space_color = MASK_DARK_COLOR;
|
||||||
l->rule_color = MASK_DARK_COLOR;
|
l->rule_color = MASK_DARK_COLOR;
|
||||||
|
|
||||||
// Definizione della prima colonna (numero di riga)
|
// Definizione della prima colonna (numero di riga)
|
||||||
const long attr = XI_ATR_VISIBLE | XI_ATR_RJUST | XI_ATR_SELECTABLE;
|
const long attr = XI_ATR_VISIBLE | XI_ATR_RJUST | XI_ATR_SELECTABLE;
|
||||||
XI_OBJ_DEF* coldef = xi_add_column_def(listdef, FIRST_FIELD+1000-1, attr, 0,
|
XI_OBJ_DEF* coldef = xi_add_column_def(listdef, FIRST_FIELD+1000-1, attr, 0,
|
||||||
@ -817,27 +818,30 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
|||||||
case XIE_SELECT:
|
case XIE_SELECT:
|
||||||
if (xiev->v.xi_obj->type == XIT_ROW)
|
if (xiev->v.xi_obj->type == XIT_ROW)
|
||||||
{
|
{
|
||||||
int num;
|
|
||||||
XI_OBJ** column = xi_get_member_list(_obj, &num);
|
|
||||||
const int col = xiev->v.select.column;
|
|
||||||
|
|
||||||
const int row = xiev->v.select.xi_obj->v.row;
|
const int row = xiev->v.select.xi_obj->v.row;
|
||||||
const long rec = row2rec(row);
|
const long rec = row2rec(row);
|
||||||
const short cid = column[col]->cid - 1000;
|
if (row_enabled(rec))
|
||||||
if (cid >= FIRST_FIELD)
|
|
||||||
{
|
|
||||||
if (check_enabled())
|
|
||||||
toggle(rec);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (_cur_rec == rec)
|
int num;
|
||||||
_sheet->on_key(K_CTRL+'G');
|
XI_OBJ** column = xi_get_member_list(_obj, &num);
|
||||||
|
const int col = xiev->v.select.column;
|
||||||
|
|
||||||
|
const short cid = column[col]->cid - 1000;
|
||||||
|
if (cid >= FIRST_FIELD)
|
||||||
|
{
|
||||||
|
if (check_enabled())
|
||||||
|
toggle(rec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_cur_rec == rec)
|
||||||
|
_sheet->on_key(K_CTRL+'G');
|
||||||
|
}
|
||||||
|
const int c = _type[0] == 'C' ? 2 : 1;
|
||||||
|
XI_OBJ cell; XI_MAKE_CELL(&cell, _obj, row, c);
|
||||||
|
xi_set_focus(&cell);
|
||||||
|
make_current(rec);
|
||||||
}
|
}
|
||||||
const int c = _type[0] == 'C' ? 2 : 1;
|
|
||||||
XI_OBJ cell; XI_MAKE_CELL(&cell, _obj, row, c);
|
|
||||||
xi_set_focus(&cell);
|
|
||||||
make_current(rec);
|
|
||||||
}
|
}
|
||||||
refused = TRUE;
|
refused = TRUE;
|
||||||
break;
|
break;
|
||||||
@ -945,7 +949,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
|
|||||||
fields_array().add(qf);
|
fields_array().add(qf);
|
||||||
_sheet = qf->sheet();
|
_sheet = qf->sheet();
|
||||||
|
|
||||||
if (!(buttons & 0x10)) add_button(DLG_SELECT, "Selezione", K_ENTER);
|
if (!(buttons & 0x10)) add_button(DLG_SELECT, "~Selezione", K_ENTER);
|
||||||
if (check_enabled())
|
if (check_enabled())
|
||||||
{
|
{
|
||||||
add_button(DLG_USER, "Tutti", 0);
|
add_button(DLG_USER, "Tutti", 0);
|
||||||
@ -954,7 +958,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
|
|||||||
|
|
||||||
if (buttons & 0x01) add_button(DLG_LINK, "~Gestione", K_CTRL+'G');
|
if (buttons & 0x01) add_button(DLG_LINK, "~Gestione", K_CTRL+'G');
|
||||||
if (buttons & 0x02) add_button(DLG_NEWREC, "~Nuovo", K_INS, BMP_NEWREC, BMP_NEWRECDN);
|
if (buttons & 0x02) add_button(DLG_NEWREC, "~Nuovo", K_INS, BMP_NEWREC, BMP_NEWRECDN);
|
||||||
if (buttons & 0x04) add_button(DLG_DELREC, "Elimina", K_DEL, BMP_DELREC, BMP_DELRECDN);
|
if (buttons & 0x04) add_button(DLG_DELREC, "~Elimina", K_DEL, BMP_DELREC, BMP_DELRECDN);
|
||||||
if (buttons & 0x08) add_button(DLG_QUIT, "Fine", K_ESC);
|
if (buttons & 0x08) add_button(DLG_QUIT, "Fine", K_ESC);
|
||||||
else add_button(DLG_CANCEL, "Annulla", K_ESC);
|
else add_button(DLG_CANCEL, "Annulla", K_ESC);
|
||||||
}
|
}
|
||||||
@ -979,7 +983,7 @@ void TSheet::add_button(
|
|||||||
{
|
{
|
||||||
TButton_field& butt = TMask::add_button(id, 0, caption, 0, -1, 11, 2,
|
TButton_field& butt = TMask::add_button(id, 0, caption, 0, -1, 11, 2,
|
||||||
"", bmp_up, bmp_dn);
|
"", bmp_up, bmp_dn);
|
||||||
butt.set_hot_key(key);
|
butt.set_exit_key(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSheet::repos_buttons() const
|
void TSheet::repos_buttons() const
|
||||||
@ -1091,9 +1095,9 @@ bool TSheet::on_key(KEY key)
|
|||||||
case K_ESC:
|
case K_ESC:
|
||||||
stop_run(key);
|
stop_run(key);
|
||||||
break;
|
break;
|
||||||
case K_DEL:
|
case K_CTRL+'E':
|
||||||
if (items() && id2pos(DLG_DELREC) >= 0)
|
if (items() && id2pos(DLG_DELREC) >= 0)
|
||||||
stop_run(key);
|
stop_run(K_DEL);
|
||||||
break;
|
break;
|
||||||
case K_CTRL+'N':
|
case K_CTRL+'N':
|
||||||
if (id2pos(DLG_NEWREC) >= 0)
|
if (id2pos(DLG_NEWREC) >= 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user