Spostata la gestione dei controlli non standard da form.cpp.

Aggiunta la class TForm_EC, derivata da TForm.


git-svn-id: svn://10.65.10.50/trunk@2451 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1996-01-13 11:00:25 +00:00
parent 1f9884859b
commit 54cba15a30

View File

@ -25,6 +25,56 @@ typedef struct {
double ratio; // ratio (width_old_font/width_new_font)
} s_data;
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);
public:
virtual const char* section_mask() { return "sc3100s" ;}
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;
}
class TForm_EC_editor : public TForm_editor
{
s_data _prm;
@ -39,6 +89,9 @@ protected:
void load_fonts();
void change_pos(char sc, pagetype pt);
bool recalculate_positions(const char* name, int size);
void remove_temp_items(char sec, pagetype p);
void put_examples(char sec, pagetype p);
void remove_examples(char sec, pagetype p);
void hook_footer_to_body(TPrint_section* f, TPrint_section* b);
void unhook_footer(TPrint_section* f);
void hide_body_items(TPrint_section* b);
@ -173,6 +226,7 @@ bool TForm_EC_editor::cpy_handler(TMask_field& f, KEY k)
error_box("Errore %d in scrittura righe profilo.",rfr_to_write.status());
break ;
}
break;
} else
error_box("Non esiste il profilo sorgente specificato.");
}
@ -333,10 +387,80 @@ bool TForm_EC_editor::recalculate_positions(const char* name, int size)
return TRUE;
}
void TForm_EC_editor::remove_temp_items(char sec, pagetype p)
{
TPrint_section* s = form().exist(sec,p);
if (s!=NULL)
{
const word items = s->fields();
for (word j=0;j<items; j++)
{
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;
}
}
}
}
void TForm_EC_editor::hook_footer_to_body(TPrint_section* f, TPrint_section* b)
{
const word items = b->columnwise() ? f->fields() : 0;
const int min_col_id = b->find_first_col();
b->reset_tabs();
for (word i=0;i<items;i++)
{
@ -350,11 +474,7 @@ void TForm_EC_editor::hook_footer_to_body(TPrint_section* f, TPrint_section* b)
fi.hide();
fi.set_x(-1);
} else
{
int x = fb.x()+b->ofspc();
if (id == min_col_id) x++;
fi.set_x(x);
}
fi.set_x(fb.x());
fi.ofs() = 999;
}
}
@ -627,17 +747,17 @@ void TForm_EC_editor::print()
remove = FALSE;
hook_footer_to_body(f,b);
hide_body_items(b);
form().put_examples('H',odd_page);
form().put_examples('F',odd_page);
put_examples('H',odd_page);
put_examples('F',odd_page);
TForm_editor::print();
form().remove_examples('H',odd_page);
form().remove_examples('F',odd_page);
remove_examples('H',odd_page);
remove_examples('F',odd_page);
show_body_items(b);
unhook_footer(f);
if (remove)
{
form().remove_temp_items('G',odd_page);
form().remove_temp_items('H',odd_page);
remove_temp_items('G',odd_page);
remove_temp_items('H',odd_page);
}
}
@ -683,8 +803,7 @@ bool TForm_EC_editor::ask_profile()
if (k == K_ENTER)
{
check_form();
set_form(new TForm(fform, (fcode!=0) ? cod : "", extra() ? 2 :1, fdesc));
form().section_mask() = "sc3100s";
set_form(new TForm_EC(fform, (fcode!=0) ? cod : "", extra() ? 2 :1, fdesc));
break;
}
else if (k == K_DEL)