1996-11-26 09:34:11 +00:00
|
|
|
#include "../ba/baformed.h"
|
|
|
|
|
1996-01-03 14:40:13 +00:00
|
|
|
#ifndef __PROGIND_H
|
|
|
|
#include <progind.h>
|
|
|
|
#endif
|
1996-11-26 09:34:11 +00:00
|
|
|
|
|
|
|
#ifndef __PRINTER_H
|
|
|
|
#include <printer.h>
|
|
|
|
#endif
|
|
|
|
|
1997-05-22 08:53:34 +00:00
|
|
|
#include <mailbox.h>
|
|
|
|
|
1995-12-18 15:37:20 +00:00
|
|
|
#include "sc3.h"
|
|
|
|
#include "sc3100a.h"
|
|
|
|
#include "sc3100b.h"
|
|
|
|
#include "sc3100c.h"
|
|
|
|
#include "sc21pec.h"
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
// serve per ricalcolare le posizioni //
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name_1[80]; // Fontname old
|
|
|
|
char name_2[80]; // Fontname new
|
|
|
|
int size_1; // size (height) of old font
|
|
|
|
int size_2; // size (height) of new font
|
|
|
|
double ratio; // ratio (width_old_font/width_new_font)
|
|
|
|
} s_data;
|
|
|
|
|
1996-01-13 11:00:25 +00:00
|
|
|
class TForm_EC : public TForm
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual void pre_edit_checks(TMask& m, TPrint_section* sec);
|
|
|
|
virtual bool post_edit_checks(TMask& m, TPrint_section* sec);
|
1997-05-22 08:53:34 +00:00
|
|
|
|
1996-01-13 11:00:25 +00:00
|
|
|
public:
|
|
|
|
virtual const char* section_mask() { return "sc3100s" ;}
|
1996-01-23 12:04:36 +00:00
|
|
|
virtual void change_number_format(int w, int dec, const char* p);
|
1996-01-13 11:00:25 +00:00
|
|
|
TForm_EC (): TForm() {};
|
|
|
|
TForm_EC (const char* form, const char * code = "", int editlevel = 0, const char* desc = "")
|
|
|
|
: TForm(form,code,editlevel,desc) {};
|
|
|
|
virtual ~TForm_EC() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
void TForm_EC::pre_edit_checks(TMask& m, TPrint_section* sec)
|
|
|
|
{
|
|
|
|
// Se sta editando il body abilita i primi 4, se sta editando il footer abilita l'ultimo
|
|
|
|
if (sec->section_type() == 'B')
|
|
|
|
m.enable(-2);
|
|
|
|
if (sec->section_type() == 'F')
|
|
|
|
m.enable(-3);
|
|
|
|
CHECK(exist('H', last_page),"La testata dell'ultima pagina non esiste!");
|
|
|
|
m.set(F_DES1,find_field('H',last_page,PEC_SALDO).prompt());
|
|
|
|
m.set(F_DES2,find_field('H',last_page,PEC_RITENUTE).prompt());
|
|
|
|
m.set(F_DES3,find_field('H',last_page,PEC_ABBUONI).prompt());
|
|
|
|
m.set(F_DES4,find_field('H',last_page,PEC_DIFFCAM).prompt());
|
|
|
|
m.set(F_DES5,find_field('H',last_page,PEC_RIPORTO).prompt());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TForm_EC::post_edit_checks(TMask& m, TPrint_section* sec)
|
|
|
|
{
|
|
|
|
CHECK(exist('H', last_page),"La testata dell'ultima pagina non esiste!");
|
|
|
|
section('H',last_page).set_dirty();
|
|
|
|
TForm_item& saldo = find_field('H',last_page,PEC_SALDO);
|
|
|
|
TForm_item& abbuoni = find_field('H',last_page,PEC_RITENUTE);
|
|
|
|
TForm_item& diffcam = find_field('H',last_page,PEC_ABBUONI);
|
|
|
|
TForm_item& ritenute = find_field('H',last_page,PEC_DIFFCAM);
|
|
|
|
TForm_item& riporto = find_field('H',last_page,PEC_RIPORTO);
|
|
|
|
saldo.set_prompt(m.get(F_DES1));
|
|
|
|
saldo.set_dirty();
|
|
|
|
abbuoni.set_prompt(m.get(F_DES2));
|
|
|
|
abbuoni.set_dirty();
|
|
|
|
diffcam.set_prompt(m.get(F_DES3));
|
|
|
|
diffcam.set_dirty();
|
|
|
|
ritenute.set_prompt(m.get(F_DES4));
|
|
|
|
ritenute.set_dirty();
|
|
|
|
riporto.set_prompt(m.get(F_DES5));
|
|
|
|
riporto.set_dirty();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-01-23 12:04:36 +00:00
|
|
|
void TForm_EC::change_number_format(int w, int dec, const char* p)
|
|
|
|
{
|
1997-05-22 08:53:34 +00:00
|
|
|
const char* const secs = "FB";
|
|
|
|
const char* const ptyp = "LOEF";
|
1996-01-23 12:04:36 +00:00
|
|
|
TPrint_section* ps;
|
|
|
|
|
|
|
|
for (int sc = 0; sc < 4; sc++)
|
|
|
|
for (int pt = 0; pt < 4; pt++)
|
|
|
|
if ((ps = exist(secs[sc], char2page(ptyp[pt]), FALSE)) != NULL)
|
|
|
|
ps_change_number_format(*ps, w, dec, p);
|
|
|
|
}
|
|
|
|
|
1995-12-23 12:16:43 +00:00
|
|
|
class TForm_EC_editor : public TForm_editor
|
|
|
|
{
|
1996-01-03 14:40:13 +00:00
|
|
|
s_data _prm;
|
|
|
|
TMask * _msk; // maschera di selezione sezione
|
1997-05-22 08:53:34 +00:00
|
|
|
|
1995-12-23 12:16:43 +00:00
|
|
|
protected:
|
|
|
|
static bool cpy_handler(TMask_field& f, KEY k);
|
|
|
|
static bool font_handler(TMask_field& f, KEY k);
|
1996-01-05 18:48:17 +00:00
|
|
|
static bool code_handler(TMask_field& f, KEY k);
|
|
|
|
static bool lng_handler(TMask_field& f, KEY k);
|
|
|
|
static bool ccodes_handler(TMask_field& f, KEY k);
|
|
|
|
static bool clngs_handler(TMask_field& f, KEY k);
|
1996-04-22 10:22:30 +00:00
|
|
|
bool load_fonts();
|
1996-01-03 14:40:13 +00:00
|
|
|
void change_pos(char sc, pagetype pt);
|
1995-12-23 12:16:43 +00:00
|
|
|
bool recalculate_positions(const char* name, int size);
|
1996-01-13 11:00:25 +00:00
|
|
|
void remove_temp_items(char sec, pagetype p);
|
|
|
|
void put_examples(char sec, pagetype p);
|
|
|
|
void remove_examples(char sec, pagetype p);
|
1996-01-03 14:40:13 +00:00
|
|
|
void hook_footer_to_body(TPrint_section* f, TPrint_section* b);
|
|
|
|
void unhook_footer(TPrint_section* f);
|
1996-01-09 11:39:10 +00:00
|
|
|
void hide_body_items(TPrint_section* b);
|
|
|
|
void show_body_items(TPrint_section* b);
|
1996-01-05 18:48:17 +00:00
|
|
|
void remove_form(TLocalisamfile& frm, TLocalisamfile& rfr,const TString& t,const TString& c);
|
1997-05-22 08:53:34 +00:00
|
|
|
|
1995-12-23 12:16:43 +00:00
|
|
|
virtual const char* selection_mask() const { return "sc3100a"; }
|
|
|
|
virtual bool ask_profile();
|
|
|
|
virtual bool edit(char s, pagetype p);
|
1996-01-03 14:40:13 +00:00
|
|
|
virtual void print();
|
1997-05-22 08:53:34 +00:00
|
|
|
|
|
|
|
bool check_mailbox(TMask& m);
|
|
|
|
|
1995-12-23 12:16:43 +00:00
|
|
|
public:
|
1997-05-22 08:53:34 +00:00
|
|
|
|
1996-01-03 14:40:13 +00:00
|
|
|
TForm_EC_editor() {_msk = NULL;}
|
|
|
|
virtual ~TForm_EC_editor() {}
|
1995-12-23 12:16:43 +00:00
|
|
|
};
|
|
|
|
|
1996-01-03 14:40:13 +00:00
|
|
|
inline TForm_EC_editor& app() { return (TForm_EC_editor&) main_app();}
|
|
|
|
|
1995-12-18 15:37:20 +00:00
|
|
|
BOOLEAN XVT_CALLCONV1 wprms (long data)
|
|
|
|
{
|
|
|
|
s_data* st =(s_data*)data;
|
|
|
|
WINDOW prwin = xvt_print_create_win(printer().get_printrcd(),"");
|
|
|
|
long width_old,width_new;
|
|
|
|
TString spc(100);
|
|
|
|
spc.fill('m');
|
|
|
|
xvt_set_font(prwin,st->name_1, XVT_FS_NONE, st->size_1);
|
|
|
|
width_old = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 100);
|
|
|
|
xvt_set_font(prwin,st->name_2, XVT_FS_NONE, st->size_2);
|
|
|
|
width_new = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 100);
|
|
|
|
st->ratio = (double)width_old / (double)width_new;
|
|
|
|
xvt_vobj_destroy(prwin);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1996-01-05 18:48:17 +00:00
|
|
|
bool TForm_EC_editor::ccodes_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
if (k==K_TAB)
|
|
|
|
{
|
|
|
|
TString base(m.get(F_CBASE));
|
|
|
|
TString code(f.get());
|
|
|
|
code << m.get(F_CCODELS);
|
|
|
|
TLocalisamfile frm(LF_FORM);
|
|
|
|
frm.zero();
|
|
|
|
frm.put("TIPOPROF",base);
|
|
|
|
frm.put("CODPROF",code);
|
|
|
|
if (frm.read(_isequal)== NOERR)
|
|
|
|
m.set(F_CDESCS,frm.get("DESC"));
|
1996-01-09 11:39:10 +00:00
|
|
|
else
|
|
|
|
m.reset(F_CDESCS);
|
1996-01-05 18:48:17 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TForm_EC_editor::clngs_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
if (key==K_TAB)
|
|
|
|
{
|
1997-12-30 14:11:31 +00:00
|
|
|
TMask& m = f.mask();
|
1996-01-05 18:48:17 +00:00
|
|
|
TString base(m.get(F_CBASE));
|
|
|
|
TString code(m.get(F_CCODES));
|
|
|
|
code << f.get();
|
|
|
|
TLocalisamfile frm(LF_FORM);
|
|
|
|
frm.zero();
|
|
|
|
frm.put("TIPOPROF",base);
|
|
|
|
frm.put("CODPROF",code);
|
|
|
|
if (frm.read(_isequal)== NOERR)
|
|
|
|
m.set(F_CDESCS,frm.get("DESC"));
|
1996-01-09 11:39:10 +00:00
|
|
|
else
|
|
|
|
m.reset(F_CDESCS);
|
1996-01-05 18:48:17 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-12-18 15:37:20 +00:00
|
|
|
bool TForm_EC_editor::cpy_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k==K_SPACE)
|
|
|
|
{
|
|
|
|
TLocalisamfile frm(LF_FORM),rfr(LF_RFORM);
|
|
|
|
TMask mm("sc3100b");
|
1996-01-05 18:48:17 +00:00
|
|
|
mm.set_handler(F_CCODES,ccodes_handler);
|
1996-04-12 08:23:03 +00:00
|
|
|
mm.set_handler(F_CCODELS,clngs_handler);
|
|
|
|
const TMask & m = f.mask();
|
|
|
|
mm.set(F_CCODED, m.get(F_CODE));
|
|
|
|
mm.set(F_CCODELD, m.get(F_CODEL));
|
|
|
|
mm.set(F_CDESCD, m.get(F_DESC));
|
1996-01-23 12:04:36 +00:00
|
|
|
mm.set(F_CBASE,BASE_EC_PROFILE);
|
1996-01-05 18:48:17 +00:00
|
|
|
while (mm.run() == K_ENTER) // Prende in input il nome del profilo sorgente
|
1995-12-18 15:37:20 +00:00
|
|
|
{
|
|
|
|
long scode = mm.get_long(F_CCODES);
|
|
|
|
long dcode = mm.get_long(F_CCODED);
|
|
|
|
char slng = mm.get(F_CCODELS)[0];
|
|
|
|
char dlng = mm.get(F_CCODELD)[0];
|
|
|
|
TString form = mm.get(F_CBASE);
|
|
|
|
TString scod,dcod;
|
|
|
|
scod.format("%04ld%c",scode,slng); // Codice profilo sorgente
|
|
|
|
if (scode == 0) scod = "";
|
|
|
|
dcod.format("%04ld%c",dcode,dlng); // Codice profilo destinazione
|
|
|
|
frm.zero();
|
|
|
|
frm.put("TIPOPROF",form);frm.put("CODPROF",dcod);
|
|
|
|
if (frm.read()==NOERR)
|
|
|
|
{
|
|
|
|
error_box("Il profilo specificato come destinazione e' gia' esistente.");
|
1996-01-05 18:48:17 +00:00
|
|
|
continue;
|
1995-12-18 15:37:20 +00:00
|
|
|
}
|
|
|
|
//Effettua la copia dei record.
|
|
|
|
frm.zero(); frm.put("TIPOPROF",form); // Questo vale per tutti
|
|
|
|
frm.put("CODPROF",scod); //Profilo sorgente...
|
|
|
|
if (frm.read()==NOERR)
|
|
|
|
{
|
|
|
|
TLocalisamfile rfr_to_write(LF_RFORM);
|
|
|
|
frm.put("CODPROF",dcod); //Cambia il codice del profilo con quello di destinazione e lo scrive
|
|
|
|
frm.put("DESC",mm.get(F_CDESCD)); // Mette la descrizione
|
1996-09-13 07:59:44 +00:00
|
|
|
if (scod.empty()) // Se la copia avviene dal profilo standard...
|
|
|
|
{
|
|
|
|
frm.put("GRID","+++++++++-|"); // copia anche i parametri di default
|
|
|
|
frm.put("FONTNAME","Courier New");
|
|
|
|
frm.put("FONTSIZE",7);
|
|
|
|
}
|
1995-12-18 15:37:20 +00:00
|
|
|
if (frm.write() != NOERR)
|
|
|
|
frm.rewrite();
|
|
|
|
if (frm.status() != NOERR)
|
|
|
|
{
|
|
|
|
error_box("Errore %d in scrittura testata profilo.",frm.status());
|
1996-01-05 18:48:17 +00:00
|
|
|
break;
|
1996-01-03 14:40:13 +00:00
|
|
|
}
|
|
|
|
TProgind pi(50,"Copia in corso...",FALSE,FALSE,10);
|
1995-12-18 15:37:20 +00:00
|
|
|
rfr.zero();rfr.put("TIPOPROF",form);
|
|
|
|
rfr.put("CODPROF",scod); //Profilo sorgente
|
|
|
|
rfr.read(_isgteq);
|
|
|
|
while ( rfr.get("CODPROF") == scod && rfr_to_write.good() && !rfr.eof())
|
|
|
|
{
|
|
|
|
rfr_to_write.curr() = rfr.curr();
|
|
|
|
rfr_to_write.put("CODPROF",dcod); // cambia il codice del profilo con quello di destinazione
|
|
|
|
if (rfr_to_write.write() != NOERR)
|
|
|
|
rfr_to_write.rewrite();
|
|
|
|
rfr.read(_isgreat);
|
1996-01-03 14:40:13 +00:00
|
|
|
}
|
|
|
|
pi.cancel();
|
1995-12-18 15:37:20 +00:00
|
|
|
if (rfr_to_write.status() != NOERR)
|
|
|
|
{
|
|
|
|
error_box("Errore %d in scrittura righe profilo.",rfr_to_write.status());
|
1996-01-05 18:48:17 +00:00
|
|
|
break ;
|
1995-12-18 15:37:20 +00:00
|
|
|
}
|
1996-01-13 11:00:25 +00:00
|
|
|
break;
|
1995-12-18 15:37:20 +00:00
|
|
|
} else
|
|
|
|
error_box("Non esiste il profilo sorgente specificato.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-01-05 18:48:17 +00:00
|
|
|
|
|
|
|
bool TForm_EC_editor::code_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
1997-12-30 14:11:31 +00:00
|
|
|
if (key==K_TAB && !f.empty())
|
1996-01-05 18:48:17 +00:00
|
|
|
{
|
1997-12-30 14:11:31 +00:00
|
|
|
TMask& m = f.mask();
|
1996-01-05 18:48:17 +00:00
|
|
|
TString base(m.get(F_BASE));
|
|
|
|
TString code(f.get());
|
|
|
|
code << m.get(F_CODEL);
|
|
|
|
TLocalisamfile frm(LF_FORM);
|
|
|
|
frm.zero();
|
|
|
|
frm.put("TIPOPROF",base);
|
|
|
|
frm.put("CODPROF",code);
|
|
|
|
if (frm.read(_isequal)== NOERR)
|
|
|
|
m.set(F_DESC,frm.get("DESC"));
|
1996-01-09 11:39:10 +00:00
|
|
|
else
|
|
|
|
m.reset(F_DESC);
|
1996-01-05 18:48:17 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TForm_EC_editor::lng_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
1996-01-23 12:04:36 +00:00
|
|
|
TMask& m = f.mask();
|
|
|
|
if (key==K_TAB && m.get(F_CODE).not_empty())
|
1996-01-05 18:48:17 +00:00
|
|
|
{
|
|
|
|
TString base(m.get(F_BASE));
|
|
|
|
TString code(m.get(F_CODE));
|
|
|
|
code << f.get();
|
|
|
|
TLocalisamfile frm(LF_FORM);
|
|
|
|
frm.zero();
|
|
|
|
frm.put("TIPOPROF",base);
|
|
|
|
frm.put("CODPROF",code);
|
|
|
|
if (frm.read(_isequal)== NOERR)
|
|
|
|
m.set(F_DESC,frm.get("DESC"));
|
1996-01-09 11:39:10 +00:00
|
|
|
else
|
|
|
|
m.reset(F_DESC);
|
1996-01-05 18:48:17 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-12-18 15:37:20 +00:00
|
|
|
bool TForm_EC_editor::font_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
if (key == K_SPACE)
|
|
|
|
{
|
|
|
|
main_app().begin_wait();
|
|
|
|
|
|
|
|
const char* family = f.get();
|
|
|
|
const int MAXSIZES = 16;
|
|
|
|
long sizes[MAXSIZES];
|
|
|
|
BOOLEAN scalable;
|
|
|
|
const int num_sizes = (int)xvt_fmap_get_family_sizes(printer().get_printrcd(),
|
|
|
|
(char*)family, sizes, &scalable, MAXSIZES);
|
|
|
|
|
|
|
|
TToken_string pn1(80), pn2(80);
|
|
|
|
if (scalable)
|
|
|
|
{
|
|
|
|
for (int i = 4; i <= 32; i++)
|
|
|
|
{
|
|
|
|
pn1.add(i);
|
|
|
|
pn2.add(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (num_sizes > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < num_sizes; i++)
|
|
|
|
pn1.add(sizes[i]);
|
|
|
|
}
|
|
|
|
else pn1.add(printer().get_char_size());
|
|
|
|
pn2 = pn1;
|
|
|
|
}
|
|
|
|
TList_field& lst = (TList_field&)f.mask().field(F_SSIZE);
|
|
|
|
lst.replace_items(pn1, pn2);
|
|
|
|
lst.set(format("%d",printer().get_char_size()));
|
|
|
|
|
|
|
|
main_app().end_wait();
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-04-22 10:22:30 +00:00
|
|
|
bool TForm_EC_editor::load_fonts()
|
1995-12-18 15:37:20 +00:00
|
|
|
{
|
|
|
|
const int MAX_FAMILIES = 128;
|
|
|
|
char* family[MAX_FAMILIES];
|
|
|
|
const int num_families = (int)xvt_fmap_get_families(printer().get_printrcd(), family, MAX_FAMILIES);
|
|
|
|
bool font_found = FALSE;
|
|
|
|
TToken_string pn1(256), pn2(256);
|
|
|
|
|
|
|
|
for (int i = 0; i < num_families; i++)
|
|
|
|
{
|
|
|
|
pn1.add(family[i]);
|
|
|
|
pn2.add(family[i]);
|
|
|
|
if (!font_found)
|
|
|
|
if (form().fontname() == family[i]) font_found = TRUE;
|
|
|
|
xvt_mem_free(family[i]);
|
|
|
|
}
|
1996-01-03 14:40:13 +00:00
|
|
|
TList_field& lst = (TList_field&)_msk->field(F_SFONT);
|
1996-05-20 14:46:40 +00:00
|
|
|
if (!font_found)
|
|
|
|
{
|
|
|
|
warning_box("Il font %s non esiste per la stampante di default.",(const char*) form().fontname());
|
|
|
|
pn1.add(form().fontname());
|
|
|
|
pn2.add(form().fontname());
|
|
|
|
}
|
1995-12-18 15:37:20 +00:00
|
|
|
lst.replace_items(pn1, pn2);
|
|
|
|
lst.set(form().fontname());
|
1996-04-22 10:22:30 +00:00
|
|
|
return font_found;
|
1995-12-23 12:16:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TForm_EC_editor::change_pos(char sc, pagetype pt)
|
|
|
|
{
|
|
|
|
TPrint_section* sec = form().exist(sc, pt);
|
1996-01-03 14:40:13 +00:00
|
|
|
if (sec != NULL && !sec->columnwise())
|
1995-12-23 12:16:43 +00:00
|
|
|
{
|
|
|
|
sec->set_dirty();
|
|
|
|
for (word i = 0; i < sec->fields() ; i++)
|
|
|
|
{
|
|
|
|
TForm_item& fi = sec->field(i);
|
1996-01-03 14:40:13 +00:00
|
|
|
short value = fi.x();
|
1995-12-23 12:16:43 +00:00
|
|
|
if (value > 0 && (_prm.ratio != 1.0))
|
|
|
|
{
|
|
|
|
real x_pos;
|
|
|
|
x_pos = value * _prm.ratio;
|
|
|
|
x_pos.round();
|
1996-01-05 18:48:17 +00:00
|
|
|
fi.set_x((short)x_pos.integer());
|
1995-12-23 12:16:43 +00:00
|
|
|
fi.set_dirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-12-18 15:37:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TForm_EC_editor::recalculate_positions(const char* name, int size)
|
|
|
|
{
|
|
|
|
if (!form().dirty()) form().set_dirty();
|
1995-12-23 12:16:43 +00:00
|
|
|
_prm.size_1=form().fontsize();
|
|
|
|
strcpy(_prm.name_1,form().fontname());
|
|
|
|
_prm.size_2=size;
|
|
|
|
strcpy(_prm.name_2,name);
|
|
|
|
_prm.ratio = 1.0;
|
1995-12-18 15:37:20 +00:00
|
|
|
// Next 3 lines may be changed
|
|
|
|
xvt_print_open();
|
1995-12-23 12:16:43 +00:00
|
|
|
xvt_print_start_thread (wprms, (long)&_prm);
|
1995-12-18 15:37:20 +00:00
|
|
|
xvt_print_close();
|
|
|
|
|
1997-05-22 08:53:34 +00:00
|
|
|
const char* const sechar = "BFGH";
|
1995-12-18 15:37:20 +00:00
|
|
|
for (int sn = 0; sn < 4 ; sn++)
|
|
|
|
{
|
|
|
|
const char sc = sechar[sn];
|
|
|
|
for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1))
|
1995-12-23 12:16:43 +00:00
|
|
|
change_pos(sc,pt);
|
1995-12-18 15:37:20 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-01-13 11:00:25 +00:00
|
|
|
void TForm_EC_editor::remove_temp_items(char sec, pagetype p)
|
|
|
|
{
|
|
|
|
TPrint_section* s = form().exist(sec,p);
|
1997-05-22 08:53:34 +00:00
|
|
|
if (s != NULL)
|
1996-01-13 11:00:25 +00:00
|
|
|
{
|
|
|
|
const word items = s->fields();
|
1997-05-22 08:53:34 +00:00
|
|
|
for (word j=0; j < items; j++)
|
1996-01-13 11:00:25 +00:00
|
|
|
{
|
|
|
|
if (s->field(j).temp())
|
|
|
|
s->destroy_field(j,FALSE);
|
|
|
|
}
|
|
|
|
s->field_array().pack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TForm_EC_editor::put_examples(char sez, pagetype p)
|
|
|
|
{
|
|
|
|
TPrint_section* s = form().exist(sez,p);
|
|
|
|
if (s!=NULL)
|
|
|
|
{
|
|
|
|
const word items = s->fields();
|
|
|
|
for (word i=0;i<items;i++)
|
|
|
|
{
|
|
|
|
TForm_item& fi = s->field(i);
|
|
|
|
if (fi.fields()!=0) continue;
|
|
|
|
if (fi.memo())
|
|
|
|
fi.set(fi.memo_info());
|
|
|
|
else
|
|
|
|
if (fi.prompt().empty())
|
|
|
|
{
|
|
|
|
if (fi.class_name() == "DATA")
|
|
|
|
{
|
|
|
|
const TDate d(TODAY);
|
|
|
|
fi.set(d);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (fi.class_name() == "NUMERO")
|
|
|
|
{
|
|
|
|
fi.set_prompt(fi.example());
|
|
|
|
fi.temp() = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fi.set(fi.key());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TForm_EC_editor::remove_examples(char sez, pagetype p)
|
|
|
|
{
|
|
|
|
TPrint_section* s = form().exist(sez,p);
|
|
|
|
if (s!=NULL)
|
|
|
|
{
|
|
|
|
const word items = s->fields();
|
|
|
|
for (word i=0;i<items;i++)
|
|
|
|
{
|
|
|
|
TForm_item& fi = s->field(i);
|
|
|
|
if (fi.fields()!=0) continue;
|
|
|
|
if (fi.memo())
|
|
|
|
fi.set("");
|
|
|
|
else
|
|
|
|
if (fi.class_name() == "NUMERO" && fi.temp())
|
|
|
|
{
|
|
|
|
fi.set_prompt("");
|
|
|
|
fi.temp() = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-01-03 14:40:13 +00:00
|
|
|
void TForm_EC_editor::hook_footer_to_body(TPrint_section* f, TPrint_section* b)
|
|
|
|
{
|
|
|
|
const word items = b->columnwise() ? f->fields() : 0;
|
|
|
|
b->reset_tabs();
|
|
|
|
for (word i=0;i<items;i++)
|
|
|
|
{
|
|
|
|
TForm_item& fi = f->field(i);
|
1996-01-05 18:48:17 +00:00
|
|
|
if (fi.x()>0 || !fi.shown()) continue;
|
|
|
|
short id = fi.id();
|
1996-01-18 17:59:53 +00:00
|
|
|
if (id >= PEC_TSALDO && id <= PEC_TUNASSIGNED) id = PEC_DESCR;
|
|
|
|
else
|
|
|
|
if (id == PEC_UNASSIGNED) id = PEC_AVERE;
|
|
|
|
|
1996-01-05 18:48:17 +00:00
|
|
|
TForm_item& fb = b->find_field(id);
|
1996-01-09 11:39:10 +00:00
|
|
|
if (!fb.shown())
|
|
|
|
{
|
|
|
|
fi.hide();
|
|
|
|
fi.set_x(-1);
|
|
|
|
} else
|
1996-01-13 11:00:25 +00:00
|
|
|
fi.set_x(fb.x());
|
1996-01-03 14:40:13 +00:00
|
|
|
fi.ofs() = 999;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TForm_EC_editor::unhook_footer(TPrint_section* f)
|
|
|
|
{
|
|
|
|
const word items = f->fields();
|
|
|
|
for (word i=0;i<items;i++)
|
|
|
|
{
|
|
|
|
TForm_item& fi = f->field(i);
|
|
|
|
if (fi.ofs()==999)
|
|
|
|
{
|
1996-01-09 11:39:10 +00:00
|
|
|
if (fi.x() == -1) fi.show();
|
1996-01-03 14:40:13 +00:00
|
|
|
fi.ofs() = 0;
|
1996-01-05 18:48:17 +00:00
|
|
|
fi.set_x(0);
|
1996-01-03 14:40:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-01-09 11:39:10 +00:00
|
|
|
void TForm_EC_editor::hide_body_items(TPrint_section* b)
|
|
|
|
{
|
|
|
|
const word items = b->fields();
|
|
|
|
for (word i=0;i<items;i++)
|
|
|
|
{
|
|
|
|
TForm_item& fi = b->field(i);
|
|
|
|
if (fi.shown() && fi.prompt().not_empty())
|
|
|
|
{
|
|
|
|
fi.hide();
|
|
|
|
fi.temp() = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TForm_EC_editor::show_body_items(TPrint_section* b)
|
|
|
|
{
|
|
|
|
const word items = b->fields();
|
|
|
|
for (word i=0;i<items;i++)
|
|
|
|
{
|
|
|
|
TForm_item& fi = b->field(i);
|
|
|
|
if (fi.temp())
|
|
|
|
{
|
|
|
|
fi.show();
|
|
|
|
fi.temp() = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-18 15:37:20 +00:00
|
|
|
bool TForm_EC_editor::edit(char s, pagetype p)
|
|
|
|
{
|
1996-01-03 14:40:13 +00:00
|
|
|
_msk= new TMask("sc3100c");
|
1995-12-18 15:37:20 +00:00
|
|
|
TString80 caption;
|
|
|
|
bool dirty = FALSE;
|
|
|
|
bool other = FALSE;
|
|
|
|
KEY k;
|
|
|
|
|
|
|
|
if (extra())
|
|
|
|
{
|
|
|
|
if (s == 'R')
|
|
|
|
dirty = edit_relation();
|
|
|
|
else
|
|
|
|
if (s == 'D')
|
|
|
|
form_config();
|
|
|
|
else
|
|
|
|
if (s == 'K')
|
|
|
|
dirty = edit_fincatura();
|
|
|
|
else
|
|
|
|
if (s == 'J')
|
|
|
|
dirty = edit_formato_numero();
|
|
|
|
else
|
|
|
|
if (s == 'Y')
|
|
|
|
dirty = edit_formato_data();
|
|
|
|
else other = TRUE;
|
|
|
|
}
|
|
|
|
if (!extra() || (extra() && other))
|
|
|
|
{
|
|
|
|
printer().set_char_size(form().fontsize()); // Questo settera' il carattere della stampante a quello del form
|
1996-01-03 14:40:13 +00:00
|
|
|
// Setta l'handler per il listbox dei fonts e per aggiornare i valori dello sfondo
|
|
|
|
_msk->set_handler(F_SFONT,font_handler);
|
1995-12-18 15:37:20 +00:00
|
|
|
// carica i dati relativi all'offset
|
1996-01-03 14:40:13 +00:00
|
|
|
_msk->set(F_SX, form().offset_x());
|
|
|
|
_msk->set(F_SY, form().offset_y());
|
1995-12-18 15:37:20 +00:00
|
|
|
TString ctp;
|
|
|
|
ctp << form().char_to_pos();
|
1996-01-03 14:40:13 +00:00
|
|
|
_msk->set(F_SCTP, ctp);
|
|
|
|
_msk->set(F_SIPX, form().ipx());
|
|
|
|
_msk->set(F_SIPY, form().ipy());
|
|
|
|
_msk->set(F_FOOT_H,form().exist('F',odd_page)->height());
|
1995-12-18 15:37:20 +00:00
|
|
|
// carica i dati relativi ai flags (memorizzati in HEADER LAST)
|
|
|
|
if (form().exist('H', last_page))
|
|
|
|
{
|
1995-12-22 16:20:42 +00:00
|
|
|
TForm_item& flags = form().find_field('H',last_page,PEC_FLAGS);
|
1995-12-18 15:37:20 +00:00
|
|
|
TToken_string tt(flags.prompt());
|
|
|
|
if (tt.get(0) != NULL)
|
1996-01-03 14:40:13 +00:00
|
|
|
_msk->set(F_SVALUTA,tt.get(0));
|
1995-12-18 15:37:20 +00:00
|
|
|
if (tt.get(1) != NULL)
|
1996-01-03 14:40:13 +00:00
|
|
|
_msk->set(F_FINK,tt.get(1));
|
|
|
|
if (tt.get(2) != NULL)
|
|
|
|
_msk->set(F_MAXTOT,tt.get(2));
|
1995-12-18 15:37:20 +00:00
|
|
|
}
|
|
|
|
// carica i dati relativi allo sfondo (memorizzati in GRAPHICS ODD)
|
|
|
|
if (form().exist('G', odd_page))
|
|
|
|
{
|
1995-12-22 16:20:42 +00:00
|
|
|
TForm_item& pict = form().find_field('G',odd_page,PEC_PICTURE);
|
1996-01-03 14:40:13 +00:00
|
|
|
_msk->set(F_BACKGROUND,pict.prompt());
|
|
|
|
_msk->set(F_BACKWIDTH,pict.width());
|
|
|
|
_msk->set(F_BACKHEIGHT,pict.height());
|
|
|
|
_msk->set(F_BACKX,pict.x());
|
|
|
|
_msk->set(F_BACKY,pict.y());
|
1995-12-18 15:37:20 +00:00
|
|
|
}
|
1996-04-22 10:22:30 +00:00
|
|
|
bool font_changed=FALSE,font_found;
|
1995-12-18 15:37:20 +00:00
|
|
|
while (TRUE)
|
|
|
|
{
|
1996-04-22 10:22:30 +00:00
|
|
|
// Carica i fonts disponibili nel listbox
|
1995-12-18 15:37:20 +00:00
|
|
|
bool local_dirty = FALSE;
|
1996-04-22 10:22:30 +00:00
|
|
|
font_found = load_fonts();
|
1996-01-09 11:39:10 +00:00
|
|
|
enable_menu_item(M_FILE_PRINT);
|
1996-01-03 14:40:13 +00:00
|
|
|
k = _msk->run();
|
1996-01-09 11:39:10 +00:00
|
|
|
disable_menu_item(M_FILE_PRINT);
|
1996-01-03 14:40:13 +00:00
|
|
|
if ((_msk->field(F_SFONT).dirty() || _msk->field(F_SSIZE).dirty()))
|
1995-12-18 15:37:20 +00:00
|
|
|
{
|
1995-12-23 12:16:43 +00:00
|
|
|
font_changed = TRUE;
|
1996-01-03 14:40:13 +00:00
|
|
|
TString ff(_msk->get(F_SFONT));
|
1996-04-22 10:22:30 +00:00
|
|
|
int ss=_msk->get_int(F_SSIZE);
|
|
|
|
if (font_found && yesno_box("E' stato cambiato il font o la dimensione del carattere\ndevo aggiornare le coordinate dei campi"))
|
|
|
|
dirty = recalculate_positions(ff, ss); // Va bene dirty e non local_dirty
|
|
|
|
form().fontname() = ff;
|
|
|
|
form().fontsize() = ss;
|
|
|
|
printer().set_char_size(ss); // Questo settera' il carattere della stampante a quello del form
|
1995-12-18 15:37:20 +00:00
|
|
|
}
|
|
|
|
if (k==K_F3) local_dirty = edit_fincatura();
|
|
|
|
else if (k==K_F4) local_dirty = edit_formato_data();
|
|
|
|
else if (k==K_F5) local_dirty = edit_formato_numero();
|
|
|
|
else if (k!= K_ESC && k!=K_ENTER)
|
|
|
|
{
|
1995-12-22 16:20:42 +00:00
|
|
|
if (k==K_F6) { s = 'H'; caption = "Testata"; }
|
1995-12-18 15:37:20 +00:00
|
|
|
else if (k==K_F7) { s = 'B'; caption = "Corpo"; }
|
|
|
|
else if (k==K_F8) { s = 'F'; caption = "Piede"; }
|
|
|
|
local_dirty = TRUE;
|
|
|
|
if (!form().exist(s, odd_page))
|
|
|
|
{
|
|
|
|
const KEY k = yesnocancel_box("La sezione %s non esiste:\n"
|
|
|
|
"si desidera generarla?",
|
|
|
|
(const char*)caption);
|
|
|
|
if (k == K_ESC)
|
|
|
|
local_dirty = FALSE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TPrint_section* sec = form().exist(s, odd_page, TRUE);
|
|
|
|
if (k == K_YES)
|
|
|
|
{
|
|
|
|
const TPrint_section* def = form().exist(s, odd_page);
|
|
|
|
if (def) *sec = *def;
|
|
|
|
else local_dirty = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (local_dirty)
|
1996-04-17 16:33:07 +00:00
|
|
|
{
|
|
|
|
TPrint_section saved_section(form().section(s,odd_page));
|
|
|
|
|
1995-12-18 15:37:20 +00:00
|
|
|
local_dirty = form().section(s,odd_page).edit(caption);
|
1995-12-23 12:16:43 +00:00
|
|
|
if (!local_dirty) // E' stato premuto annulla dalla maschera di sezione
|
1996-04-17 16:33:07 +00:00
|
|
|
{ // Quindi ripristina la vecchia sezione
|
|
|
|
form().section(s,odd_page) = saved_section;
|
1996-04-22 10:22:30 +00:00
|
|
|
if (font_changed && font_found)
|
1995-12-23 12:16:43 +00:00
|
|
|
//se e' stato cambiato il font allora in _prm ho i dati necessari
|
|
|
|
// per ricostruire le dimensioni corrette
|
1996-04-22 10:22:30 +00:00
|
|
|
change_pos(s,odd_page);
|
1996-04-17 16:33:07 +00:00
|
|
|
}
|
1995-12-23 12:16:43 +00:00
|
|
|
}
|
1995-12-18 15:37:20 +00:00
|
|
|
}
|
1996-05-20 14:46:40 +00:00
|
|
|
if (local_dirty || _msk->dirty()!=0 || k == K_ENTER) dirty=TRUE;
|
1995-12-18 15:37:20 +00:00
|
|
|
if (k==K_ESC || k==K_ENTER)
|
|
|
|
break;
|
|
|
|
} // End of while
|
|
|
|
} // End if
|
|
|
|
|
1996-01-03 14:40:13 +00:00
|
|
|
if (_msk->dirty() != 0 || dirty)
|
1995-12-18 15:37:20 +00:00
|
|
|
{
|
1996-01-03 14:40:13 +00:00
|
|
|
form().fontname() = _msk->get(F_SFONT);
|
|
|
|
form().fontsize() = _msk->get_int(F_SSIZE);
|
|
|
|
form().offset_x() = _msk->get_int(F_SX);
|
|
|
|
form().offset_y() = _msk->get_int(F_SY);
|
|
|
|
form().char_to_pos() = _msk->get(F_SCTP)[0];
|
|
|
|
form().ipx() = _msk->get_int(F_SIPX);
|
|
|
|
form().ipy() = _msk->get_int(F_SIPY);
|
1995-12-18 15:37:20 +00:00
|
|
|
if (form().exist('H', last_page))
|
|
|
|
{
|
1995-12-22 16:20:42 +00:00
|
|
|
TForm_item& flags = form().find_field('H',last_page,PEC_FLAGS);
|
1996-01-03 14:40:13 +00:00
|
|
|
TString s(_msk->get(F_SVALUTA));
|
|
|
|
s << "|" << _msk->get(F_FINK); s << "|" << _msk->get(F_MAXTOT);
|
1995-12-18 15:37:20 +00:00
|
|
|
form().section('H',last_page).set_dirty();
|
|
|
|
flags.set_prompt(s);
|
|
|
|
flags.set_dirty();
|
|
|
|
}
|
|
|
|
if (form().exist('G', odd_page))
|
|
|
|
{
|
1995-12-22 16:20:42 +00:00
|
|
|
TForm_item& pict = form().find_field('G',odd_page,PEC_PICTURE);
|
1996-01-03 14:40:13 +00:00
|
|
|
pict.set_prompt(_msk->get(F_BACKGROUND));
|
|
|
|
pict.width() = _msk->get_int(F_BACKWIDTH);
|
|
|
|
pict.height() = _msk->get_int(F_BACKHEIGHT);
|
1996-01-05 18:48:17 +00:00
|
|
|
pict.set_x(_msk->get_int(F_BACKX));
|
1996-01-03 14:40:13 +00:00
|
|
|
pict.y() = _msk->get_int(F_BACKY);
|
1995-12-18 15:37:20 +00:00
|
|
|
form().section('G',odd_page).set_dirty();
|
|
|
|
pict.set_dirty();
|
|
|
|
}
|
|
|
|
form().set_dirty();
|
|
|
|
if (!dirty) dirty = TRUE;
|
|
|
|
}
|
|
|
|
if ((dirty && k==K_ESC && yesno_box("Salvare le modifiche?")) || (dirty && k==K_ENTER))
|
|
|
|
{ // Se si preme annulla e sono state effettuate modifiche chiede la conferma per salvare
|
|
|
|
// Se invece si preme conferma e sono state effettuate modifiche non chiede la conferma
|
1995-12-22 16:20:42 +00:00
|
|
|
if (form().code().empty())
|
1995-12-18 15:37:20 +00:00
|
|
|
{
|
|
|
|
TFilename n(form().name()); n.ext("frm");
|
|
|
|
TFilename bak(n); bak.ext("bak");
|
|
|
|
rename(n, bak);
|
|
|
|
ofstream out(n);
|
|
|
|
form().print_on(out);
|
|
|
|
}
|
|
|
|
else
|
1996-09-17 10:59:10 +00:00
|
|
|
{
|
|
|
|
TForm& ff = form();
|
|
|
|
ff.write_profile();
|
|
|
|
TLocalisamfile r(LF_RFORM); // scrivera' un record sulle righe, relativo alla sezione
|
|
|
|
r.put("TIPOPROF",ff.name());// per memorizzare i formati numero/data
|
|
|
|
r.put("CODPROF",ff.code());
|
|
|
|
r.put("SEZ","DN");
|
|
|
|
r.put("ID",0);
|
|
|
|
TToken_string t(get_formato_data(),'\n');
|
|
|
|
t.add(get_formato_numero());
|
1997-05-28 12:38:08 +00:00
|
|
|
if (t.trim().not_empty())
|
|
|
|
r.put("SPECIAL",t);
|
1996-09-17 10:59:10 +00:00
|
|
|
if (r.write()!= NOERR) r.rewrite();
|
|
|
|
}
|
1996-01-05 18:48:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (k==K_ESC && form()._isnew)
|
|
|
|
{
|
|
|
|
TLocalisamfile f(LF_FORM),r(LF_RFORM);
|
|
|
|
remove_form(f,r,form().name(),form().code());
|
1996-01-09 11:39:10 +00:00
|
|
|
mask().reset(F_BASE);
|
1996-01-05 18:48:17 +00:00
|
|
|
mask().reset(F_CODE);
|
|
|
|
mask().reset(F_CODEL);
|
|
|
|
mask().reset(F_DESC);
|
|
|
|
}
|
1996-01-03 14:40:13 +00:00
|
|
|
if (_msk!=NULL) delete _msk;
|
|
|
|
_msk = NULL;
|
1995-12-18 15:37:20 +00:00
|
|
|
if (!extra()) dispatch_e_menu(MENU_ITEM(14));
|
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
|
1996-01-03 14:40:13 +00:00
|
|
|
void TForm_EC_editor::print()
|
|
|
|
{
|
|
|
|
TPrint_section* g = form().exist('G',odd_page);
|
|
|
|
TPrint_section* h = form().exist('H',odd_page);
|
|
|
|
TPrint_section* f = form().exist('F',odd_page);
|
|
|
|
TPrint_section* b = form().exist('B',odd_page);
|
|
|
|
bool remove = TRUE;
|
|
|
|
|
|
|
|
CHECK(b!=NULL && f!=NULL && h!=NULL,"Una o piu' sezioni non sono presenti");
|
|
|
|
// Rilegge la sezione grafica, perche' se e' la seconda volta che si
|
|
|
|
// stampa deve ripristinare la situazione iniziale.
|
|
|
|
// NB la sezione grafica deve contenere solo sfondo: le linee di fincatura
|
|
|
|
// qui generate non verranno salvate; analogamente il programma di stampa
|
|
|
|
// vero e proprio.
|
|
|
|
if (b->columnwise())
|
|
|
|
{
|
|
|
|
bool gen_fink = TRUE;
|
|
|
|
if (_msk != NULL)
|
|
|
|
{
|
|
|
|
TForm_item& pict = g->find_field(PEC_PICTURE);
|
|
|
|
pict.set_prompt(_msk->get(F_BACKGROUND));
|
|
|
|
pict.width() = _msk->get_int(F_BACKWIDTH);
|
|
|
|
pict.height() = _msk->get_int(F_BACKHEIGHT);
|
1996-01-05 18:48:17 +00:00
|
|
|
pict.set_x(_msk->get_int(F_BACKX));
|
1996-01-03 14:40:13 +00:00
|
|
|
pict.y() = _msk->get_int(F_BACKY);
|
|
|
|
form().offset_y() = _msk->get_int(F_SY);
|
|
|
|
form().offset_x() = _msk->get_int(F_SX);
|
1997-05-28 12:38:08 +00:00
|
|
|
int fnk_mode = _msk->get_int(F_FINK);
|
|
|
|
if (fnk_mode == 0)
|
|
|
|
gen_fink = FALSE;
|
|
|
|
else
|
|
|
|
form().set_fink_mode(fnk_mode == 1 ? FALSE : TRUE);
|
1996-01-03 14:40:13 +00:00
|
|
|
}
|
|
|
|
// Schiaffa dentro le stringhe di esempio per ogni campo che non ha prompt o riferimenti sul file
|
|
|
|
// per i campi memo si copia _memo in _prompt
|
|
|
|
const int formlen = printer().formlen();
|
|
|
|
const int h_height = h->height();
|
|
|
|
int rws[3] = {h_height,formlen-f->height(),0};
|
|
|
|
if (gen_fink)
|
|
|
|
form().genera_fincatura(odd_page,h_height-2,formlen,rws);
|
|
|
|
form().genera_intestazioni(odd_page,h_height-1);
|
|
|
|
} else
|
|
|
|
remove = FALSE;
|
|
|
|
hook_footer_to_body(f,b);
|
1996-01-09 11:39:10 +00:00
|
|
|
hide_body_items(b);
|
1996-01-13 11:00:25 +00:00
|
|
|
put_examples('H',odd_page);
|
|
|
|
put_examples('F',odd_page);
|
1996-01-03 14:40:13 +00:00
|
|
|
TForm_editor::print();
|
1996-01-13 11:00:25 +00:00
|
|
|
remove_examples('H',odd_page);
|
|
|
|
remove_examples('F',odd_page);
|
1996-01-09 11:39:10 +00:00
|
|
|
show_body_items(b);
|
1996-01-03 14:40:13 +00:00
|
|
|
unhook_footer(f);
|
|
|
|
if (remove)
|
|
|
|
{
|
1996-01-13 11:00:25 +00:00
|
|
|
remove_temp_items('G',odd_page);
|
|
|
|
remove_temp_items('H',odd_page);
|
1996-01-03 14:40:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-01-05 18:48:17 +00:00
|
|
|
void TForm_EC_editor::remove_form(TLocalisamfile& frm, TLocalisamfile& rfr,const TString& t,const TString& c)
|
|
|
|
{
|
|
|
|
frm.zero();
|
|
|
|
frm.put("TIPOPROF", t);
|
|
|
|
if (c.not_empty())
|
|
|
|
frm.put("CODPROF", c);
|
|
|
|
if (frm.read() == NOERR)
|
|
|
|
frm.remove();
|
|
|
|
rfr.zero();
|
|
|
|
rfr.put("TIPOPROF", t);
|
|
|
|
rfr.put("CODPROF", c);
|
|
|
|
if (rfr.read(_isgteq) == NOERR)
|
|
|
|
{
|
|
|
|
for ( ; rfr.get("CODPROF") == c && rfr.get("TIPOPROF") == t; rfr.next())
|
|
|
|
rfr.remove();
|
|
|
|
}
|
|
|
|
}
|
1995-12-18 15:37:20 +00:00
|
|
|
bool TForm_EC_editor::ask_profile()
|
|
|
|
{
|
|
|
|
KEY k;
|
1996-01-23 12:04:36 +00:00
|
|
|
|
1997-05-22 08:53:34 +00:00
|
|
|
TMask& m = mask();
|
|
|
|
m.set_handler(DLG_COPY,cpy_handler);
|
|
|
|
m.set_handler(F_CODE,code_handler);
|
|
|
|
m.set_handler(F_CODEL,lng_handler);
|
|
|
|
m.set(F_BASE,BASE_EC_PROFILE);
|
1996-01-03 14:40:13 +00:00
|
|
|
disable_menu_item(M_FILE_PRINT);
|
1997-05-22 08:53:34 +00:00
|
|
|
|
|
|
|
check_mailbox(m);
|
|
|
|
|
|
|
|
while ((k = m.run()) != K_QUIT)
|
1995-12-18 15:37:20 +00:00
|
|
|
{
|
|
|
|
TLocalisamfile frm(LF_FORM);
|
|
|
|
TLocalisamfile rfr(LF_RFORM);
|
1997-05-22 08:53:34 +00:00
|
|
|
TString fform = m.get(F_BASE);
|
|
|
|
TString fdesc = m.get(F_DESC);
|
|
|
|
long fcode = m.get_long(F_CODE);
|
|
|
|
char flng = m.get(F_CODEL)[0];
|
1995-12-18 15:37:20 +00:00
|
|
|
TString cod;
|
|
|
|
cod.format("%04ld%c",fcode,flng);
|
|
|
|
if (!extra() && fcode == 0 && flng=='\0')
|
|
|
|
{
|
|
|
|
error_box("Non e' possibile modificare il profilo standard.");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (k == K_ENTER)
|
|
|
|
{
|
1997-05-28 12:38:08 +00:00
|
|
|
set_formato_data("");
|
|
|
|
set_formato_numero("");
|
1995-12-18 15:37:20 +00:00
|
|
|
check_form();
|
1996-01-13 11:00:25 +00:00
|
|
|
set_form(new TForm_EC(fform, (fcode!=0) ? cod : "", extra() ? 2 :1, fdesc));
|
1996-09-17 10:59:10 +00:00
|
|
|
|
|
|
|
TLocalisamfile r(LF_RFORM); // Setta l'eventuale formato date/numero impostati
|
|
|
|
r.put("TIPOPROF",fform);
|
|
|
|
r.put("CODPROF",cod);
|
|
|
|
r.put("SEZ","DN");r.put("ID",0);
|
|
|
|
if (r.read() == NOERR)
|
|
|
|
{
|
|
|
|
TToken_string special (r.get("SPECIAL"),'\n');
|
|
|
|
set_formato_data(special.get(0));
|
|
|
|
set_formato_numero(special.get(1));
|
|
|
|
}
|
|
|
|
|
1995-12-18 15:37:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (k == K_DEL)
|
|
|
|
{
|
|
|
|
if (fcode != 0 &&
|
|
|
|
yesno_box("Confermare la cancellazione del profilo %04ld%c", fcode,flng))
|
|
|
|
{
|
1996-01-03 14:40:13 +00:00
|
|
|
TProgind pi(50,"Cancellazione in corso...",FALSE,FALSE,10);
|
1996-01-05 18:48:17 +00:00
|
|
|
remove_form(frm,rfr,fform,cod);
|
1996-01-03 14:40:13 +00:00
|
|
|
pi.cancel();
|
1996-04-18 09:14:13 +00:00
|
|
|
mask().set(F_BASE,BASE_EC_PROFILE);
|
1995-12-18 15:37:20 +00:00
|
|
|
mask().set(F_CODE,"");
|
|
|
|
mask().set(F_CODEL,"");
|
|
|
|
mask().set(F_DESC,"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k == K_QUIT)
|
|
|
|
{
|
|
|
|
dispatch_e_menu(M_FILE_QUIT);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1997-05-22 08:53:34 +00:00
|
|
|
bool TForm_EC_editor::check_mailbox(TMask& m)
|
|
|
|
{
|
|
|
|
TMailbox mail;
|
|
|
|
TMessage* msg = mail.next_s(MSG_ED);
|
|
|
|
if (msg)
|
|
|
|
{
|
|
|
|
TToken_string body(msg->body());
|
|
|
|
const int key = body.get_int();
|
|
|
|
|
|
|
|
TAssoc_array field_values;
|
|
|
|
const char * s;
|
|
|
|
TString80 t;
|
|
|
|
|
|
|
|
while((s = body.get()) != NULL)
|
|
|
|
{
|
|
|
|
t = s;
|
|
|
|
const int u = t.find('=');
|
|
|
|
|
|
|
|
CHECKS(u > 0, "Invalid edit message ", (const char *) body);
|
|
|
|
if (u > 0)
|
|
|
|
{
|
|
|
|
const TString v(t.mid(u + 1));
|
|
|
|
|
|
|
|
t.cut(u);
|
|
|
|
field_values.add(t, v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TString val;
|
|
|
|
for (TEditable_field* e = m.get_key_field(key, TRUE); e; e = m.get_key_field(key, FALSE))
|
|
|
|
{
|
|
|
|
const TFieldref* field = e->field();
|
|
|
|
if (field)
|
|
|
|
{
|
|
|
|
TString16 field_name(field->name());
|
|
|
|
const int from = field->from();
|
|
|
|
const int to = field->to();
|
|
|
|
|
|
|
|
if (to >= 0)
|
|
|
|
field_name << "[" << (from + 1);
|
|
|
|
const TString * v = (const TString *) field_values.objptr(field_name);
|
|
|
|
|
|
|
|
if (v == NULL && to >= 0)
|
|
|
|
{
|
|
|
|
v = (const TString *)field_values.objptr(field->name());
|
|
|
|
if (v)
|
|
|
|
val = v->sub(from, to);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (v) val = *v;
|
|
|
|
|
|
|
|
if (v)
|
|
|
|
e->set(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m.send_key(K_AUTO_ENTER, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-12-18 15:37:20 +00:00
|
|
|
int sc3100(int argc, char** argv)
|
|
|
|
{
|
|
|
|
TForm_EC_editor a;
|
|
|
|
a.run(argc, argv, "Parametrizzazione profili EC");
|
|
|
|
return 0;
|
|
|
|
}
|