diff --git a/ba/ba2.url b/ba/ba2.url index 80ac815c1..b333b6136 100755 --- a/ba/ba2.url +++ b/ba/ba2.url @@ -29,7 +29,9 @@ MENU BAR_ITEM(1) ITEM MENU_ITEM(11) "~Relazione" ITEM MENU_ITEM(12) "~Parametri" ITEM MENU_ITEM(13) "Caratteri ~fincatura" - ITEM MENU_ITEM(14) "~Cambia profilo" + ITEM MENU_ITEM(14) "~Cambia profilo" + ITEM MENU_ITEM(15) "Imposta formato ~numeri" + ITEM MENU_ITEM(16) "Imposta formato ~date" MENU BAR_ITEM(2) ITEM MENU_ITEM(21) "~Normale" diff --git a/ba/ba2100.cpp b/ba/ba2100.cpp index 144f73d38..5279fa033 100755 --- a/ba/ba2100.cpp +++ b/ba/ba2100.cpp @@ -228,6 +228,10 @@ bool TForm_editor::menu(MENU_TAG tag) case MENU_ITEM(14): quit = ask_profile(); sec = 'B'; pt = odd_page; break; + case MENU_ITEM(15): // formato numeri + sec = 'J'; break; + case MENU_ITEM(16): // formato date + sec = 'Y'; break; case MENU_ITEM(21): sec = 'H'; pt = odd_page; break; case MENU_ITEM(22): @@ -320,6 +324,83 @@ bool TForm_editor::edit_fincatura() return dirty; } +bool TForm_editor::date_example(TMask_field& f, KEY k) +{ + if (k == K_TAB && f.focusdirty()) + { + TMask& m = f.mask(); + char format[6]; + format[0] = m.get(F_DFORMAT)[0]; + format[1] = m.get(F_DDAY )[0]; + format[2] = m.get(F_DMONTH )[0]; + format[3] = m.get(F_DYEAR )[0]; + format[4] = m.get(F_DSEP )[0]; + format[5] = '\0'; + + TDate dd(TODAY); + TFormatted_date d(dd); + + d.set_format(format); + m.set(F_DEXAMPLE, d.string()); + } + return TRUE; +} + +bool TForm_editor::edit_formato_numero() +{ + bool dirty = FALSE; + + TMask m("ba21nm"); + if (dirty = (m.run() == K_ENTER)) + { + int w = m.get_int(F_WIDTH); + int d = m.get_int(F_DECIMALS); + TString p(m.get(F_PICTURE)); + + _form->change_number_format(w, d, p); + } + return dirty; + +} + +bool TForm_editor::edit_formato_data() +{ + bool dirty = FALSE; + char format[6] = { "1444-" }; + TMask m("ba21dt"); + + m.set_handler(F_DFORMAT, date_example); + m.set_handler(F_DDAY, date_example); + m.set_handler(F_DMONTH, date_example); + m.set_handler(F_DYEAR, date_example); + m.set_handler(F_DSEP, date_example); + + TDate dd(TODAY); + TFormatted_date d(dd); + d.set_format(format); + + m.set(F_DFORMAT, "1"); + m.set(F_DDAY, "4"); + m.set(F_DMONTH, "4"); + m.set(F_DYEAR, "4"); + m.set(F_DSEP, "-"); + m.set(F_DEXAMPLE, d.string()); + + if (dirty = (m.run() == K_ENTER)) + { + format[0] = m.get(F_DFORMAT)[0]; + format[1] = m.get(F_DDAY )[0]; + format[2] = m.get(F_DMONTH )[0]; + format[3] = m.get(F_DYEAR )[0]; + format[4] = m.get(F_DSEP )[0]; + format[5] = '\0'; + + _form->change_date_format(format); + } + return dirty; + +} + bool TForm_editor::edit_relation() { TMask m("ba2100r"); @@ -398,6 +479,12 @@ bool TForm_editor::edit(char s, pagetype t) else if (s == 'K') dirty = edit_fincatura(); + else + if (s == 'J') + dirty = edit_formato_numero(); + else + if (s == 'Y') + dirty = edit_formato_data(); else { TString80 caption; diff --git a/ba/baformed.h b/ba/baformed.h index 636258bde..2679b4f50 100755 --- a/ba/baformed.h +++ b/ba/baformed.h @@ -21,12 +21,15 @@ protected: static bool file_handler(TMask_field& f, KEY k); static bool cod_handler(TMask_field&f, KEY k); + static bool date_example(TMask_field&f, KEY k); bool& extra() { return _extra;} void set_form(TForm * f) { _form = f; } bool ask_profile(); bool edit_relation(); bool edit_fincatura(); + bool edit_formato_numero(); + bool edit_formato_data(); bool edit(char s, pagetype p); bool form_config() const; public: diff --git a/include/form.cpp b/include/form.cpp index 75a089a29..25ba4d8be 100755 --- a/include/form.cpp +++ b/include/form.cpp @@ -866,6 +866,8 @@ protected: void put_paragraph(const char* s); public: + + void set_picture(const char* p) { _picture = p; } virtual bool edit(TMask& m); TForm_string(TPrint_section* section) : TForm_item(section) {} virtual ~TForm_string() {} @@ -1097,6 +1099,8 @@ protected: int decimals() const { return _height; } public: + + void set_decimals(int d) { _height = d; } TForm_number(TPrint_section* section) : TForm_string(section) {} virtual ~TForm_number() {} }; @@ -1208,7 +1212,8 @@ protected: virtual void print_on(TRectype& rform); public: - + + void set_format(const char* f) { _format = f; } virtual bool edit(TMask& m); TForm_date(TPrint_section* section); virtual ~TForm_date() {} @@ -2232,7 +2237,73 @@ TPrint_section& TForm::section(char s, word p) TPrint_section* sec = exist(s, pos, TRUE); return *sec; } + +// =========================================== +// TForm +// =========================================== +bool TForm::ps_change_date_format(TPrint_section& s, const char* f) +{ + for (word i = 0; i < s.fields(); i++) + { + TForm_item& fi = s.field(i); + if (strcmp(fi.class_name(), "SEZIONE") == 0) + { + TPrint_section& ps = ((TForm_subsection&)fi).subsection(); + ps_change_date_format(ps, f); + } + else if (strcmp(fi.class_name(), "DATA") == 0) + ((TForm_date&)fi).set_format(f); + } + return TRUE; +} + +bool TForm::ps_change_number_format(TPrint_section& s, int w, int dec, const char* p) +{ + for (word i = 0; i < s.fields(); i++) + { + TForm_item& fi = s.field(i); + if (strcmp(fi.class_name(), "SEZIONE") == 0) + { + TPrint_section& ps = ((TForm_subsection&)fi).subsection(); + ps_change_number_format(ps, w, dec, p); + } + else if (strcmp(fi.class_name(), "NUMERO") == 0) + { + TForm_number& fn = (TForm_number&)fi; + fn.set_width(w); + fn.set_decimals(dec); + fn.set_picture(p); + } + } + return TRUE; +} + + +void TForm::change_date_format(const char* f) +{ + char secs[] = { "FHGB" }; + char ptyp[] = { "LOEF" }; + 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_date_format(*ps, f); +} + +void TForm::change_number_format(int w, int dec, const char* p) +{ + char secs[] = { "FHGB" }; + char ptyp[] = { "LOEF" }; + 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); +} + word TForm::set_background(word p, bool u) { word len = 0; diff --git a/include/form.h b/include/form.h index a12f8ccdc..650edbae9 100755 --- a/include/form.h +++ b/include/form.h @@ -127,7 +127,12 @@ class TForm : public TObject TToken_string& get_fincatura() { return _fink; } void set_fincatura(const char* s) { _fink = s; } - + + // come sotto ma per printsection, all'uopo di chiamarle + // con ricorsiva insistenza + bool ps_change_date_format(TPrint_section& s, const char* f); + bool ps_change_number_format(TPrint_section& s, int w, int dec, const char* p); + protected: // H = Header, B = Body, F = Footer, R = Relation TPrint_section& section(char s = 'B', word page = 1); @@ -191,7 +196,12 @@ public: bool dirty() const { return _dirty; } void set_dirty(bool d = TRUE) { _dirty = d; } void set_arrange(bool arng = TRUE) { _arrange = arng ; } - + + // cambia il formato di tutte le date nel form + void change_date_format(const char* f); + // cambia il formato di tutti i numeri nel form + void change_number_format(int w, int dec, const char* p); + // fincazione char f_topleft() { return _fink.get_char(0); } char f_topmiddle() { return _fink.get_char(1); } @@ -263,6 +273,7 @@ protected: public: short id() const { return _id; } virtual int width() const { return _width; } + virtual void set_width(int w) { _width = w; } virtual int height() const { return _height; } virtual short& x() { return _x; } virtual short& y() { return _y; }