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
|
#if XVT_OS == XVT_OS_WIN
|
||||||
#define STRICT
|
#define STRICT
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <toolhelp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <extcdecl.h>
|
#include <extcdecl.h>
|
||||||
@ -555,15 +556,14 @@ bool TApplication::set_firm(long newfirm)
|
|||||||
_savefirm = 0;
|
_savefirm = 0;
|
||||||
|
|
||||||
WINDOW w = cur_win();
|
WINDOW w = cur_win();
|
||||||
if (w != NULL_WIN)
|
if (w != NULL_WIN)
|
||||||
{
|
{
|
||||||
EVENT e;
|
EVENT e;
|
||||||
e.type = E_COMMAND;
|
e.type = E_COMMAND;
|
||||||
e.v.cmd.tag = M_FILE_NEW;
|
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);
|
xvt_win_dispatch_event(w, &e);
|
||||||
}
|
}
|
||||||
|
|
||||||
on_firm_change();
|
on_firm_change();
|
||||||
on_config_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()
|
void TApplication::on_firm_change()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ protected:
|
|||||||
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
||||||
virtual bool build_firm_data(long cod, bool flagcom = FALSE) { return TRUE;}
|
virtual bool build_firm_data(long cod, bool flagcom = FALSE) { return TRUE;}
|
||||||
virtual bool destroy(); // Rimuove l'applicazione
|
virtual bool destroy(); // Rimuove l'applicazione
|
||||||
|
|
||||||
virtual void on_config_change();
|
virtual void on_config_change();
|
||||||
virtual void on_firm_change();
|
virtual void on_firm_change();
|
||||||
|
|
||||||
@ -69,6 +69,7 @@ public:
|
|||||||
virtual word class_id() const { return CLASS_APPLICATION; }
|
virtual word class_id() const { return CLASS_APPLICATION; }
|
||||||
virtual bool ok() const { return _create_ok; }
|
virtual bool ok() const { return _create_ok; }
|
||||||
virtual void print();
|
virtual void print();
|
||||||
|
virtual bool firm_change_enabled() const;
|
||||||
|
|
||||||
void stop_run(); // Forza chiusura applicazione
|
void stop_run(); // Forza chiusura applicazione
|
||||||
|
|
||||||
|
@ -920,27 +920,24 @@ Utilizzato per il Data Entry.
|
|||||||
char *s; /* stringa per l'output */
|
char *s; /* stringa per l'output */
|
||||||
|
|
||||||
{
|
{
|
||||||
int p, i;
|
int p, i;
|
||||||
unsigned int off;
|
char *s1;
|
||||||
byte len;
|
TrDate d;
|
||||||
char *s1;
|
|
||||||
TrDate d;
|
|
||||||
|
|
||||||
if ((p = findfld(recd, fieldname)) != -1)
|
if ((p = findfld(recd, fieldname)) != -1)
|
||||||
{
|
{
|
||||||
off = recd->Fd[p].RecOff;
|
const int tipo = recd->Fd[p].TypeF;
|
||||||
len = recd->Fd[p].Len;
|
unsigned int off = recd->Fd[p].RecOff;
|
||||||
if ((recd->Fd[p].TypeF != AlfaF) &&
|
byte len = recd->Fd[p].Len;
|
||||||
(recd->Fd[p].TypeF != DateF) &&
|
|
||||||
(recd->Fd[p].TypeF != ZeroF) &&
|
if ((tipo != AlfaF) && (tipo != DateF) && (tipo != ZeroF) && (tipo != EZeroF))
|
||||||
(recd->Fd[p].TypeF != EZeroF))
|
|
||||||
{
|
{
|
||||||
while ((recin[off] == ' ') && (len))
|
while ((recin[off] == ' ') && (len))
|
||||||
{
|
{
|
||||||
off++;
|
off++;
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
if ((recd->Fd[p].TypeF != RealF) && (recd->Fd[p].TypeF != CharF))
|
if ((tipo != RealF) && (tipo != CharF))
|
||||||
{
|
{
|
||||||
while ((recin[off] == '0') && (len))
|
while ((recin[off] == '0') && (len))
|
||||||
{
|
{
|
||||||
@ -950,17 +947,18 @@ Utilizzato per il Data Entry.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if ((recd->Fd[p].TypeF == ZeroF) ||
|
if ((tipo == ZeroF) || (tipo == EZeroF))
|
||||||
(recd->Fd[p].TypeF == EZeroF))
|
|
||||||
{
|
{
|
||||||
int i = 0, pos = 0;
|
char* c = &recin[off];
|
||||||
while (i < len)
|
for (i = 0; i < len; i++, c++)
|
||||||
{
|
{
|
||||||
if (recin[off + i] != '0') break;
|
if (*c == ' ')
|
||||||
i++;
|
*c = '0';
|
||||||
pos = i;
|
else
|
||||||
|
if (*c != '0')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (pos == len)
|
if (i == len)
|
||||||
{
|
{
|
||||||
off += len;
|
off += len;
|
||||||
len = 0;
|
len = 0;
|
||||||
@ -975,7 +973,7 @@ Utilizzato per il Data Entry.
|
|||||||
}
|
}
|
||||||
else strcpy(s, "");
|
else strcpy(s, "");
|
||||||
|
|
||||||
if ((recd->Fd[p].TypeF == RealF))
|
if ((tipo == RealF))
|
||||||
if ((s1 = strchr(s, ',')) != NULL) *s1 = '.';
|
if ((s1 = strchr(s, ',')) != NULL) *s1 = '.';
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -1024,11 +1022,14 @@ Utilizzato per il Data Entry
|
|||||||
|
|
||||||
{
|
{
|
||||||
int p, off, len, l, i;
|
int p, off, len, l, i;
|
||||||
char *s1;
|
|
||||||
char *s2;
|
|
||||||
TrDate d;
|
TrDate d;
|
||||||
|
char *s1;
|
||||||
|
/*
|
||||||
|
char *s2;
|
||||||
s2 = malloc(256);
|
s2 = malloc(256);
|
||||||
|
*/
|
||||||
|
char s2[256];
|
||||||
|
|
||||||
strcpy(s2, s);
|
strcpy(s2, s);
|
||||||
if ((p = findfld(recd, fieldname)) != -1)
|
if ((p = findfld(recd, fieldname)) != -1)
|
||||||
{
|
{
|
||||||
@ -1038,7 +1039,7 @@ Utilizzato per il Data Entry
|
|||||||
l = LENGTH(s2);
|
l = LENGTH(s2);
|
||||||
if (l > len)
|
if (l > len)
|
||||||
{
|
{
|
||||||
free(s2);
|
/* free(s2); */
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
s1 = recout + off ;
|
s1 = recout + off ;
|
||||||
@ -1065,13 +1066,13 @@ Utilizzato per il Data Entry
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
while (l < len) s1[l++] = ' ';
|
while (l < len) s1[l++] = ' ';
|
||||||
free(s2);
|
/* free(s2); */
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(s, "");
|
strcpy(s, "");
|
||||||
free(s2);
|
/* free(s2); */
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ int TExternal_app::run(
|
|||||||
if (utente)
|
if (utente)
|
||||||
{
|
{
|
||||||
tw.maximize();
|
tw.maximize();
|
||||||
tw.activate();
|
tw.activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xvt_statbar_refresh();
|
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
|
// 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()
|
TForm_flags::TForm_flags()
|
||||||
{
|
{
|
||||||
automagic = dirty = FALSE;
|
automagic = dirty = FALSE;
|
||||||
@ -260,74 +241,6 @@ void TForm_flags::read_from(const TMask& m)
|
|||||||
// TForm_item
|
// 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)
|
TForm_item::TForm_item(TPrint_section* section)
|
||||||
: _section(section), _x(-1), _y(-1), _width(0), _height(0), _id(0)
|
: _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)
|
bool TForm_item::do_message(int num)
|
||||||
{
|
{
|
||||||
TToken_string& messaggio = message(num);
|
TToken_string& messaggio = message(num);
|
||||||
@ -588,8 +516,7 @@ bool TForm_item::do_message(int num)
|
|||||||
msg = m;
|
msg = m;
|
||||||
if (*m == '_')
|
if (*m == '_')
|
||||||
{
|
{
|
||||||
const char* s = form().validate(get(), msg);
|
form().validate(*this, msg);
|
||||||
if (s) set(s);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -608,20 +535,9 @@ bool TForm_item::do_message(int num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isdigit(id[0])) // Field in the same section
|
TForm_item& des = find_field(id);
|
||||||
{
|
send_message(cmd, des);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,16 +564,20 @@ bool TForm_item::update()
|
|||||||
|
|
||||||
void TForm_item::print_on(TToken_string& row) const
|
void TForm_item::print_on(TToken_string& row) const
|
||||||
{
|
{
|
||||||
row = "";
|
row.cut(0);
|
||||||
row.add(id());
|
row.add(id());
|
||||||
row.add(class_name());
|
row.add(class_name());
|
||||||
row.add(_y);
|
row.add(_y);
|
||||||
row.add(_x);
|
row.add(_x);
|
||||||
|
row.add(key());
|
||||||
|
|
||||||
const long fu = _group.first_one();
|
if (form().edit_level() > 1)
|
||||||
if (fu > 0) row.add(fu);
|
{
|
||||||
else row.add(" ");
|
row.add(shown() ? " " : "X");
|
||||||
row.add(key());
|
const long fu = _group.first_one();
|
||||||
|
if (fu > 0) row.add(fu);
|
||||||
|
else row.add(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TForm_item::print_on(TMask& m)
|
void TForm_item::print_on(TMask& m)
|
||||||
@ -766,7 +686,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
TForm_subsection::TForm_subsection(TPrint_section* s, const char* nm) :
|
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 read();
|
||||||
virtual bool update();
|
virtual bool update();
|
||||||
|
|
||||||
const char* get() const;
|
virtual const char* get() const;
|
||||||
bool set(const char*);
|
bool set(const char*);
|
||||||
|
|
||||||
const TString& picture() const { return _picture; }
|
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
|
void TForm_string::print_on(TToken_string& row) const
|
||||||
{
|
{
|
||||||
TForm_item::print_on(row);
|
TForm_item::print_on(row);
|
||||||
if (_field.items())
|
if (_field.items() && form().edit_level() > 1)
|
||||||
row << '|' << field(0);
|
row << '|' << field(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1091,14 +1011,54 @@ bool TForm_string::update()
|
|||||||
if (read())
|
if (read())
|
||||||
{
|
{
|
||||||
TForm_item::update();
|
TForm_item::update();
|
||||||
if (_picture.not_empty())
|
if (!picture().blank())
|
||||||
{
|
{
|
||||||
TString80 p;
|
TToken_string delim(4, ','); // Stringa con i due delimitatori
|
||||||
p.picture(_picture, get());
|
const char* pic = picture(); // Picture senza delimitatori
|
||||||
put_paragraph(p);
|
|
||||||
|
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
|
else
|
||||||
put_paragraph(get());
|
put_paragraph(get()); // Stampa immediata senza picture
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1114,7 +1074,6 @@ protected: // TForm_string
|
|||||||
virtual const char* class_name() const { return "NUMERO"; }
|
virtual const char* class_name() const { return "NUMERO"; }
|
||||||
virtual bool parse_head(TScanner& scanner);
|
virtual bool parse_head(TScanner& scanner);
|
||||||
virtual bool update();
|
virtual bool update();
|
||||||
|
|
||||||
virtual int height() const { return 0; }
|
virtual int height() const { return 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -1138,15 +1097,62 @@ bool TForm_number::parse_head(TScanner& scanner)
|
|||||||
bool TForm_number::update()
|
bool TForm_number::update()
|
||||||
{
|
{
|
||||||
if (read())
|
if (read())
|
||||||
{
|
{
|
||||||
TForm_item::update();
|
TForm_item::update();
|
||||||
const char* s = get();
|
|
||||||
real n(s);
|
real n(get());
|
||||||
n.round(decimals());
|
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;
|
TMask* TPrint_section::_msk = NULL;
|
||||||
|
|
||||||
TPrint_section::TPrint_section(TForm* f, pagetype pt, bool sub)
|
TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub)
|
||||||
: _height(0), _x(0), _y(0), _form(f), _page_type(pt), _dirty(FALSE),
|
: _height(0), _x(0), _y(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE),
|
||||||
_subsection(sub), _repeat_count(0)
|
_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);
|
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++)
|
for (word i = 0; i < fields(); i++)
|
||||||
{
|
{
|
||||||
@ -1727,7 +1737,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
void append(const char* s) { _back << s; }
|
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() {}
|
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);
|
TPrint_section* sec = (TPrint_section*)a->objptr(t);
|
||||||
if (sec == NULL && create)
|
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);
|
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&)
|
bool TForm::validate(TForm_item& f, TToken_string&)
|
||||||
{ return NULL; }
|
{ return FALSE; }
|
||||||
|
|
||||||
void TForm::print_on(ostream& out) const
|
void TForm::print_on(ostream& out) const
|
||||||
{
|
{
|
||||||
|
103
include/form.h
103
include/form.h
@ -1,8 +1,8 @@
|
|||||||
#ifndef __FORM_H
|
#ifndef __FORM_H
|
||||||
#define __FORM_H
|
#define __FORM_H
|
||||||
|
|
||||||
#ifndef __STRINGS_H
|
#ifndef __SCANNER_H
|
||||||
#include <strings.h>
|
#include <scanner.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __PRINTER_H
|
#ifndef __PRINTER_H
|
||||||
@ -10,10 +10,6 @@ class TPrinter;
|
|||||||
class TPrintrow;
|
class TPrintrow;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __SCANNER_H
|
|
||||||
class TScanner;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __MASK_H
|
#ifndef __MASK_H
|
||||||
class TMask;
|
class TMask;
|
||||||
#endif
|
#endif
|
||||||
@ -33,7 +29,6 @@ enum pagetype { odd_page, even_page, first_page, last_page };
|
|||||||
class TForm;
|
class TForm;
|
||||||
class TForm_item;
|
class TForm_item;
|
||||||
|
|
||||||
|
|
||||||
class TPrint_section : public TArray
|
class TPrint_section : public TArray
|
||||||
{
|
{
|
||||||
static TMask* _msk;
|
static TMask* _msk;
|
||||||
@ -43,6 +38,7 @@ class TPrint_section : public TArray
|
|||||||
bool _dirty; // Flag di modifica parametri
|
bool _dirty; // Flag di modifica parametri
|
||||||
|
|
||||||
TForm* _form; // Form cui appartiene alla sezione
|
TForm* _form; // Form cui appartiene alla sezione
|
||||||
|
char _sec_type; // H, B, F, G
|
||||||
pagetype _page_type; // Tipo della pagina
|
pagetype _page_type; // Tipo della pagina
|
||||||
bool _subsection; // e' una sottosezione
|
bool _subsection; // e' una sottosezione
|
||||||
|
|
||||||
@ -80,13 +76,14 @@ public:
|
|||||||
void print_on(TRectype& rec);
|
void print_on(TRectype& rec);
|
||||||
|
|
||||||
bool edit(const char* title);
|
bool edit(const char* title);
|
||||||
|
char section_type() const { return _sec_type; }
|
||||||
pagetype page_type() const { return _page_type; }
|
pagetype page_type() const { return _page_type; }
|
||||||
|
|
||||||
bool dirty() const { return _dirty; }
|
bool dirty() const { return _dirty; }
|
||||||
void set_dirty(bool d = TRUE) { _dirty = d; }
|
void set_dirty(bool d = TRUE) { _dirty = d; }
|
||||||
|
|
||||||
const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); }
|
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); }
|
TPrint_section(const TPrint_section& ps) { copy(ps); }
|
||||||
virtual ~TPrint_section();
|
virtual ~TPrint_section();
|
||||||
};
|
};
|
||||||
@ -158,7 +155,7 @@ public:
|
|||||||
TRelation_description& rel_desc() const;
|
TRelation_description& rel_desc() const;
|
||||||
|
|
||||||
TCursor* cursor() const { return _cursor; }
|
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;
|
TForm_item& find_field(char sec, pagetype pag, short id) const;
|
||||||
|
|
||||||
@ -168,4 +165,92 @@ public:
|
|||||||
virtual ~TForm();
|
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
|
#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')
|
if (recin[off] == '\0')
|
||||||
{
|
{
|
||||||
memset(key + l, ' ', len);
|
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';
|
key[l + len - 1] = '0';
|
||||||
}
|
}
|
||||||
else
|
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;
|
int w = l, j = l + len;
|
||||||
while (w < j && key[w] == ' ') w++;
|
while (w < j && key[w] == ' ') w++;
|
||||||
@ -2579,42 +2580,58 @@ HIDDEN void __getfieldbuff(byte l, byte t, const char* recin, char *s)
|
|||||||
*s = '\0';
|
*s = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((t != _alfafld) && (t != _datefld))
|
|
||||||
{
|
if (t != _alfafld && t != _datefld)
|
||||||
while ((*recin == ' ') && (l))
|
{
|
||||||
{
|
if (t == _intzerofld || t == _longzerofld)
|
||||||
recin++;
|
{
|
||||||
l--;
|
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) &&
|
else
|
||||||
(t != _intzerofld) && (t != _longzerofld))
|
|
||||||
{
|
{
|
||||||
while ((*recin == '0') && (l))
|
while ((*recin == ' ') && (l))
|
||||||
{
|
{
|
||||||
recin++;
|
recin++;
|
||||||
l--;
|
l--;
|
||||||
}
|
}
|
||||||
}
|
if ((t != _realfld) && (t != _charfld))
|
||||||
|
{
|
||||||
|
while ((*recin == '0') && (l))
|
||||||
|
{
|
||||||
|
recin++;
|
||||||
|
l--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l)
|
if (l)
|
||||||
{
|
{
|
||||||
strncpy(s, recin, l);
|
strncpy(s, recin, l);
|
||||||
for (int i = l-1; i >= 0 && s[i] == ' '; i--);
|
for (int i = l-1; i >= 0 && s[i] == ' '; i--);
|
||||||
l = byte(i+1);
|
l = byte(i+1);
|
||||||
}
|
}
|
||||||
s[l] = '\0';
|
s[l] = '\0';
|
||||||
if (t == _datefld && *s)
|
if (*s)
|
||||||
{
|
{
|
||||||
TDate dt(atol(s));
|
if (t == _datefld)
|
||||||
strcpy(s, dt.string(full));
|
{
|
||||||
}
|
const TDate dt(atol(s));
|
||||||
if (t == _boolfld && *s)
|
strcpy(s, dt.string(full));
|
||||||
{
|
} else
|
||||||
if (toupper(*s) == 'T' || toupper(*s) == 'Y'
|
if (t == _boolfld)
|
||||||
|| toupper(*s) == 'S' || toupper(*s) == 'X')
|
{
|
||||||
strcpy(s,"X");
|
const char ok = toupper(*s);
|
||||||
else
|
if (ok == 'T' || ok == 'Y' || ok == 'S' || ok == 'X')
|
||||||
strcpy(s," ");
|
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;
|
if (recout == NULL) return;
|
||||||
|
|
||||||
char s2[256];
|
char s2[256];
|
||||||
|
|
||||||
strcpy(s2, s);
|
strcpy(s2, s);
|
||||||
|
|
||||||
if (t == _datefld)
|
if (t == _datefld)
|
||||||
{
|
{
|
||||||
if (*s2)
|
if (*s2)
|
||||||
{
|
{
|
||||||
TDate dt(s2);
|
const TDate dt(s2);
|
||||||
sprintf(s2,"%8s", dt.string(ANSI));
|
sprintf(s2,"%8s", dt.string(ANSI));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (t == _boolfld)
|
if (t == _boolfld)
|
||||||
{
|
{
|
||||||
if (toupper(*s2) == 'T' || toupper(*s2) == 'Y'
|
const char ok = toupper(*s2);
|
||||||
|| toupper(*s2) == 'S' || toupper(*s2) == 'X')
|
if (ok == 'T' || ok == 'Y' || ok == 'S' || ok == 'X')
|
||||||
strcpy(s2,"T");
|
strcpy(s2, "T");
|
||||||
else
|
else
|
||||||
strcpy(s2,"F");
|
strcpy(s2, "F");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (t == _realfld) setdec(s2, d);
|
if (t == _realfld) setdec(s2, d);
|
||||||
|
|
||||||
len = strlen(s2);
|
len = strlen(s2);
|
||||||
if (len > l) return ;
|
|
||||||
if ((t == _intfld) ||
|
if (len > l)
|
||||||
(t == _longfld) ||
|
{
|
||||||
(t == _wordfld) ||
|
yesnofatal_box("Impossibile scrivere %d caratteri su di un campo di %d", (int)len, (int)l);
|
||||||
(t == _realfld))
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((t == _intfld) ||
|
||||||
|
(t == _longfld) ||
|
||||||
|
(t == _wordfld) ||
|
||||||
|
(t == _realfld) ||
|
||||||
|
(t == _intzerofld) ||
|
||||||
|
(t == _longzerofld)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
{
|
{
|
||||||
strcpy(s2, "0");
|
strcpy(s2, "0");
|
||||||
len = 1;
|
len = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char c = (t == _intzerofld || t == _longzerofld) ? '0' : ' ';
|
||||||
i = 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) ;
|
strncpy(&recout[l - len - 1], s2, len) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -915,23 +915,23 @@ void TPrinter::read_configuration(const char* parag)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_config = parag;
|
_config = parag; // Inizializza nome configurazione
|
||||||
|
if (_config.empty()) // Se non specificata ...
|
||||||
if (_config.empty())
|
_config = "Printer"; // ... usa configurazione standard
|
||||||
_config = "Printer";
|
|
||||||
|
|
||||||
TConfig* iniptr = NULL;
|
TConfig* iniptr = NULL;
|
||||||
if (_config != "Printer")
|
if (_config != "Printer") // Cerca configurazione speciale
|
||||||
{ // Usa configurazione speciale
|
{
|
||||||
iniptr = new TConfig(CONFIG_STAMPE, _config);
|
iniptr = new TConfig(CONFIG_STAMPE, _config);
|
||||||
const int what = iniptr->get_int("Type", NULL, -1, -1);
|
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)
|
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
|
const int what = iniptr->get_int("Type", NULL, -1, 0); // Tipo stampante
|
||||||
_curprn = iniptr->get_int("Number", NULL, -1, 0); // Numero stampante corrente
|
_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 <mailbox.h>
|
||||||
#include <sheet.h>
|
#include <sheet.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
@ -8,32 +8,8 @@
|
|||||||
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
#if XVT_OS == XVT_OS_WIN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <toolhelp.h>
|
|
||||||
#endif
|
#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
|
// Array delle chiavi della maschera di ricerca
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -750,6 +726,12 @@ bool TRelation_application::remove()
|
|||||||
return err == NOERR;
|
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()
|
bool TRelation_application::main_loop()
|
||||||
{
|
{
|
||||||
@ -765,7 +747,7 @@ bool TRelation_application::main_loop()
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const bool change = _mask->query_mode() && can_change_firm();
|
const bool change = firm_change_enabled();
|
||||||
// Dis/abilita cambio ditta
|
// Dis/abilita cambio ditta
|
||||||
enable_menu_item(M_FILE_NEW, change);
|
enable_menu_item(M_FILE_NEW, change);
|
||||||
// Dis/abilita cambio parametri
|
// Dis/abilita cambio parametri
|
||||||
|
@ -29,9 +29,6 @@ class TRelation_application : public TApplication
|
|||||||
TToken_string _fixed;
|
TToken_string _fixed;
|
||||||
TString _renum_message;
|
TString _renum_message;
|
||||||
|
|
||||||
virtual bool create();
|
|
||||||
virtual bool destroy();
|
|
||||||
|
|
||||||
bool filter();
|
bool filter();
|
||||||
bool test_key(byte k, bool err);
|
bool test_key(byte k, bool err);
|
||||||
bool save(bool check_dirty);
|
bool save(bool check_dirty);
|
||||||
@ -42,23 +39,29 @@ class TRelation_application : public TApplication
|
|||||||
void set_limits(byte what = 0x3);
|
void set_limits(byte what = 0x3);
|
||||||
void query_insert_mode() { query_mode(TRUE); }
|
void query_insert_mode() { query_mode(TRUE); }
|
||||||
void insert_mode(); // Entra in modo inserimento
|
void insert_mode(); // Entra in modo inserimento
|
||||||
virtual bool main_loop(); // Ciclo principale
|
|
||||||
bool relation_remove(); // Cancella il record corrente
|
bool relation_remove(); // Cancella il record corrente
|
||||||
TMask_field* get_search_field() const;
|
TMask_field* get_search_field() const;
|
||||||
|
|
||||||
bool autonum(TMask* m, bool rec);
|
bool autonum(TMask* m, bool rec);
|
||||||
bool has_filtered_cursor() const { return filtered() || force_cursor_usage();}
|
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:
|
protected:
|
||||||
TLocalisamfile& file() const { return get_relation()->lfile(); } // File principale della relazione
|
TLocalisamfile& file() const { return get_relation()->lfile(); } // File principale della relazione
|
||||||
TRecnotype first() const { return _first;}
|
TRecnotype first() const { return _first;}
|
||||||
TRecnotype last() const { return _first;}
|
TRecnotype last() const { return _first;}
|
||||||
TMask& curr_mask() const { return *_mask; }
|
TMask& curr_mask() const { return *_mask; }
|
||||||
const TString& autoins_caller() const { return _autoins_caller;}
|
const TString& autoins_caller() const { return _autoins_caller;}
|
||||||
virtual bool menu(MENU_TAG m);
|
|
||||||
|
|
||||||
virtual bool user_create() pure; // Inizializzazione dati utente
|
virtual bool menu(MENU_TAG m);
|
||||||
virtual bool user_destroy() pure; // Distruzione dati utente
|
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
|
void set_fixed(); // Fissa i campi non modificabili
|
||||||
bool search_mode(); // Attiva la maschera di ricerca
|
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++)
|
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;
|
item = g;
|
||||||
|
|
||||||
const int et = item.find('@');
|
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
|
if (dy == 0) dy = 20; // Compute window height
|
||||||
|
|
||||||
create(x, y, dx, dy, title, flags, wt, parent);
|
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;
|
_visible_rows = rows()- head_on() - 3;
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <applicat.h>
|
||||||
#include <checks.h>
|
#include <checks.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
#include <utility.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.checkable = flag.find('C') != -1 || flag.find('c') != -1;
|
||||||
m.checked = flag.find('c') != -1;
|
m.checked = flag.find('c') != -1;
|
||||||
m.separator = text == NULL;
|
m.separator = text == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TWindow_manager
|
// TWindow_manager
|
||||||
@ -158,19 +159,9 @@ HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on)
|
|||||||
{
|
{
|
||||||
switch(m->tag)
|
switch(m->tag)
|
||||||
{
|
{
|
||||||
case MENU_FILE:
|
case MENU_FILE: // Leave it as is
|
||||||
if (m->child)
|
case -1: // Separator
|
||||||
xvt_menu_enable(m->child, on);
|
break;
|
||||||
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
|
|
||||||
default:
|
default:
|
||||||
xvt_menu_set_item_enabled(TASK_WIN, m->tag, on);
|
xvt_menu_set_item_enabled(TASK_WIN, m->tag, on);
|
||||||
break;
|
break;
|
||||||
@ -197,10 +188,17 @@ void TWindow_manager::reg(TWindow* m)
|
|||||||
switch (_current)
|
switch (_current)
|
||||||
{
|
{
|
||||||
case 0 :
|
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;
|
break;
|
||||||
case 1 :
|
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:
|
default:
|
||||||
_window[_current-1]->deactivate(); break;
|
_window[_current-1]->deactivate(); break;
|
||||||
}
|
}
|
||||||
@ -228,7 +226,13 @@ void TWindow_manager::unreg(const TWindow* m)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cur_win()->activate();
|
cur_win()->activate();
|
||||||
|
|
||||||
xvt_menu_set_item_enabled(TASK_WIN, M_FILE_QUIT, _current == 0);
|
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);
|
xvt_menu_update(TASK_WIN);
|
||||||
cur_win()->set_focus();
|
cur_win()->set_focus();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user