Generazione automatica fincatura; aggiunto BOX, corrette cazzatelle
git-svn-id: svn://10.65.10.50/trunk@2296 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									cd274bfec5
								
							
						
					
					
						commit
						70c3e5a7bc
					
				
							
								
								
									
										129
									
								
								include/form.cpp
									
									
									
									
									
								
							
							
						
						
									
										129
									
								
								include/form.cpp
									
									
									
									
									
								
							| @ -278,7 +278,7 @@ void TForm_flags::read_from(const TMask& m) | ||||
|   enabled   = !m.get_bool(F_DISABLED); | ||||
|   automagic = m.get_bool(F_AUTOMAGIC); | ||||
|   finkl     = !m.get_bool(F_FINKL); | ||||
|   finkr     = !m.get_bool(F_FINKL); | ||||
|   finkr     = !m.get_bool(F_FINKR); | ||||
| } | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| @ -1729,7 +1729,7 @@ protected: | ||||
|   virtual bool update(); | ||||
| 
 | ||||
| public: | ||||
|   TForm_picture(TGraphic_section* section) : TForm_item(section) {}; | ||||
|   TForm_picture(TGraphic_section* section) : TForm_item(section) {} | ||||
|   virtual ~TForm_picture() {} | ||||
| }; | ||||
| 
 | ||||
| @ -1740,10 +1740,21 @@ protected: | ||||
|   virtual bool update(); | ||||
| 
 | ||||
| public: | ||||
|   TForm_line(TGraphic_section* section) : TForm_item(section) {}; | ||||
|   TForm_line(TGraphic_section* section) : TForm_item(section) {} | ||||
|   virtual ~TForm_line() {} | ||||
| }; | ||||
| 
 | ||||
| class TForm_box : public TForm_item | ||||
| { | ||||
| protected: | ||||
|   virtual const char* class_name() const { return "BOX"; } | ||||
|   virtual bool update(); | ||||
| 
 | ||||
| public: | ||||
|   TForm_box(TGraphic_section* section) : TForm_item(section) {} | ||||
|   virtual ~TForm_box() {} | ||||
| }; | ||||
| 
 | ||||
| bool TForm_picture::update() | ||||
| {                         | ||||
|   const bool ok = _prompt.not_empty(); | ||||
| @ -1768,6 +1779,18 @@ bool TForm_line::update() | ||||
|   return TRUE; | ||||
| } | ||||
| 
 | ||||
| bool TForm_box::update() | ||||
| {                                         | ||||
|   TString80 i; | ||||
|   const int w = _prompt[0] == '@' ? 3 : 1;  | ||||
|   i << 'W' << w << "b{" << _x << ',' << _y << ',' | ||||
|     << (_x+width()-1) << ',' << (_y+height()-1) << '}'; | ||||
|    | ||||
|   ((TGraphic_section&)section()).append(i); | ||||
|   return TRUE; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| TForm_item* TGraphic_section::parse_item(const TString& s) | ||||
| { | ||||
| @ -1775,6 +1798,8 @@ TForm_item* TGraphic_section::parse_item(const TString& s) | ||||
|     return new TForm_picture(this); | ||||
|   else if (s == "LI") | ||||
|     return new TForm_line(this); | ||||
|   else if (s == "BO") | ||||
|     return new TForm_box(this); | ||||
| 
 | ||||
|   error_box("Campo di stampa non ammesso per lo sfondo: %s", (const char*)s); | ||||
|   return NULL;   | ||||
| @ -1838,7 +1863,7 @@ TMask* TPrint_section::_msk = NULL; | ||||
| 
 | ||||
| TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub)  | ||||
| : _height(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE), | ||||
|   _subsection(sub), _repeat_count(0) | ||||
|   _subsection(sub), _repeat_count(0), _ofspc(0), _nfld(0) | ||||
| { _tab[0] = -1; } | ||||
| 
 | ||||
| TPrint_section::~TPrint_section() | ||||
| @ -1860,6 +1885,11 @@ void  TPrint_section::insert_field(int n, TForm_item* f) | ||||
|   _item.insert(f,n); | ||||
| } | ||||
| 
 | ||||
