Aggiunto il metod TForm_EC_editor::print() per l'anteprima di stampa.
Aggiunti metodi hook_footer() e unhook_footer() per agganciare il footer al body se columnwise. Tolto il ricalcolo delle larghezze colonne in sezioni columnwise se viene cambiato il font. git-svn-id: svn://10.65.10.50/trunk@2377 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8e6e27f3e5
commit
0fcb8f024c
209
sc/sc3100.cpp
209
sc/sc3100.cpp
@ -1,7 +1,11 @@
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __PROGIND_H
|
||||
#include <progind.h>
|
||||
#endif
|
||||
|
||||
#include "../ba/baformed.h"
|
||||
#include "sc3.h"
|
||||
#include "sc3100a.h"
|
||||
@ -23,19 +27,27 @@ typedef struct {
|
||||
|
||||
class TForm_EC_editor : public TForm_editor
|
||||
{
|
||||
s_data _prm;
|
||||
s_data _prm;
|
||||
TMask * _msk; // maschera di selezione sezione
|
||||
protected:
|
||||
static bool cpy_handler(TMask_field& f, KEY k);
|
||||
static bool font_handler(TMask_field& f, KEY k);
|
||||
void load_fonts(TMask& m);
|
||||
void change_pos(char sc, pagetype pt);
|
||||
void load_fonts();
|
||||
void change_pos(char sc, pagetype pt);
|
||||
bool recalculate_positions(const char* name, int size);
|
||||
void hook_footer_to_body(TPrint_section* f, TPrint_section* b);
|
||||
void unhook_footer(TPrint_section* f);
|
||||
virtual const char* selection_mask() const { return "sc3100a"; }
|
||||
virtual bool ask_profile();
|
||||
virtual bool edit(char s, pagetype p);
|
||||
virtual void print();
|
||||
public:
|
||||
TForm_EC_editor() {_msk = NULL;}
|
||||
virtual ~TForm_EC_editor() {}
|
||||
};
|
||||
|
||||
inline TForm_EC_editor& app() { return (TForm_EC_editor&) main_app();}
|
||||
|
||||
BOOLEAN XVT_CALLCONV1 wprms (long data)
|
||||
{
|
||||
s_data* st =(s_data*)data;
|
||||
@ -91,7 +103,8 @@ bool TForm_EC_editor::cpy_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
error_box("Errore %d in scrittura testata profilo.",frm.status());
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
TProgind pi(50,"Copia in corso...",FALSE,FALSE,10);
|
||||
rfr.zero();rfr.put("TIPOPROF",form);
|
||||
rfr.put("CODPROF",scod); //Profilo sorgente
|
||||
rfr.read(_isgteq);
|
||||
@ -102,7 +115,8 @@ bool TForm_EC_editor::cpy_handler(TMask_field& f, KEY k)
|
||||
if (rfr_to_write.write() != NOERR)
|
||||
rfr_to_write.rewrite();
|
||||
rfr.read(_isgreat);
|
||||
}
|
||||
}
|
||||
pi.cancel();
|
||||
if (rfr_to_write.status() != NOERR)
|
||||
{
|
||||
error_box("Errore %d in scrittura righe profilo.",rfr_to_write.status());
|
||||
@ -156,7 +170,7 @@ bool TForm_EC_editor::font_handler(TMask_field& f, KEY key)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TForm_EC_editor::load_fonts(TMask& m)
|
||||
void TForm_EC_editor::load_fonts()
|
||||
{
|
||||
const int MAX_FAMILIES = 128;
|
||||
char* family[MAX_FAMILIES];
|
||||
@ -172,7 +186,7 @@ void TForm_EC_editor::load_fonts(TMask& m)
|
||||
if (form().fontname() == family[i]) font_found = TRUE;
|
||||
xvt_mem_free(family[i]);
|
||||
}
|
||||
TList_field& lst = (TList_field&)m.field(F_SFONT);
|
||||
TList_field& lst = (TList_field&)_msk->field(F_SFONT);
|
||||
lst.replace_items(pn1, pn2);
|
||||
if (!font_found) warning_box("Il font %s non esiste per la stampante di default.",(const char*) form().fontname());
|
||||
lst.set(form().fontname());
|
||||
@ -181,22 +195,19 @@ void TForm_EC_editor::load_fonts(TMask& m)
|
||||
void TForm_EC_editor::change_pos(char sc, pagetype pt)
|
||||
{
|
||||
TPrint_section* sec = form().exist(sc, pt);
|
||||
if (sec != NULL)
|
||||
if (sec != NULL && !sec->columnwise())
|
||||
{
|
||||
sec->set_dirty();
|
||||
for (word i = 0; i < sec->fields() ; i++)
|
||||
{
|
||||
TForm_item& fi = sec->field(i);
|
||||
short value = sec->columnwise() ? fi.y() : fi.x();
|
||||
short value = fi.x();
|
||||
if (value > 0 && (_prm.ratio != 1.0))
|
||||
{
|
||||
real x_pos;
|
||||
x_pos = value * _prm.ratio;
|
||||
x_pos.round();
|
||||
if (sec->columnwise())
|
||||
fi.y() = (short)x_pos.integer();
|
||||
else
|
||||
fi.x() = (short)x_pos.integer();
|
||||
fi.x() = (short)x_pos.integer();
|
||||
fi.set_dirty();
|
||||
}
|
||||
}
|
||||
@ -228,14 +239,44 @@ bool TForm_EC_editor::recalculate_positions(const char* name, int size)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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);
|
||||
if (fi.x()>0) continue;
|
||||
const TForm_item& fb = b->find_field(fi.id());
|
||||
const int x = fb.x()+b->ofspc();
|
||||
fi.x() = x;
|
||||
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)
|
||||
{
|
||||
fi.ofs() = 0;
|
||||
fi.x() = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TForm_EC_editor::edit(char s, pagetype p)
|
||||
{
|
||||
TMask m("sc3100c");
|
||||
_msk= new TMask("sc3100c");
|
||||
TString80 caption;
|
||||
bool dirty = FALSE;
|
||||
bool other = FALSE;
|
||||
KEY k;
|
||||
|
||||
enable_menu_item(M_FILE_PRINT);
|
||||
if (extra())
|
||||
{
|
||||
if (s == 'R')
|
||||
@ -257,49 +298,52 @@ bool TForm_EC_editor::edit(char s, pagetype p)
|
||||
if (!extra() || (extra() && other))
|
||||
{
|
||||
// Carica i fonts disponibili nel listbox
|
||||
load_fonts(m);
|
||||
load_fonts();
|
||||
printer().set_char_size(form().fontsize()); // Questo settera' il carattere della stampante a quello del form
|
||||
// Setta l'handler per il listbox dei fonts
|
||||
m.set_handler(F_SFONT,font_handler);
|
||||
// Setta l'handler per il listbox dei fonts e per aggiornare i valori dello sfondo
|
||||
_msk->set_handler(F_SFONT,font_handler);
|
||||
// carica i dati relativi all'offset
|
||||
m.set(F_SX, form().offset_x());
|
||||
m.set(F_SY, form().offset_y());
|
||||
_msk->set(F_SX, form().offset_x());
|
||||
_msk->set(F_SY, form().offset_y());
|
||||
TString ctp;
|
||||
ctp << form().char_to_pos();
|
||||
m.set(F_SCTP, ctp);
|
||||
m.set(F_SIPX, form().ipx());
|
||||
m.set(F_SIPY, form().ipy());
|
||||
_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());
|
||||
// carica i dati relativi ai flags (memorizzati in HEADER LAST)
|
||||
if (form().exist('H', last_page))
|
||||
{
|
||||
TForm_item& flags = form().find_field('H',last_page,PEC_FLAGS);
|
||||
TToken_string tt(flags.prompt());
|
||||
if (tt.get(0) != NULL)
|
||||
m.set(F_SVALUTA,tt.get(0));
|
||||
_msk->set(F_SVALUTA,tt.get(0));
|
||||
if (tt.get(1) != NULL)
|
||||
m.set(F_FINK,tt.get(1));
|
||||
_msk->set(F_FINK,tt.get(1));
|
||||
if (tt.get(2) != NULL)
|
||||
_msk->set(F_MAXTOT,tt.get(2));
|
||||
}
|
||||
// carica i dati relativi allo sfondo (memorizzati in GRAPHICS ODD)
|
||||
if (form().exist('G', odd_page))
|
||||
{
|
||||
TForm_item& pict = form().find_field('G',odd_page,PEC_PICTURE);
|
||||
m.set(F_BACKGROUND,pict.prompt());
|
||||
m.set(F_BACKWIDTH,pict.width());
|
||||
m.set(F_BACKHEIGHT,pict.height());
|
||||
m.set(F_BACKX,pict.x());
|
||||
m.set(F_BACKY,pict.y());
|
||||
_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());
|
||||
}
|
||||
bool font_changed=FALSE;
|
||||
while (TRUE)
|
||||
{
|
||||
bool local_dirty = FALSE;
|
||||
k = m.run();
|
||||
if ((m.field(F_SFONT).dirty() || m.field(F_SSIZE).dirty()))
|
||||
k = _msk->run();
|
||||
if ((_msk->field(F_SFONT).dirty() || _msk->field(F_SSIZE).dirty()))
|
||||
{
|
||||
font_changed = TRUE;
|
||||
TString ff(m.get(F_SFONT));
|
||||
dirty = recalculate_positions(ff, m.get_int(F_SSIZE)); // Va bene dirty e non local_dirty
|
||||
printer().set_char_size(m.get_int(F_SSIZE)); // Questo settera' il carattere della stampante a quello del form
|
||||
TString ff(_msk->get(F_SFONT));
|
||||
dirty = recalculate_positions(ff, _msk->get_int(F_SSIZE)); // Va bene dirty e non local_dirty
|
||||
printer().set_char_size(_msk->get_int(F_SSIZE)); // Questo settera' il carattere della stampante a quello del form
|
||||
}
|
||||
if (k==K_F3) local_dirty = edit_fincatura();
|
||||
else if (k==K_F4) local_dirty = edit_formato_data();
|
||||
@ -338,26 +382,26 @@ bool TForm_EC_editor::edit(char s, pagetype p)
|
||||
change_pos(s,odd_page);
|
||||
}
|
||||
}
|
||||
if (local_dirty || m.dirty()!=0) dirty=TRUE;
|
||||
if (local_dirty || _msk->dirty()!=0) dirty=TRUE;
|
||||
if (k==K_ESC || k==K_ENTER)
|
||||
break;
|
||||
} // End of while
|
||||
} // End if
|
||||
|
||||
if (m.dirty() != 0 || dirty)
|
||||
if (_msk->dirty() != 0 || dirty)
|
||||
{
|
||||
form().fontname() = m.get(F_SFONT);
|
||||
form().fontsize() = m.get_int(F_SSIZE);
|
||||
form().offset_x() = m.get_int(F_SX);
|
||||
form().offset_y() = m.get_int(F_SY);
|
||||
form().char_to_pos() = m.get(F_SCTP)[0];
|
||||
form().ipx() = m.get_int(F_SIPX);
|
||||
form().ipy() = m.get_int(F_SIPY);
|
||||
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);
|
||||
if (form().exist('H', last_page))
|
||||
{
|
||||
TForm_item& flags = form().find_field('H',last_page,PEC_FLAGS);
|
||||
TString s(m.get(F_SVALUTA));
|
||||
s << "|" << m.get(F_FINK);
|
||||
TString s(_msk->get(F_SVALUTA));
|
||||
s << "|" << _msk->get(F_FINK); s << "|" << _msk->get(F_MAXTOT);
|
||||
form().section('H',last_page).set_dirty();
|
||||
flags.set_prompt(s);
|
||||
flags.set_dirty();
|
||||
@ -365,11 +409,11 @@ bool TForm_EC_editor::edit(char s, pagetype p)
|
||||
if (form().exist('G', odd_page))
|
||||
{
|
||||
TForm_item& pict = form().find_field('G',odd_page,PEC_PICTURE);
|
||||
pict.set_prompt(m.get(F_BACKGROUND));
|
||||
pict.width() = m.get_int(F_BACKWIDTH);
|
||||
pict.height() = m.get_int(F_BACKHEIGHT);
|
||||
pict.x() = m.get_int(F_BACKX);
|
||||
pict.y() = m.get_int(F_BACKY);
|
||||
pict.set_prompt(_msk->get(F_BACKGROUND));
|
||||
pict.width() = _msk->get_int(F_BACKWIDTH);
|
||||
pict.height() = _msk->get_int(F_BACKHEIGHT);
|
||||
pict.x() = _msk->get_int(F_BACKX);
|
||||
pict.y() = _msk->get_int(F_BACKY);
|
||||
form().section('G',odd_page).set_dirty();
|
||||
pict.set_dirty();
|
||||
}
|
||||
@ -389,15 +433,74 @@ bool TForm_EC_editor::edit(char s, pagetype p)
|
||||
}
|
||||
else
|
||||
form().write_profile();
|
||||
}
|
||||
}
|
||||
if (_msk!=NULL) delete _msk;
|
||||
_msk = NULL;
|
||||
disable_menu_item(M_FILE_PRINT);
|
||||
if (!extra()) dispatch_e_menu(MENU_ITEM(14));
|
||||
return dirty;
|
||||
}
|
||||
|
||||
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);
|
||||
pict.x() = _msk->get_int(F_BACKX);
|
||||
pict.y() = _msk->get_int(F_BACKY);
|
||||
form().offset_y() = _msk->get_int(F_SY);
|
||||
form().offset_x() = _msk->get_int(F_SX);
|
||||
form()._background_mode = (bkg_mode)_msk->get_int(F_FINK);
|
||||
if (form()._background_mode == none) gen_fink = FALSE;
|
||||
if (printer().is_generic() && form()._background_mode == graphics) form()._background_mode = texto;
|
||||
}
|
||||
// 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);
|
||||
form().put_examples('H',odd_page);
|
||||
form().put_examples('F',odd_page);
|
||||
TForm_editor::print();
|
||||
form().remove_examples('H',odd_page);
|
||||
form().remove_examples('F',odd_page);
|
||||
unhook_footer(f);
|
||||
if (remove)
|
||||
{
|
||||
form().remove_temp_items('G',odd_page);
|
||||
form().remove_temp_items('H',odd_page);
|
||||
}
|
||||
}
|
||||
|
||||
bool TForm_EC_editor::ask_profile()
|
||||
{
|
||||
KEY k;
|
||||
mask().set_handler(DLG_COPY,cpy_handler);
|
||||
disable_menu_item(M_FILE_PRINT);
|
||||
while ((k = mask().run()) != K_QUIT)
|
||||
{
|
||||
TLocalisamfile frm(LF_FORM);
|
||||
@ -425,6 +528,7 @@ bool TForm_EC_editor::ask_profile()
|
||||
if (fcode != 0 &&
|
||||
yesno_box("Confermare la cancellazione del profilo %04ld%c", fcode,flng))
|
||||
{
|
||||
TProgind pi(50,"Cancellazione in corso...",FALSE,FALSE,10);
|
||||
frm.zero();
|
||||
frm.put("TIPOPROF", fform);
|
||||
if (fcode != 0 )
|
||||
@ -439,6 +543,7 @@ bool TForm_EC_editor::ask_profile()
|
||||
for ( ; rfr.get("CODPROF") == cod && rfr.get("TIPOPROF") == fform; rfr.next())
|
||||
rfr.remove();
|
||||
}
|
||||
pi.cancel();
|
||||
mask().set(F_CODE,"");
|
||||
mask().set(F_CODEL,"");
|
||||
mask().set(F_DESC,"");
|
||||
|
Loading…
x
Reference in New Issue
Block a user