Migliorate segnalazioni d'errore e colorati gli sheet selezionabili
git-svn-id: svn://10.65.10.50/trunk@798 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
29d720bce7
commit
61afb17024
@ -1,3 +1,64 @@
|
||||
<<<<<<< checks.h
|
||||
#ifndef __CHECKS_H
|
||||
#define __CHECKS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* @FPUB */
|
||||
int message_box(const char* fmt, ...);
|
||||
int warning_box(const char* fmt, ...);
|
||||
int sorry_box(const char* fmt, ...);
|
||||
int error_box(const char* fmt, ...);
|
||||
int fatal_box(const char* fmt, ...);
|
||||
int yesno_box(const char* fmt, ...);
|
||||
int yesnocancel_box(const char* fmt, ...);
|
||||
int yesnofatal_box(const char* fmt, ...);
|
||||
int __trace(const char* fmt, ...);
|
||||
|
||||
/* @END */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* @M
|
||||
Utilizzate in fase di debug (definire il simbolo DBG in compilazione)
|
||||
*/
|
||||
#ifdef DBG
|
||||
#define CHECK(p, m) ( (p) ? (void)0 : (void) fatal_box( \
|
||||
"Check failed in %s, line %d:\n\r%s", \
|
||||
__FILE__, __LINE__, m) )
|
||||
|
||||
#define CHECKS(p, m, s0) ( (p) ? (void)0 : (void) fatal_box( \
|
||||
"Check failed in %s, line %d:\n\r%s%s", \
|
||||
__FILE__, __LINE__, m, s0) )
|
||||
|
||||
#define CHECKD(p, m, d0) ( (p) ? (void)0 : (void) fatal_box( \
|
||||
"Check failed in %s, line %d:\n\r%s%d", \
|
||||
__FILE__, __LINE__, m, d0) )
|
||||
#else
|
||||
|
||||
#define CHECK(p, m)
|
||||
#define CHECKS(p, m, s)
|
||||
#define CHECKD(p, m, d)
|
||||
|
||||
#endif
|
||||
/* @END */
|
||||
|
||||
|
||||
/* @M
|
||||
Utilizzata in fase di debug (definire il simbolo TRC in compilazione)
|
||||
*/
|
||||
#ifdef TRC
|
||||
#define TRACE __trace
|
||||
#else
|
||||
#define TRACE 1 ? 0 : __trace
|
||||
#endif
|
||||
/* @END */
|
||||
|
||||
#endif // __CHECKS_H
|
||||
=======
|
||||
#ifndef __CHECKS_H
|
||||
#define __CHECKS_H
|
||||
|
||||
@ -57,3 +118,4 @@ Utilizzata in fase di debug (definire il simbolo TRC in compilazione)
|
||||
/* @END */
|
||||
|
||||
#endif // __CHECKS_H
|
||||
>>>>>>> 1.3
|
||||
|
@ -770,19 +770,23 @@ bool TForm_list::update()
|
||||
if (!read()) return ok;
|
||||
|
||||
const TString& val =get();
|
||||
const int pos = _codes.get_pos(val);
|
||||
int pos = _codes.get_pos(val);
|
||||
if (pos < 0)
|
||||
{
|
||||
ok = error_box("Il campo '%s' non puo' valere '%s'",
|
||||
ok = yesno_box("Il campo '%s' non puo' valere '%s': continuare ugualmente",
|
||||
(const char*)key(), (const char*)val);
|
||||
set(_codes.get(pos = 0));
|
||||
}
|
||||
else do_message(pos);
|
||||
|
||||
if (!hidden())
|
||||
if (ok)
|
||||
{
|
||||
const char* c = _values.get(pos);
|
||||
if (c == NULL) c = val;
|
||||
if (c) string_at(_x, _y, c);
|
||||
do_message(pos);
|
||||
|
||||
if (!hidden())
|
||||
{
|
||||
const char* c = _values.get(pos);
|
||||
if (c == NULL) c = val;
|
||||
if (c) string_at(_x, _y, c);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -881,11 +885,11 @@ bool TPrint_section::update()
|
||||
const bool esito = field(i).update();
|
||||
if (!esito) ok = FALSE;
|
||||
}
|
||||
|
||||
const word l = last()-1;
|
||||
if (l >= _height)
|
||||
ok = warning_box("Sezione troppo lunga: %d > %d", l, _height);
|
||||
|
||||
#ifdef DBG
|
||||
const int l = last()-1;
|
||||
if (l >= (int)_height)
|
||||
warning_box("Sezione troppo lunga: %d > %d", l+1, _height);
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -1046,6 +1050,30 @@ bool TForm::parse_join(TScanner& scanner)
|
||||
}
|
||||
|
||||
|
||||
TPrint_section* TForm::exist(char s, pagetype t, bool create)
|
||||
{
|
||||
TArray* a = NULL;
|
||||
switch (s)
|
||||
{
|
||||
case 'H':
|
||||
a = &_head; break;
|
||||
case 'F':
|
||||
a = &_foot; break;
|
||||
default:
|
||||
a = &_body; break;
|
||||
}
|
||||
|
||||
TPrint_section* sec = (TPrint_section*)a->objptr(t);
|
||||
if (sec == NULL && create)
|
||||
{
|
||||
sec = new TPrint_section(this);
|
||||
a->add(sec, t);
|
||||
}
|
||||
|
||||
return sec;
|
||||
}
|
||||
|
||||
|
||||
TPrint_section& TForm::section(char s, word p)
|
||||
{
|
||||
pagetype pos = odd_page;
|
||||
@ -1053,11 +1081,11 @@ TPrint_section& TForm::section(char s, word p)
|
||||
if (p == 1 && exist(s, first_page)) pos = first_page;
|
||||
if (pos == 0 && (p & 0x1) == 0 && exist(s, even_page)) pos = even_page;
|
||||
|
||||
TPrint_section* sec = exist(s, pos);
|
||||
CHECKD(sec, "Can't find section for page ", p);
|
||||
TPrint_section* sec = exist(s, pos, TRUE);
|
||||
return *sec;
|
||||
}
|
||||
|
||||
|
||||
word TForm::set_header(word p, bool u)
|
||||
{
|
||||
TPrinter& printer = main_app().printer();
|
||||
@ -1139,7 +1167,7 @@ word TForm::page(const TPrinter& p) const
|
||||
long TForm::records() const
|
||||
{
|
||||
const long r = _cursor ? _cursor->items() : 0;
|
||||
return 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
// Stampa gli items dal from a to
|
||||
@ -1199,7 +1227,7 @@ void TForm::print_section(ostream& out, char s) const
|
||||
for (pagetype t = odd_page; t <= last_page; t = pagetype(t+1))
|
||||
{
|
||||
const TPrint_section* sec = ((TForm*)this)->exist(s, t);
|
||||
if (sec)
|
||||
if (sec && sec->ok())
|
||||
{
|
||||
const char* name = s == 'H' ? "HEADER" : (s == 'F' ? "FOOTER" : "BODY");
|
||||
out << "SECTION " << name << ' ' << int(t);
|
||||
@ -1222,29 +1250,6 @@ void TForm::print_on(ostream& out) const
|
||||
}
|
||||
|
||||
|
||||
TPrint_section* TForm::exist(char s, pagetype t, bool create)
|
||||
{
|
||||
TArray* a = NULL;
|
||||
switch (s)
|
||||
{
|
||||
case 'H':
|
||||
a = &_head; break;
|
||||
case 'F':
|
||||
a = &_foot; break;
|
||||
default:
|
||||
a = &_body; break;
|
||||
}
|
||||
|
||||
TPrint_section* sec = (TPrint_section*)a->objptr(t);
|
||||
if (sec == NULL && create)
|
||||
{
|
||||
sec = new TPrint_section(this);
|
||||
a->add(sec, t);
|
||||
}
|
||||
|
||||
return sec;
|
||||
}
|
||||
|
||||
word TForm::height()
|
||||
{
|
||||
word h = 0;
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
TForm_item& field(int n) const { return (TForm_item&)_item[n]; }
|
||||
word fields() const { return _item.items(); }
|
||||
word height() const { return _height; }
|
||||
virtual bool ok() const { return height() > 0 || fields() > 0; }
|
||||
|
||||
void reset();
|
||||
bool update();
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: maskfld.cpp,v 1.64 1994-12-27 14:58:54 guy Exp $
|
||||
// $Id: maskfld.cpp,v 1.65 1994-12-28 11:01:21 guy Exp $
|
||||
#include <xvt.h>
|
||||
|
||||
#include <applicat.h>
|
||||
@ -1965,6 +1965,21 @@ bool TEdit_field::on_hit()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TEdit_field::default_error_box() const
|
||||
{
|
||||
if (_warning.empty())
|
||||
{
|
||||
const TString& p = prompt();
|
||||
if (isalnum(p[0]))
|
||||
error_box("Valore non valido per %s: '%s'", (const char*)p, (const char*)get());
|
||||
else
|
||||
error_box("Valore non valido: '%s'", (const char*)get());
|
||||
}
|
||||
else
|
||||
error_box(_warning);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TEdit_field::on_key(KEY key)
|
||||
{
|
||||
switch(key)
|
||||
@ -1981,7 +1996,8 @@ bool TEdit_field::on_key(KEY key)
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
if (_warning.not_empty()) error_box(_warning);
|
||||
if (_warning.not_empty())
|
||||
error_box(_warning);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1994,16 +2010,7 @@ bool TEdit_field::on_key(KEY key)
|
||||
ok = _browse->check();
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
if (_warning.not_empty()) error_box(_warning);
|
||||
else
|
||||
#ifdef DBG
|
||||
error_box("Valore del campo %d non valido: %s", dlg(), (const char*)get());
|
||||
#else
|
||||
error_box("Valore non valido: %s", (const char*)get());
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
return default_error_box();
|
||||
|
||||
ok = on_hit();
|
||||
if (!ok)
|
||||
@ -2033,7 +2040,8 @@ bool TEdit_field::on_key(KEY key)
|
||||
bool ok = validate(K_ENTER); // Check validation expression
|
||||
if (!ok)
|
||||
{
|
||||
if (_warning.not_empty()) error_box(_warning);
|
||||
if (_warning.not_empty())
|
||||
error_box(_warning);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -2053,11 +2061,7 @@ bool TEdit_field::on_key(KEY key)
|
||||
ok = query || !(check_type() == CHECK_REQUIRED && get().empty());
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
if (_warning.not_empty()) error_box(_warning);
|
||||
else error_box("Valore del campo %d non valido: '%s'", dlg(), (const char*)get());
|
||||
return FALSE;
|
||||
}
|
||||
return default_error_box();
|
||||
}
|
||||
break;
|
||||
case K_F9:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: maskfld.h,v 1.16 1994-12-27 14:58:59 guy Exp $ */
|
||||
/* $Id: maskfld.h,v 1.17 1994-12-28 11:01:27 guy Exp $ */
|
||||
#ifndef __MASKFLD_H
|
||||
#define __MASKFLD_H
|
||||
|
||||
@ -240,6 +240,7 @@ protected:
|
||||
virtual void set_window_data(const char* data);
|
||||
virtual void set_field_data(const char* data);
|
||||
virtual const char* get_field_data() const;
|
||||
bool default_error_box() const;
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
|
@ -459,14 +459,26 @@ bool TSheet::update_row(long n)
|
||||
for (int j = 0; (s = t.get()) != NULL; x += _size[j++]+1)
|
||||
{
|
||||
int x1 = x;
|
||||
bool dis = FALSE;
|
||||
bool changed = FALSE;
|
||||
if (n >= 0)
|
||||
{
|
||||
if (_checkable && j == 0)
|
||||
s = _checked[n] ? "X" : " ";
|
||||
{
|
||||
const bool c = _checked[n];
|
||||
s = c ? "X" : " ";
|
||||
if (c)
|
||||
{
|
||||
changed = TRUE;
|
||||
set_color(COLOR_RED, COLOR_LTGRAY);
|
||||
}
|
||||
}
|
||||
|
||||
dis = _disabled[n];
|
||||
if (dis) set_color(COLOR_CYAN, COLOR_GRAY);
|
||||
const bool c = _disabled[n];
|
||||
if (c)
|
||||
{
|
||||
set_color(COLOR_GRAY, COLOR_LTGRAY);
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
switch (_type[j])
|
||||
{
|
||||
@ -484,7 +496,8 @@ bool TSheet::update_row(long n)
|
||||
x1 += (_size[j]-strlen(s)) >> 1; // Centra le testate
|
||||
|
||||
stringat(x1, y, s);
|
||||
if (dis) set_color(COLOR_BLACK, COLOR_GRAY);
|
||||
if (changed)
|
||||
set_color(COLOR_BLACK, COLOR_LTGRAY);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user