Modifiche per effettuare la rilettura di una sezione nel caso si

annullino le modifiche.


git-svn-id: svn://10.65.10.50/trunk@2357 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1995-12-23 12:16:43 +00:00
parent 68de7c2f96
commit bf99d32250

View File

@ -9,19 +9,6 @@
#include "sc3100c.h"
#include "sc21pec.h"
class TForm_EC_editor : public TForm_editor
{
protected:
static bool cpy_handler(TMask_field& f, KEY k);
static bool font_handler(TMask_field& f, KEY k);
void load_fonts(TMask& m);
bool recalculate_positions(const char* name, int size);
virtual const char* selection_mask() const { return "sc3100a"; }
virtual bool ask_profile();
virtual bool edit(char s, pagetype p);
public:
};
/////////////////////////////////////////////////////////////////
// serve per ricalcolare le posizioni //
/////////////////////////////////////////////////////////////////
@ -34,6 +21,21 @@ typedef struct {
double ratio; // ratio (width_old_font/width_new_font)
} s_data;
class TForm_EC_editor : public TForm_editor
{
s_data _prm;
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);
bool recalculate_positions(const char* name, int size);
virtual const char* selection_mask() const { return "sc3100a"; }
virtual bool ask_profile();
virtual bool edit(char s, pagetype p);
public:
};
BOOLEAN XVT_CALLCONV1 wprms (long data)
{
s_data* st =(s_data*)data;
@ -174,20 +176,44 @@ void TForm_EC_editor::load_fonts(TMask& m)
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());
}
void TForm_EC_editor::change_pos(char sc, pagetype pt)
{
TPrint_section* sec = form().exist(sc, pt);
if (sec != NULL)
{
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();
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.set_dirty();
}
}
}
}
bool TForm_EC_editor::recalculate_positions(const char* name, int size)
{
if (!form().dirty()) form().set_dirty();
s_data prm;
prm.size_1=form().fontsize();
strcpy(prm.name_1,form().fontname());
prm.size_2=size;
strcpy(prm.name_2,name);
prm.ratio = 1.0;
_prm.size_1=form().fontsize();
strcpy(_prm.name_1,form().fontname());
_prm.size_2=size;
strcpy(_prm.name_2,name);
_prm.ratio = 1.0;
// Next 3 lines may be changed
xvt_print_open();
xvt_print_start_thread (wprms, (long)&prm);
xvt_print_start_thread (wprms, (long)&_prm);
xvt_print_close();
form().fontname() = name;
@ -197,29 +223,7 @@ bool TForm_EC_editor::recalculate_positions(const char* name, int size)
{
const char sc = sechar[sn];
for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1))
{
TPrint_section* sec = form().exist(sc, pt);
if (sec != NULL)
{
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();
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.set_dirty();
}
}
}
}
change_pos(sc,pt);
}
return TRUE;
}
@ -285,12 +289,14 @@ bool TForm_EC_editor::edit(char s, pagetype p)
m.set(F_BACKX,pict.x());
m.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()))
{
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
@ -323,7 +329,14 @@ bool TForm_EC_editor::edit(char s, pagetype p)
}
}
if (local_dirty)
{
local_dirty = form().section(s,odd_page).edit(caption);
if (!local_dirty) // E' stato premuto annulla dalla maschera di sezione
if (form().reread(s,odd_page) && font_changed)
//se e' stato cambiato il font allora in _prm ho i dati necessari
// per ricostruire le dimensioni corrette
change_pos(s,odd_page);
}
}
if (local_dirty || m.dirty()!=0) dirty=TRUE;
if (k==K_ESC || k==K_ENTER)