applicat.cpp Aggiunto metodo firm_change_enabled
applicat.h " " cfiles.c Modificata __getfieldbuff execp.cpp Aggiunta e poi tolta disabilitazione finestra corrente form.cpp MOdificato metodo validate form.h " " isam.cpp MOdificata setfield e getfield per campi numerici printer.cpp Corretta gestione configurazioni di stampa relapp.cpp Aggiunto metodo firm_change_enabled relapp.h " " sheet.cpp window.cpp Aggiunto e tolta funzione broadcast_event git-svn-id: svn://10.65.10.50/trunk@1614 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6cab17797b
commit
17f49f6998
@ -5,6 +5,7 @@
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <toolhelp.h>
|
||||
#endif
|
||||
|
||||
#include <extcdecl.h>
|
||||
@ -555,15 +556,14 @@ bool TApplication::set_firm(long newfirm)
|
||||
_savefirm = 0;
|
||||
|
||||
WINDOW w = cur_win();
|
||||
if (w != NULL_WIN)
|
||||
if (w != NULL_WIN)
|
||||
{
|
||||
EVENT e;
|
||||
e.type = E_COMMAND;
|
||||
e.v.cmd.tag = M_FILE_NEW;
|
||||
e.v.cmd.shift = e.v.cmd.control = 0;
|
||||
e .v.cmd.shift = e.v.cmd.control = 0;
|
||||
xvt_win_dispatch_event(w, &e);
|
||||
}
|
||||
|
||||
}
|
||||
on_firm_change();
|
||||
on_config_change();
|
||||
}
|
||||
@ -649,6 +649,32 @@ void TApplication::set_cursor(bool w)
|
||||
}
|
||||
}
|
||||
|
||||
// Ritorna TRUE se al programma corrente e' concesso cambiare ditta da menu.
|
||||
// Praticamente controlla se e' stato lanciato da ba0 o dal program manager
|
||||
bool TApplication::firm_change_enabled() const
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
static bool can = 2;
|
||||
if (can == 2)
|
||||
{
|
||||
TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
|
||||
HTASK ct = GetCurrentTask();
|
||||
TaskFindHandle(&te, ct);
|
||||
TaskFindHandle(&te, te.hTaskParent);
|
||||
can = stricmp(te.szModule, "BA0") == 0 ||
|
||||
#ifdef DBG
|
||||
stricmp(te.szModule, "CVW4") == 0 ||
|
||||
#endif
|
||||
stricmp(te.szModule, "PROGMAN") == 0;
|
||||
}
|
||||
return can;
|
||||
#else
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TApplication::on_firm_change()
|
||||
{}
|
||||
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
||||
virtual bool build_firm_data(long cod, bool flagcom = FALSE) { return TRUE;}
|
||||
virtual bool destroy(); // Rimuove l'applicazione
|
||||
|
||||
|
||||
virtual void on_config_change();
|
||||
virtual void on_firm_change();
|
||||
|
||||
@ -69,6 +69,7 @@ public:
|
||||
virtual word class_id() const { return CLASS_APPLICATION; }
|
||||
virtual bool ok() const { return _create_ok; }
|
||||
virtual void print();
|
||||
virtual bool firm_change_enabled() const;
|
||||
|
||||
void stop_run(); // Forza chiusura applicazione
|
||||
|
||||
|
@ -920,27 +920,24 @@ Utilizzato per il Data Entry.
|
||||
char *s; /* stringa per l'output */
|
||||
|
||||
{
|
||||
int p, i;
|
||||
unsigned int off;
|
||||
byte len;
|
||||
char *s1;
|
||||
TrDate d;
|
||||
|
||||
int p, i;
|
||||
char *s1;
|
||||
TrDate d;
|
||||
|
||||
if ((p = findfld(recd, fieldname)) != -1)
|
||||
{
|
||||
off = recd->Fd[p].RecOff;
|
||||
len = recd->Fd[p].Len;
|
||||
if ((recd->Fd[p].TypeF != AlfaF) &&
|
||||
(recd->Fd[p].TypeF != DateF) &&
|
||||
(recd->Fd[p].TypeF != ZeroF) &&
|
||||
(recd->Fd[p].TypeF != EZeroF))
|
||||
const int tipo = recd->Fd[p].TypeF;
|
||||
unsigned int off = recd->Fd[p].RecOff;
|
||||
byte len = recd->Fd[p].Len;
|
||||
|
||||
if ((tipo != AlfaF) && (tipo != DateF) && (tipo != ZeroF) && (tipo != EZeroF))
|
||||
{
|
||||
while ((recin[off] == ' ') && (len))
|
||||
{
|
||||
off++;
|
||||
len--;
|
||||
}
|
||||
if ((recd->Fd[p].TypeF != RealF) && (recd->Fd[p].TypeF != CharF))
|
||||
if ((tipo != RealF) && (tipo != CharF))
|
||||
{
|
||||
while ((recin[off] == '0') && (len))
|
||||
{
|
||||
@ -950,17 +947,18 @@ Utilizzato per il Data Entry.
|
||||
}
|
||||
}
|
||||
else
|
||||
if ((recd->Fd[p].TypeF == ZeroF) ||
|
||||
(recd->Fd[p].TypeF == EZeroF))
|
||||
if ((tipo == ZeroF) || (tipo == EZeroF))
|
||||
{
|
||||
int i = 0, pos = 0;
|
||||
while (i < len)
|
||||
{
|
||||
if (recin[off + i] != '0') break;
|
||||
i++;
|
||||
pos = i;
|
||||
char* c = &recin[off];
|
||||
for (i = 0; i < len; i++, c++)
|
||||
{
|
||||
if (*c == ' ')
|
||||
*c = '0';
|
||||
else
|
||||
if (*c != '0')
|
||||
break;
|
||||
}
|
||||
if (pos == len)
|
||||
if (i == len)
|
||||
{
|
||||
off += len;
|
||||
len = 0;
|
||||
@ -975,7 +973,7 @@ Utilizzato per il Data Entry.
|
||||
}
|
||||
else strcpy(s, "");
|
||||
|
||||
if ((recd->Fd[p].TypeF == RealF))
|
||||
if ((tipo == RealF))
|
||||
if ((s1 = strchr(s, ',')) != NULL) *s1 = '.';
|
||||
return(0);
|
||||
}
|
||||
@ -1024,11 +1022,14 @@ Utilizzato per il Data Entry
|
||||
|
||||
{
|
||||
int p, off, len, l, i;
|
||||
char *s1;
|
||||
char *s2;
|
||||
TrDate d;
|
||||
|
||||
char *s1;
|
||||
/*
|
||||
char *s2;
|
||||
s2 = malloc(256);
|
||||
*/
|
||||
char s2[256];
|
||||
|
||||
strcpy(s2, s);
|
||||
if ((p = findfld(recd, fieldname)) != -1)
|
||||
{
|
||||
@ -1038,7 +1039,7 @@ Utilizzato per il Data Entry
|
||||
l = LENGTH(s2);
|
||||
if (l > len)
|
||||
{
|
||||
free(s2);
|
||||
/* free(s2); */
|
||||
return(-1);
|
||||
}
|
||||
s1 = recout + off ;
|
||||
@ -1065,13 +1066,13 @@ Utilizzato per il Data Entry
|
||||
}
|
||||
else
|
||||
while (l < len) s1[l++] = ' ';
|
||||
free(s2);
|
||||
/* free(s2); */
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(s, "");
|
||||
free(s2);
|
||||
/* free(s2); */
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ int TExternal_app::run(
|
||||
if (utente)
|
||||
{
|
||||
tw.maximize();
|
||||
tw.activate();
|
||||
tw.activate();
|
||||
}
|
||||
}
|
||||
xvt_statbar_refresh();
|
||||
|
276
include/form.cpp
276
include/form.cpp
@ -178,25 +178,6 @@ HIDDEN bool dateformat_handler(TMask_field& f, KEY k)
|
||||
// TForm_flags
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
struct TForm_flags : public TObject
|
||||
{
|
||||
bool automagic : 1;
|
||||
bool enabled : 1;
|
||||
bool shown : 1;
|
||||
bool dirty : 1;
|
||||
|
||||
protected:
|
||||
void print_on(ostream& out) const;
|
||||
|
||||
public:
|
||||
TForm_flags();
|
||||
|
||||
void print_on(TMask& m);
|
||||
void read_from(const TMask& m);
|
||||
|
||||
bool update(const char* s);
|
||||
};
|
||||
|
||||
TForm_flags::TForm_flags()
|
||||
{
|
||||
automagic = dirty = FALSE;
|
||||
@ -260,74 +241,6 @@ void TForm_flags::read_from(const TMask& m)
|
||||
// TForm_item
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TForm_item : public TObject
|
||||
{
|
||||
TPrint_section* _section;
|
||||
TForm_flags _flag;
|
||||
TBit_array _group;
|
||||
|
||||
protected:
|
||||
short _id, _x, _y, _width, _height;
|
||||
TString _prompt;
|
||||
TString _desc;
|
||||
TString_array _message;
|
||||
|
||||
virtual void print_on(ostream& out) const;
|
||||
virtual void print_body(ostream& out) const;
|
||||
|
||||
bool shown() const { return _flag.shown; }
|
||||
bool hidden() const { return !_flag.shown; }
|
||||
bool enabled() const { return _flag.enabled; }
|
||||
bool disabled() const { return !_flag.enabled; }
|
||||
bool automagic() const { return _flag.automagic; }
|
||||
|
||||
virtual bool parse_head(TScanner&);
|
||||
virtual bool parse_item(TScanner&);
|
||||
|
||||
virtual const char* get() const { return _prompt; }
|
||||
virtual bool set(const char* s) { _prompt = s; return TRUE; }
|
||||
|
||||
TToken_string& message(int m = 0);
|
||||
void send_message(const TString& cmd, TForm_item& dest) const;
|
||||
bool do_message(int m = 0);
|
||||
|
||||
void string_at(int x, int y, const char* s);
|
||||
|
||||
public:
|
||||
short id() const { return _id; }
|
||||
virtual int width() const { return _width; }
|
||||
virtual int height() const { return _height; }
|
||||
|
||||
virtual bool parse(TScanner&);
|
||||
virtual bool update();
|
||||
|
||||
virtual void print_on(TMask& m);
|
||||
virtual void read_from(const TMask& m);
|
||||
|
||||
virtual bool read_from(const TRectype& rform);
|
||||
virtual void print_on(TRectype& rform);
|
||||
|
||||
virtual bool edit(TMask& m);
|
||||
|
||||
TPrint_section& section() const { return *_section; }
|
||||
TForm& form() const { return _section->form(); }
|
||||
|
||||
void set_dirty(bool d = TRUE) { _flag.dirty = d; }
|
||||
bool dirty() const { return _flag.dirty; }
|
||||
|
||||
bool in_group(byte g) const { return g == 0 || _group[g]; }
|
||||
const TString& key() const { return _desc; }
|
||||
virtual void print_on(TToken_string& row) const;
|
||||
|
||||
virtual void show(bool on = TRUE) { _flag.shown = on; }
|
||||
void hide() { show(FALSE); }
|
||||
virtual void enable(bool on = TRUE);
|
||||
void disable() { enable(FALSE); }
|
||||
|
||||
TForm_item(TPrint_section* section);
|
||||
virtual ~TForm_item() {}
|
||||
};
|
||||
|
||||
|
||||
TForm_item::TForm_item(TPrint_section* section)
|
||||
: _section(section), _x(-1), _y(-1), _width(0), _height(0), _id(0)
|
||||
@ -577,6 +490,21 @@ void TForm_item::send_message(const TString& cmd, TForm_item& des) const
|
||||
}
|
||||
|
||||
|
||||
TForm_item& TForm_item::find_field(const TString& id) const
|
||||
{
|
||||
if (isdigit(id[0])) // Field in the same section
|
||||
{
|
||||
TForm_item& des = section().find_field(atoi(id));
|
||||
return des;
|
||||
}
|
||||
|
||||
const pagetype pt = (id[1] == '-') ? section().page_type() : char2page(id[1]);
|
||||
const int freccia = id.find("->");
|
||||
CHECKS(freccia > 0, "Non trovo la freccia nel campo ", (const char*)id);
|
||||
TForm_item& des = form().find_field(id[0], pt, atoi(id.mid(freccia+2)));
|
||||
return des;
|
||||
}
|
||||
|
||||
bool TForm_item::do_message(int num)
|
||||
{
|
||||
TToken_string& messaggio = message(num);
|
||||
@ -588,8 +516,7 @@ bool TForm_item::do_message(int num)
|
||||
msg = m;
|
||||
if (*m == '_')
|
||||
{
|
||||
const char* s = form().validate(get(), msg);
|
||||
if (s) set(s);
|
||||
form().validate(*this, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -608,20 +535,9 @@ bool TForm_item::do_message(int num)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isdigit(id[0])) // Field in the same section
|
||||
{
|
||||
TForm_item& des = section().find_field(atoi(id));
|
||||
send_message(cmd, des);
|
||||
}
|
||||
else
|
||||
{
|
||||
const pagetype pt = (id[1] == '-') ? section().page_type() : char2page(id[1]);
|
||||
const int freccia = id.find("->");
|
||||
CHECKS(freccia > 0, "Non trovo la freccia nel messaggio ", (const char*)messaggio);
|
||||
TForm_item& des = form().find_field(id[0], pt, atoi(id.mid(freccia+2)));
|
||||
send_message(cmd, des);
|
||||
}
|
||||
{
|
||||
TForm_item& des = find_field(id);
|
||||
send_message(cmd, des);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -648,16 +564,20 @@ bool TForm_item::update()
|
||||
|
||||
void TForm_item::print_on(TToken_string& row) const
|
||||
{
|
||||
row = "";
|
||||
row.cut(0);
|
||||
row.add(id());
|
||||
row.add(class_name());
|
||||
row.add(_y);
|
||||
row.add(_x);
|
||||
row.add(key());
|
||||
|
||||
const long fu = _group.first_one();
|
||||
if (fu > 0) row.add(fu);
|
||||
else row.add(" ");
|
||||
row.add(key());
|
||||
if (form().edit_level() > 1)
|
||||
{
|
||||
row.add(shown() ? " " : "X");
|
||||
const long fu = _group.first_one();
|
||||
if (fu > 0) row.add(fu);
|
||||
else row.add(" ");
|
||||
}
|
||||
}
|
||||
|
||||
void TForm_item::print_on(TMask& m)
|
||||
@ -766,7 +686,7 @@ public:
|
||||
|
||||
|
||||
TForm_subsection::TForm_subsection(TPrint_section* s, const char* nm) :
|
||||
TForm_item(s), _ssec(&(s->form()), s->page_type(), TRUE), _file_id(-1), _name(nm)
|
||||
TForm_item(s), _ssec(&(s->form()), s->section_type(), s->page_type(), TRUE), _file_id(-1), _name(nm)
|
||||
{}
|
||||
|
||||
|
||||
@ -928,7 +848,7 @@ protected:
|
||||
virtual bool read();
|
||||
virtual bool update();
|
||||
|
||||
const char* get() const;
|
||||
virtual const char* get() const;
|
||||
bool set(const char*);
|
||||
|
||||
const TString& picture() const { return _picture; }
|
||||
@ -984,8 +904,8 @@ bool TForm_string::read_from(const TRectype& prof)
|
||||
|
||||
void TForm_string::print_on(TToken_string& row) const
|
||||
{
|
||||
TForm_item::print_on(row);
|
||||
if (_field.items())
|
||||
TForm_item::print_on(row);
|
||||
if (_field.items() && form().edit_level() > 1)
|
||||
row << '|' << field(0);
|
||||
}
|
||||
|
||||
@ -1091,14 +1011,54 @@ bool TForm_string::update()
|
||||
if (read())
|
||||
{
|
||||
TForm_item::update();
|
||||
if (_picture.not_empty())
|
||||
{
|
||||
TString80 p;
|
||||
p.picture(_picture, get());
|
||||
put_paragraph(p);
|
||||
if (!picture().blank())
|
||||
{
|
||||
TToken_string delim(4, ','); // Stringa con i due delimitatori
|
||||
const char* pic = picture(); // Picture senza delimitatori
|
||||
|
||||
if (pic[0] == '(') // Se ci sono i delimitatori ...
|
||||
{
|
||||
const int bra = picture().find(')');
|
||||
if (bra > 0) // ... cerca la parentesi chiusa
|
||||
{
|
||||
delim = picture().sub(1, bra); // memorizza delimitatori
|
||||
pic += bra+1; // toglili dalla picture
|
||||
}
|
||||
}
|
||||
|
||||
TString80 s;
|
||||
s.picture(pic, get()); // riempi la stringa col valore pitturato
|
||||
|
||||
if (!delim.empty_items()) // Aggiungi delimitatori
|
||||
{
|
||||
char d = delim.get_char(0);
|
||||
if (d > ' ') // Se il primo delimitatore e' valido ...
|
||||
{
|
||||
int spc = -1;
|
||||
for (int i = 0; s[i]; i++)
|
||||
if (s[i] != ' ') // Sostituiscilo all'ultimo spazio iniziale
|
||||
{
|
||||
spc = i-1;
|
||||
break;
|
||||
}
|
||||
if (spc < 0)
|
||||
{
|
||||
s.insert(" ", 0); // ... inseriscilo all'inizio
|
||||
spc = 0;
|
||||
}
|
||||
s[spc] = d;
|
||||
}
|
||||
d = delim.get_char();
|
||||
if (d > ' ') // Se il secondo delimitatore e' valido ...
|
||||
{
|
||||
s.rtrim();
|
||||
s << d; // ... aggiungilo alla fine
|
||||
}
|
||||
}
|
||||
put_paragraph(s);
|
||||
}
|
||||
else
|
||||
put_paragraph(get());
|
||||
else
|
||||
put_paragraph(get()); // Stampa immediata senza picture
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -1114,7 +1074,6 @@ protected: // TForm_string
|
||||
virtual const char* class_name() const { return "NUMERO"; }
|
||||
virtual bool parse_head(TScanner& scanner);
|
||||
virtual bool update();
|
||||
|
||||
virtual int height() const { return 0; }
|
||||
|
||||
protected:
|
||||
@ -1138,15 +1097,62 @@ bool TForm_number::parse_head(TScanner& scanner)
|
||||
bool TForm_number::update()
|
||||
{
|
||||
if (read())
|
||||
{
|
||||
{
|
||||
TForm_item::update();
|
||||
const char* s = get();
|
||||
real n(s);
|
||||
|
||||
real n(get());
|
||||
n.round(decimals());
|
||||
s = n.string(picture());
|
||||
string_at(-1, _y, s);
|
||||
|
||||
if (!picture().blank())
|
||||
{
|
||||
TToken_string delim(4, ','); // Stringa con i due delimitatori
|
||||
const char* pic = picture(); // Picture senza delimitatori
|
||||
|
||||
if (pic[0] == '(') // Se ci sono i delimitatori ...
|
||||
{
|
||||
const int bra = picture().find(')');
|
||||
if (bra > 0) // ... cerca la parentesi chiusa
|
||||
{
|
||||
delim = picture().sub(1, bra); // memorizza delimitatori
|
||||
pic += bra+1; // toglili dalla picture
|
||||
}
|
||||
}
|
||||
|
||||
TString80 s(n.string(pic)); // riempi la stringa col valore pitturato
|
||||
|
||||
if (!delim.empty_items()) // Aggiungi delimitatori
|
||||
{
|
||||
char d = delim.get_char(0);
|
||||
if (d > ' ') // Se il primo delimitatore e' valido ...
|
||||
{
|
||||
int spc = -1;
|
||||
for (int i = 0; s[i]; i++)
|
||||
if (s[i] != ' ') // Sostituiscilo all'ultimo spazio iniziale
|
||||
{
|
||||
spc = i-1;
|
||||
break;
|
||||
}
|
||||
if (spc < 0)
|
||||
{
|
||||
s.insert(" ", 0); // ... inseriscilo all'inizio
|
||||
spc = 0;
|
||||
}
|
||||
s[spc] = d;
|
||||
}
|
||||
d = delim.get_char();
|
||||
if (d > ' ') // Se il secondo delimitatore e' valido ...
|
||||
{
|
||||
s.rtrim();
|
||||
s << d; // ... aggiungilo alla fine
|
||||
}
|
||||
}
|
||||
put_paragraph(s);
|
||||
}
|
||||
else
|
||||
put_paragraph(n.string());
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1429,8 +1435,8 @@ public:
|
||||
|
||||
TMask* TPrint_section::_msk = NULL;
|
||||
|
||||
TPrint_section::TPrint_section(TForm* f, pagetype pt, bool sub)
|
||||
: _height(0), _x(0), _y(0), _form(f), _page_type(pt), _dirty(FALSE),
|
||||
TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub)
|
||||
: _height(0), _x(0), _y(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE),
|
||||
_subsection(sub), _repeat_count(0)
|
||||
{}
|
||||
|
||||
@ -1601,7 +1607,11 @@ bool TPrint_section::edit(const char* title)
|
||||
}
|
||||
|
||||
const word flags = 0x08 | (form().edit_level() > 1 ? 0x06 : 0x00);
|
||||
TArray_sheet a(-1, -1, 0, 0, title, "ID@4|Tipo@8|Riga@R|Col.@R|Gr.@R|Descrizione@40|Campo@16", flags);
|
||||
|
||||
TString80 caption("ID@4|Tipo@8|Riga@R|Col.@R|Descrizione@40|Nascosto");
|
||||
if (form().edit_level() > 1) caption << "|Gr.@R|Campo@16";
|
||||
|
||||
TArray_sheet a(-1, -1, 0, 0, title, caption, flags);
|
||||
|
||||
for (word i = 0; i < fields(); i++)
|
||||
{
|
||||
@ -1727,7 +1737,7 @@ protected:
|
||||
public:
|
||||
void append(const char* s) { _back << s; }
|
||||
|
||||
TGraphic_section(TForm* f, pagetype pt) : TPrint_section(f, pt) {}
|
||||
TGraphic_section(TForm* f, pagetype pt) : TPrint_section(f, 'G', pt) {}
|
||||
virtual ~TGraphic_section() {}
|
||||
};
|
||||
|
||||
@ -1938,7 +1948,7 @@ TPrint_section* TForm::exist(char s, pagetype t, bool create)
|
||||
TPrint_section* sec = (TPrint_section*)a->objptr(t);
|
||||
if (sec == NULL && create)
|
||||
{
|
||||
sec = (s == 'G') ? new TGraphic_section(this, t) : new TPrint_section(this, t);
|
||||
sec = (s == 'G') ? new TGraphic_section(this, t) : new TPrint_section(this, s, t);
|
||||
a->add(sec, t);
|
||||
}
|
||||
|
||||
@ -2146,8 +2156,8 @@ void TForm::print_section(ostream& out, char s) const
|
||||
}
|
||||
}
|
||||
|
||||
const char* TForm::validate(const char*, TToken_string&)
|
||||
{ return NULL; }
|
||||
bool TForm::validate(TForm_item& f, TToken_string&)
|
||||
{ return FALSE; }
|
||||
|
||||
void TForm::print_on(ostream& out) const
|
||||
{
|
||||
|
103
include/form.h
103
include/form.h
@ -1,8 +1,8 @@
|
||||
#ifndef __FORM_H
|
||||
#define __FORM_H
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#ifndef __SCANNER_H
|
||||
#include <scanner.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
@ -10,10 +10,6 @@ class TPrinter;
|
||||
class TPrintrow;
|
||||
#endif
|
||||
|
||||
#ifndef __SCANNER_H
|
||||
class TScanner;
|
||||
#endif
|
||||
|
||||
#ifndef __MASK_H
|
||||
class TMask;
|
||||
#endif
|
||||
@ -33,7 +29,6 @@ enum pagetype { odd_page, even_page, first_page, last_page };
|
||||
class TForm;
|
||||
class TForm_item;
|
||||
|
||||
|
||||
class TPrint_section : public TArray
|
||||
{
|
||||
static TMask* _msk;
|
||||
@ -43,6 +38,7 @@ class TPrint_section : public TArray
|
||||
bool _dirty; // Flag di modifica parametri
|
||||
|
||||
TForm* _form; // Form cui appartiene alla sezione
|
||||
char _sec_type; // H, B, F, G
|
||||
pagetype _page_type; // Tipo della pagina
|
||||
bool _subsection; // e' una sottosezione
|
||||
|
||||
@ -80,13 +76,14 @@ public:
|
||||
void print_on(TRectype& rec);
|
||||
|
||||
bool edit(const char* title);
|
||||
char section_type() const { return _sec_type; }
|
||||
pagetype page_type() const { return _page_type; }
|
||||
|
||||
bool dirty() const { return _dirty; }
|
||||
void set_dirty(bool d = TRUE) { _dirty = d; }
|
||||
|
||||
const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); }
|
||||
TPrint_section(TForm* parent, pagetype pt, bool subsection = FALSE);
|
||||
TPrint_section(TForm* parent, char st, pagetype pt, bool subsection = FALSE);
|
||||
TPrint_section(const TPrint_section& ps) { copy(ps); }
|
||||
virtual ~TPrint_section();
|
||||
};
|
||||
@ -158,7 +155,7 @@ public:
|
||||
TRelation_description& rel_desc() const;
|
||||
|
||||
TCursor* cursor() const { return _cursor; }
|
||||
virtual const char* validate(const char* cur, TToken_string& val);
|
||||
virtual bool validate(TForm_item& fld, TToken_string& val);
|
||||
|
||||
TForm_item& find_field(char sec, pagetype pag, short id) const;
|
||||
|
||||
@ -168,4 +165,92 @@ public:
|
||||
virtual ~TForm();
|
||||
};
|
||||
|
||||
struct TForm_flags : public TObject
|
||||
{
|
||||
bool automagic : 1;
|
||||
bool enabled : 1;
|
||||
bool shown : 1;
|
||||
bool dirty : 1;
|
||||
|
||||
protected:
|
||||
void print_on(ostream& out) const;
|
||||
|
||||
public:
|
||||
TForm_flags();
|
||||
|
||||
void print_on(TMask& m);
|
||||
void read_from(const TMask& m);
|
||||
|
||||
bool update(const char* s);
|
||||
};
|
||||
|
||||
class TForm_item : public TObject
|
||||
{
|
||||
TPrint_section* _section;
|
||||
TForm_flags _flag;
|
||||
TBit_array _group;
|
||||
|
||||
protected:
|
||||
short _id, _x, _y, _width, _height;
|
||||
TString _prompt;
|
||||
TString _desc;
|
||||
TString_array _message;
|
||||
|
||||
virtual void print_on(ostream& out) const;
|
||||
virtual void print_body(ostream& out) const;
|
||||
|
||||
bool shown() const { return _flag.shown; }
|
||||
bool hidden() const { return !_flag.shown; }
|
||||
bool enabled() const { return _flag.enabled; }
|
||||
bool disabled() const { return !_flag.enabled; }
|
||||
bool automagic() const { return _flag.automagic; }
|
||||
|
||||
virtual bool parse_head(TScanner&);
|
||||
virtual bool parse_item(TScanner&);
|
||||
|
||||
TToken_string& message(int m = 0);
|
||||
void send_message(const TString& cmd, TForm_item& dest) const;
|
||||
bool do_message(int m = 0);
|
||||
|
||||
void string_at(int x, int y, const char* s);
|
||||
|
||||
public:
|
||||
short id() const { return _id; }
|
||||
virtual int width() const { return _width; }
|
||||
virtual int height() const { return _height; }
|
||||
|
||||
virtual bool parse(TScanner&);
|
||||
virtual bool update();
|
||||
|
||||
virtual void print_on(TMask& m);
|
||||
virtual void read_from(const TMask& m);
|
||||
|
||||
virtual bool read_from(const TRectype& rform);
|
||||
virtual void print_on(TRectype& rform);
|
||||
|
||||
virtual bool edit(TMask& m);
|
||||
|
||||
virtual const char* get() const { return _prompt; }
|
||||
virtual bool set(const char* s) { _prompt = s; return TRUE; }
|
||||
|
||||
TPrint_section& section() const { return *_section; }
|
||||
TForm& form() const { return _section->form(); }
|
||||
TForm_item& find_field(const TString& id) const;
|
||||
|
||||
void set_dirty(bool d = TRUE) { _flag.dirty = d; }
|
||||
bool dirty() const { return _flag.dirty; }
|
||||
|
||||
bool in_group(byte g) const { return g == 0 || _group[g]; }
|
||||
const TString& key() const { return _desc; }
|
||||
virtual void print_on(TToken_string& row) const;
|
||||
|
||||
virtual void show(bool on = TRUE) { _flag.shown = on; }
|
||||
void hide() { show(FALSE); }
|
||||
virtual void enable(bool on = TRUE);
|
||||
void disable() { enable(FALSE); }
|
||||
|
||||
TForm_item(TPrint_section* section);
|
||||
virtual ~TForm_item() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
103
include/isam.cpp
103
include/isam.cpp
@ -205,11 +205,12 @@ HIDDEN int CBuildKey(RecDes *recd, int numkey, RecType recin, char *key, bool b
|
||||
if (recin[off] == '\0')
|
||||
{
|
||||
memset(key + l, ' ', len);
|
||||
if (build_x_cb && ((f == _intfld) || (f == _longfld) || (f == _wordfld)))
|
||||
if (build_x_cb && ((f == _intfld) || (f == _longfld) || (f == _wordfld) ||
|
||||
(f == _intzerofld) || (f == _longzerofld)))
|
||||
key[l + len - 1] = '0';
|
||||
}
|
||||
else
|
||||
if ((f == _intfld) || (f == _longfld) || (f == _wordfld))
|
||||
if ((f == _intfld) || (f == _longfld) || (f == _wordfld) || (f == _intzerofld) || (f == _longzerofld))
|
||||
{
|
||||
int w = l, j = l + len;
|
||||
while (w < j && key[w] == ' ') w++;
|
||||
@ -2579,42 +2580,58 @@ HIDDEN void __getfieldbuff(byte l, byte t, const char* recin, char *s)
|
||||
*s = '\0';
|
||||
return;
|
||||
}
|
||||
if ((t != _alfafld) && (t != _datefld))
|
||||
{
|
||||
while ((*recin == ' ') && (l))
|
||||
{
|
||||
recin++;
|
||||
l--;
|
||||
|
||||
if (t != _alfafld && t != _datefld)
|
||||
{
|
||||
if (t == _intzerofld || t == _longzerofld)
|
||||
{
|
||||
byte i = 0;
|
||||
for (char* c = (char*)recin; i < l; c++, i++)
|
||||
if (*c == ' ') *c = '0';
|
||||
else break;
|
||||
if (i == l)
|
||||
l = 0;
|
||||
}
|
||||
if ((t != _realfld) && (t != _charfld) &&
|
||||
(t != _intzerofld) && (t != _longzerofld))
|
||||
else
|
||||
{
|
||||
while ((*recin == '0') && (l))
|
||||
while ((*recin == ' ') && (l))
|
||||
{
|
||||
recin++;
|
||||
l--;
|
||||
}
|
||||
}
|
||||
if ((t != _realfld) && (t != _charfld))
|
||||
{
|
||||
while ((*recin == '0') && (l))
|
||||
{
|
||||
recin++;
|
||||
l--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (l)
|
||||
{
|
||||
strncpy(s, recin, l);
|
||||
for (int i = l-1; i >= 0 && s[i] == ' '; i--);
|
||||
l = byte(i+1);
|
||||
}
|
||||
s[l] = '\0';
|
||||
if (t == _datefld && *s)
|
||||
s[l] = '\0';
|
||||
if (*s)
|
||||
{
|
||||
TDate dt(atol(s));
|
||||
strcpy(s, dt.string(full));
|
||||
}
|
||||
if (t == _boolfld && *s)
|
||||
{
|
||||
if (toupper(*s) == 'T' || toupper(*s) == 'Y'
|
||||
|| toupper(*s) == 'S' || toupper(*s) == 'X')
|
||||
strcpy(s,"X");
|
||||
else
|
||||
strcpy(s," ");
|
||||
if (t == _datefld)
|
||||
{
|
||||
const TDate dt(atol(s));
|
||||
strcpy(s, dt.string(full));
|
||||
} else
|
||||
if (t == _boolfld)
|
||||
{
|
||||
const char ok = toupper(*s);
|
||||
if (ok == 'T' || ok == 'Y' || ok == 'S' || ok == 'X')
|
||||
strcpy(s,"X");
|
||||
else
|
||||
strcpy(s," ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2627,43 +2644,53 @@ HIDDEN void __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout)
|
||||
if (recout == NULL) return;
|
||||
|
||||
char s2[256];
|
||||
|
||||
strcpy(s2, s);
|
||||
|
||||
if (t == _datefld)
|
||||
{
|
||||
if (*s2)
|
||||
{
|
||||
TDate dt(s2);
|
||||
const TDate dt(s2);
|
||||
sprintf(s2,"%8s", dt.string(ANSI));
|
||||
}
|
||||
}
|
||||
else
|
||||
if (t == _boolfld)
|
||||
{
|
||||
if (toupper(*s2) == 'T' || toupper(*s2) == 'Y'
|
||||
|| toupper(*s2) == 'S' || toupper(*s2) == 'X')
|
||||
strcpy(s2,"T");
|
||||
{
|
||||
const char ok = toupper(*s2);
|
||||
if (ok == 'T' || ok == 'Y' || ok == 'S' || ok == 'X')
|
||||
strcpy(s2, "T");
|
||||
else
|
||||
strcpy(s2,"F");
|
||||
strcpy(s2, "F");
|
||||
}
|
||||
else
|
||||
if (t == _realfld) setdec(s2, d);
|
||||
|
||||
len = strlen(s2);
|
||||
if (len > l) return ;
|
||||
if ((t == _intfld) ||
|
||||
(t == _longfld) ||
|
||||
(t == _wordfld) ||
|
||||
(t == _realfld))
|
||||
|
||||
if (len > l)
|
||||
{
|
||||
yesnofatal_box("Impossibile scrivere %d caratteri su di un campo di %d", (int)len, (int)l);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((t == _intfld) ||
|
||||
(t == _longfld) ||
|
||||
(t == _wordfld) ||
|
||||
(t == _realfld) ||
|
||||
(t == _intzerofld) ||
|
||||
(t == _longzerofld)
|
||||
)
|
||||
{
|
||||
if (len == 0)
|
||||
{
|
||||
strcpy(s2, "0");
|
||||
len = 1;
|
||||
}
|
||||
}
|
||||
|
||||
const char c = (t == _intzerofld || t == _longzerofld) ? '0' : ' ';
|
||||
i = 0;
|
||||
while (i < l - len - 1) recout[i++] = ' ';
|
||||
while (i < l - len - 1) recout[i++] = c;
|
||||
strncpy(&recout[l - len - 1], s2, len) ;
|
||||
}
|
||||
else
|
||||
|
@ -915,23 +915,23 @@ void TPrinter::read_configuration(const char* parag)
|
||||
|
||||
#endif
|
||||
|
||||
_config = parag;
|
||||
|
||||
if (_config.empty())
|
||||
_config = "Printer";
|
||||
_config = parag; // Inizializza nome configurazione
|
||||
if (_config.empty()) // Se non specificata ...
|
||||
_config = "Printer"; // ... usa configurazione standard
|
||||
|
||||
TConfig* iniptr = NULL;
|
||||
if (_config != "Printer")
|
||||
{ // Usa configurazione speciale
|
||||
if (_config != "Printer") // Cerca configurazione speciale
|
||||
{
|
||||
iniptr = new TConfig(CONFIG_STAMPE, _config);
|
||||
const int what = iniptr->get_int("Type", NULL, -1, -1);
|
||||
if (what < 0)
|
||||
if (what < 0) // Se configurazione annullata ...
|
||||
{
|
||||
delete iniptr; iniptr = NULL;
|
||||
delete iniptr; iniptr = NULL;
|
||||
_config = "Printer"; // ... usa configurazione standard
|
||||
}
|
||||
}
|
||||
if (iniptr == NULL)
|
||||
iniptr = new TConfig(CONFIG_USER, "Printer");
|
||||
iniptr = new TConfig(CONFIG_USER, _config);
|
||||
|
||||
const int what = iniptr->get_int("Type", NULL, -1, 0); // Tipo stampante
|
||||
_curprn = iniptr->get_int("Number", NULL, -1, 0); // Numero stampante corrente
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: relapp.cpp,v 1.62 1995-07-07 14:43:39 guy Exp $
|
||||
// $Id: relapp.cpp,v 1.63 1995-07-19 09:57:17 guy Exp $
|
||||
#include <mailbox.h>
|
||||
#include <sheet.h>
|
||||
#include <urldefid.h>
|
||||
@ -8,32 +8,8 @@
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
#include <windows.h>
|
||||
#include <toolhelp.h>
|
||||
#endif
|
||||
|
||||
HIDDEN bool can_change_firm()
|
||||
{
|
||||
#ifndef DBG
|
||||
static bool can = 2;
|
||||
if (can == 2)
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
|
||||
HTASK ct = GetCurrentTask();
|
||||
TaskFindHandle(&te, ct);
|
||||
TaskFindHandle(&te, te.hTaskParent);
|
||||
can = stricmp(te.szModule, "BA0") == 0;
|
||||
#else
|
||||
can = TRUE;
|
||||
#endif
|
||||
}
|
||||
return can;
|
||||
#else /* DBG */
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Array delle chiavi della maschera di ricerca
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -750,6 +726,12 @@ bool TRelation_application::remove()
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
bool TRelation_application::firm_change_enabled() const
|
||||
{
|
||||
bool ok = TApplication::firm_change_enabled();
|
||||
if (ok) ok = curr_mask().query_mode();
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TRelation_application::main_loop()
|
||||
{
|
||||
@ -765,7 +747,7 @@ bool TRelation_application::main_loop()
|
||||
|
||||
do
|
||||
{
|
||||
const bool change = _mask->query_mode() && can_change_firm();
|
||||
const bool change = firm_change_enabled();
|
||||
// Dis/abilita cambio ditta
|
||||
enable_menu_item(M_FILE_NEW, change);
|
||||
// Dis/abilita cambio parametri
|
||||
|
@ -29,9 +29,6 @@ class TRelation_application : public TApplication
|
||||
TToken_string _fixed;
|
||||
TString _renum_message;
|
||||
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
|
||||
bool filter();
|
||||
bool test_key(byte k, bool err);
|
||||
bool save(bool check_dirty);
|
||||
@ -42,23 +39,29 @@ class TRelation_application : public TApplication
|
||||
void set_limits(byte what = 0x3);
|
||||
void query_insert_mode() { query_mode(TRUE); }
|
||||
void insert_mode(); // Entra in modo inserimento
|
||||
virtual bool main_loop(); // Ciclo principale
|
||||
bool relation_remove(); // Cancella il record corrente
|
||||
TMask_field* get_search_field() const;
|
||||
|
||||
bool autonum(TMask* m, bool rec);
|
||||
bool has_filtered_cursor() const { return filtered() || force_cursor_usage();}
|
||||
|
||||
protected: // TApplication
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
virtual bool firm_change_enabled() const;
|
||||
|
||||
protected:
|
||||
TLocalisamfile& file() const { return get_relation()->lfile(); } // File principale della relazione
|
||||
TRecnotype first() const { return _first;}
|
||||
TRecnotype last() const { return _first;}
|
||||
TMask& curr_mask() const { return *_mask; }
|
||||
const TString& autoins_caller() const { return _autoins_caller;}
|
||||
virtual bool menu(MENU_TAG m);
|
||||
|
||||
virtual bool user_create() pure; // Inizializzazione dati utente
|
||||
virtual bool user_destroy() pure; // Distruzione dati utente
|
||||
virtual bool menu(MENU_TAG m);
|
||||
virtual bool main_loop(); // Ciclo principale
|
||||
|
||||
virtual bool user_create() pure; // Inizializzazione dati utente
|
||||
virtual bool user_destroy() pure; // Distruzione dati utente
|
||||
|
||||
void set_fixed(); // Fissa i campi non modificabili
|
||||
bool search_mode(); // Attiva la maschera di ricerca
|
||||
|
@ -25,7 +25,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
|
||||
|
||||
for(_columns = 0; (g = h.get()) != NULL; _columns++)
|
||||
{
|
||||
CHECK(_columns < MAX_COL, "To many columns in sheet ");
|
||||
CHECK(_columns < MAX_COL, "Too many columns in sheet ");
|
||||
item = g;
|
||||
|
||||
const int et = item.find('@');
|
||||
@ -75,7 +75,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
|
||||
if (dy == 0) dy = 20; // Compute window height
|
||||
|
||||
create(x, y, dx, dy, title, flags, wt, parent);
|
||||
if (wt != W_PLAIN) // If normal sheet add buttons
|
||||
if (wt != W_PLAIN) // If normal sheet add buttons
|
||||
{
|
||||
_visible_rows = rows()- head_on() - 3;
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <applicat.h>
|
||||
#include <checks.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
@ -66,7 +67,7 @@ HIDDEN void set_menu_item(MENU_ITEM& m, TToken_string& tt)
|
||||
m.checkable = flag.find('C') != -1 || flag.find('c') != -1;
|
||||
m.checked = flag.find('c') != -1;
|
||||
m.separator = text == NULL;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TWindow_manager
|
||||
@ -158,19 +159,9 @@ HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on)
|
||||
{
|
||||
switch(m->tag)
|
||||
{
|
||||
case MENU_FILE:
|
||||
if (m->child)
|
||||
xvt_menu_enable(m->child, on);
|
||||
break;
|
||||
case -1: // Separator
|
||||
case M_FILE_NEW:
|
||||
case M_FILE_REVERT:
|
||||
case M_FILE_QUIT:
|
||||
case M_FILE_ABOUT:
|
||||
case M_FILE_PRINT:
|
||||
case M_FILE_PG_SETUP:
|
||||
case (M_FILE+11):
|
||||
break; // Leave them as they are
|
||||
case MENU_FILE: // Leave it as is
|
||||
case -1: // Separator
|
||||
break;
|
||||
default:
|
||||
xvt_menu_set_item_enabled(TASK_WIN, m->tag, on);
|
||||
break;
|
||||
@ -197,10 +188,17 @@ void TWindow_manager::reg(TWindow* m)
|
||||
switch (_current)
|
||||
{
|
||||
case 0 :
|
||||
menu_enable(FALSE);
|
||||
menu_enable(FALSE);
|
||||
{
|
||||
const bool on = main_app().firm_change_enabled();
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_NEW, on);
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_REVERT, on);
|
||||
}
|
||||
break;
|
||||
case 1 :
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_QUIT, FALSE);
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_QUIT, FALSE);
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_NEW, FALSE);
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_REVERT, FALSE);
|
||||
default:
|
||||
_window[_current-1]->deactivate(); break;
|
||||
}
|
||||
@ -228,7 +226,13 @@ void TWindow_manager::unreg(const TWindow* m)
|
||||
else
|
||||
{
|
||||
cur_win()->activate();
|
||||
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_QUIT, _current == 0);
|
||||
|
||||
const bool cf = _current == 0 && main_app().firm_change_enabled();
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_NEW, cf);
|
||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_REVERT, cf);
|
||||
|
||||
xvt_menu_update(TASK_WIN);
|
||||
cur_win()->set_focus();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user