| void  TPrint_section::add_field(TForm_item* f) | ||||
| {   | ||||
|   _item.add(f); | ||||
| } | ||||
| 
 | ||||
| const TPrint_section& TPrint_section::copy(const TPrint_section& ps) | ||||
| { | ||||
|   _item = ps._item; | ||||
| @ -1886,7 +1916,7 @@ int TPrint_section::tab(int col) | ||||
|     if (_tab[0] == -1)   | ||||
|     { | ||||
|       // compute column offset 
 | ||||
|       word nfld = 0;    | ||||
|       _nfld = 0;    | ||||
|       _tab[0] = 1; | ||||
|       for (word i = 0; i < fields(); i++)  | ||||
|       {                                                                     | ||||
| @ -1894,12 +1924,12 @@ int TPrint_section::tab(int col) | ||||
|         {                  | ||||
|           CHECKD (field(i)._x < MAXCOLUMNS, "Colonna ammessa e non concessa: ", field(i)._x); | ||||
|           _tab[field(i)._x] = field(i).width() + 1; // one is for separation 
 | ||||
|           nfld++; | ||||
|           _nfld++; | ||||
|         } | ||||
|       }                    | ||||
|       // cumulate offsets
 | ||||
|       for (i = 1; i < nfld; i++) | ||||
|         _tab[i] += _tab[i-1]; | ||||
|       for (i = 1; i < _nfld; i++) | ||||
|         _tab[i] += _tab[i-1];   | ||||
|     } | ||||
|     ret = _tab[col]; | ||||
|   }     | ||||
| @ -1910,7 +1940,7 @@ void TPrint_section::offset(int& x, int& y) | ||||
| {  | ||||
|   if (x >= 0) | ||||
|   { | ||||
|     if (_columnwise) x = tab(x-1); | ||||
|     if (_columnwise) x = tab(x-1) + _ofspc; | ||||
|     x += form().offset_x(); | ||||
|   } | ||||
|   if (y >= 0) y += form().offset_y() + (_height * _repeat_count); | ||||
| @ -2239,6 +2269,8 @@ bool TPrint_section::detail_field_notify (TSheet_field& s, int r, KEY k) | ||||
|         fff = new TForm_group(&sec); | ||||
|       else if (typ == "LINEA") | ||||
|         fff = new TForm_line((TGraphic_section*)&sec); | ||||
|       else if (typ == "BOX") | ||||
|         fff = new TForm_box((TGraphic_section*)&sec); | ||||
|       else if (typ == "FIGURA") | ||||
|         fff = new TForm_picture((TGraphic_section*)&sec); | ||||
|         | ||||
| @ -2279,7 +2311,12 @@ bool TPrint_section::edit(const char* title) | ||||
|     m.set(F_IPY, form().ipy()); | ||||
|     m.set(F_FPX, form().fpx()); | ||||
|     m.set(F_FLEN, printer().formlen()); | ||||
|     | ||||
|     m.set(F_OFSPC, _ofspc); | ||||
|      | ||||
|     // still unused: will need to be shown if section is columnwise; no 
 | ||||
|     // provision for saving yet (should be in form, with a field for each pos) 
 | ||||
|     m.hide(F_OFSPC); | ||||
|      | ||||
|     TSheet_field& ms = (TSheet_field&)m.field(F_FIELDS); | ||||
|      | ||||
|     if (_columnwise) | ||||
| @ -2355,6 +2392,11 @@ bool TPrint_section::edit(const char* title) | ||||
|         _height = m.get_int(F_HEIGHT); | ||||
|         _dirty=TRUE; | ||||
|       } | ||||
|       if (_ofspc != (word)m.get_int(F_OFSPC) ) | ||||
|       { | ||||
|         _ofspc = m.get_int(F_OFSPC); | ||||
|         _dirty=TRUE; | ||||
|       } | ||||
|       if (m.get_int(F_X) != form().offset_x() || m.get_int(F_Y) != form().offset_y()) | ||||
|       { | ||||
|         form().offset_x() = m.get_int(F_X); | ||||
| @ -2754,7 +2796,7 @@ bool TForm::ps_change_number_format(TPrint_section& s, int w, int dec, const cha | ||||
|     else if (strcmp(fi.class_name(), "NUMERO") == 0)  | ||||
|     { | ||||
|       TForm_number& fn = (TForm_number&)fi;  | ||||
|       fn.set_width(w); | ||||
|       fn.width() = w; | ||||
|       fn.set_decimals(dec); | ||||
|       fn.set_picture(p); | ||||
|     } | ||||
| @ -2955,8 +2997,70 @@ long TForm::records() const | ||||
| {              | ||||
|   const long r = cursor() ? cursor()->items() : 0; | ||||
|   return r; | ||||
| }                                                                         | ||||
| 
 | ||||
| bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows) | ||||
| { | ||||
|   const TPrint_section* body = exist('B', p); | ||||
|   if (body == NULL) return FALSE;       | ||||
|    | ||||
|   TGraphic_section* grs = (TGraphic_section*)exist('G', p, TRUE); | ||||
|   word j = 0, start = 999, end = 0, wlast = 0; | ||||
|   word cols[MAXCOLUMNS]; | ||||
|    | ||||
|   for (word i = 0; i < body->fields(); i++) | ||||
|   { | ||||
|     TForm_item& f = body->field(i); | ||||
|     if (!f.shown()) continue; | ||||
|      | ||||
|     word x = f.x();  | ||||
|      | ||||
|     if (x < start) start = x; | ||||
|     if (x > end)   { end = x; wlast = f.width(); } | ||||
|     cols[j++] = x; | ||||
|   } | ||||
|    | ||||
|   // inner lines
 | ||||
|   for (i = 0; i < j; i++) | ||||
|   { | ||||
|     if (cols[i] != start) | ||||
|     { | ||||
|       TForm_line* l = new TForm_line(grs); | ||||
|       l->x()      = cols[i]-1; | ||||
|       l->y()      = (word)y1; | ||||
|       l->width()  = 0; | ||||
|       l->height() = (int)(y2 - y1 + 1); | ||||
|       grs->add_field(l); | ||||
|     } | ||||
|   }   | ||||
|    | ||||
|   // box around
 | ||||
|   if (start != 999 && end != 0) | ||||
|   { | ||||
|     TForm_box* l = new TForm_box(grs); | ||||
|     l->x()      = start; | ||||
|     l->y()      = (word)y1; | ||||
|     l->width()  = (int)(end + wlast - start + 1); | ||||
|     l->height() = (int)(y2 - y1 + 1); | ||||
|     grs->add_field(l); | ||||
|   }                    | ||||
|    | ||||
|   // horizontal lines 
 | ||||
|   if (start != 999 && end != 0) | ||||
|     for (i = 0; rows[i]; i++) | ||||
|     {  | ||||
|       TForm_line* l = new TForm_line(grs); | ||||
|       l->x()      = start; | ||||
|       l->y()      = (word)rows[i]; | ||||
|       l->width()  = (int)(end + wlast - start + 1); | ||||
|       l->height() = 0; | ||||
|       grs->add_field(l); | ||||
|     } | ||||
|    | ||||
|   return TRUE; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // Stampa gli items dal from a to
 | ||||
| // se to < 0 stampa fino alla fine del file
 | ||||
| 
 | ||||
| @ -3270,7 +3374,8 @@ void TForm::init() | ||||
|   _arrange= TRUE; | ||||
|   _fink= "+,+,+,+,+,+,+,+,+,-,|"; | ||||
|   _fink.separator(','); | ||||
|   _dirty= FALSE; | ||||
|   _dirty= FALSE;                          | ||||
|   _background_mode = printer().isgraphics() ? graphics : text; | ||||
| } | ||||
| 
 | ||||
| void TForm::read(const char* name, const char* code, int lev, const char* desc) | ||||
|  | ||||
| @ -37,12 +37,17 @@ class TSheet_field; | ||||
| class TForm_item; | ||||
| class TPrint_section; | ||||
| 
 | ||||
| const int MAXCOLUMNS = 32; | ||||
| 
 | ||||
| class TForm : public TObject | ||||
| {                     | ||||
|   friend class TForm_editor; | ||||
|   friend class TPrint_section; | ||||
| 
 | ||||
|   enum bkg_mode  | ||||
|     { none, text, graphics }  | ||||
|     _background_mode; | ||||
| 
 | ||||
|   TString   _name;        // Profile name                     
 | ||||
|   TString   _code;        // Profile code                    
 | ||||
|   TString   _fontname;    // Font name
 | ||||
| @ -120,6 +125,12 @@ protected: | ||||
|   virtual word set_footer(word p, bool u); | ||||
|    | ||||
| public:                | ||||
|                                         | ||||
|   // genera automaticamente la sezione grafica con colonne fincate
 | ||||
|   // parametri: posizione pagina, prima e ultima Y per le righe
 | ||||
|   // verticali, array di posizioni riga con 0 per finire  
 | ||||
|   // ritorna FALSE se non c'e' il body per quella pagina                                   
 | ||||
|   bool genera_fincatura(pagetype p, int y1, int y2,  int* rows); | ||||
| 
 | ||||
|   bool print(long from = 0L, long to = -1L); | ||||
|    | ||||
| @ -212,9 +223,10 @@ public: | ||||
| class TPrint_section : public TArray | ||||
| { | ||||
|   static TMask* _msk;     | ||||
|   enum { MAXCOLUMNS = 32 }; | ||||
| 
 | ||||
|   word _height;           // Altezza della sezione
 | ||||
|   word _ofspc;            // Offset prima colonna (still ignored)
 | ||||
|   word _nfld;             // number of columns if columnwise
 | ||||
|   bool _dirty;            // Flag di modifica parametri
 | ||||
|   bool _columnwise;       // Columnwise field specification
 | ||||
|    | ||||
| @ -250,9 +262,12 @@ public: | ||||
|   TForm_item& find_field(short id) const; | ||||
|   void        destroy_field(int n) {  _item.destroy(n, TRUE);  } | ||||
|   void        change_field(int n, TForm_item* f); | ||||
|   void        insert_field(int n, TForm_item* f); | ||||
|   void        insert_field(int n, TForm_item* f);                  | ||||
|   void        add_field(TForm_item* f); | ||||
|    | ||||
|   word fields() const { return _item.items(); } | ||||
|   // returns 0 if not columnwise; means n. of printable fields             
 | ||||
|   word columns()      { tab(0); return _nfld; } | ||||
|   word height() const { return _height; } | ||||
|   void offset(int& x, int& y); | ||||
|   void set_repeat_count(int x) { _repeat_count = x; } | ||||
| @ -285,7 +300,6 @@ public: | ||||
| class TForm_item : public TObject | ||||
| { | ||||
|   friend class TPrint_section; | ||||
| 
 | ||||
|   TPrint_section* _section; | ||||
|   TForm_flags _flag; | ||||
|   TBit_array _group; | ||||
| @ -314,8 +328,9 @@ public: | ||||
| 
 | ||||
|   short id() const { return _id; }      | ||||
|   virtual int width() const { return _width; }  | ||||
|   virtual void set_width(int w) { _width = w; }  | ||||
|   virtual short& width() { return _width; }  | ||||
|   virtual int height() const { return _height; } | ||||
|   virtual short& height() { return _height; } | ||||
|   virtual short& ofs() { return _ofs; } | ||||
|   virtual int effective_height() const { return _effective_height; } | ||||
|    | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user