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 "sc3100c.h"
#include "sc21pec.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 // // serve per ricalcolare le posizioni //
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@ -34,6 +21,21 @@ typedef struct {
double ratio; // ratio (width_old_font/width_new_font) double ratio; // ratio (width_old_font/width_new_font)
} s_data; } 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) BOOLEAN XVT_CALLCONV1 wprms (long data)
{ {
s_data* st =(s_data*)data; s_data* st =(s_data*)data;
@ -176,18 +178,42 @@ void TForm_EC_editor::load_fonts(TMask& m)
lst.set(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) bool TForm_EC_editor::recalculate_positions(const char* name, int size)
{ {
if (!form().dirty()) form().set_dirty(); if (!form().dirty()) form().set_dirty();
s_data prm; _prm.size_1=form().fontsize();
prm.size_1=form().fontsize(); strcpy(_prm.name_1,form().fontname());
strcpy(prm.name_1,form().fontname()); _prm.size_2=size;
prm.size_2=size; strcpy(_prm.name_2,name);
strcpy(prm.name_2,name); _prm.ratio = 1.0;
prm.ratio = 1.0;
// Next 3 lines may be changed // Next 3 lines may be changed
xvt_print_open(); xvt_print_open();
xvt_print_start_thread (wprms, (long)&prm); xvt_print_start_thread (wprms, (long)&_prm);
xvt_print_close(); xvt_print_close();
form().fontname() = name; form().fontname() = name;
@ -197,29 +223,7 @@ bool TForm_EC_editor::recalculate_positions(const char* name, int size)
{ {
const char sc = sechar[sn]; const char sc = sechar[sn];
for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1)) for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1))
{ change_pos(sc,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();
}
}
}
}
} }
return TRUE; return TRUE;
} }
@ -285,12 +289,14 @@ bool TForm_EC_editor::edit(char s, pagetype p)
m.set(F_BACKX,pict.x()); m.set(F_BACKX,pict.x());
m.set(F_BACKY,pict.y()); m.set(F_BACKY,pict.y());
} }
bool font_changed=FALSE;
while (TRUE) while (TRUE)
{ {
bool local_dirty = FALSE; bool local_dirty = FALSE;
k = m.run(); k = m.run();
if ((m.field(F_SFONT).dirty() || m.field(F_SSIZE).dirty())) if ((m.field(F_SFONT).dirty() || m.field(F_SSIZE).dirty()))
{ {
font_changed = TRUE;
TString ff(m.get(F_SFONT)); TString ff(m.get(F_SFONT));
dirty = recalculate_positions(ff, m.get_int(F_SSIZE)); // Va bene dirty e non local_dirty 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 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) if (local_dirty)
{
local_dirty = form().section(s,odd_page).edit(caption); 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 (local_dirty || m.dirty()!=0) dirty=TRUE;
if (k==K_ESC || k==K_ENTER) if (k==K_ESC || k==K_ENTER)