Modifica 95/24. Gestione dei profili di stampa con font name e size
selezionalbili dall'utente. git-svn-id: svn://10.65.10.50/trunk@1761 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									87f3d41343
								
							
						
					
					
						commit
						7ce6f8d18d
					
				
							
								
								
									
										322
									
								
								include/form.cpp
									
									
									
									
									
								
							
							
						
						
									
										322
									
								
								include/form.cpp
									
									
									
									
									
								
							| @ -1,5 +1,10 @@ | |||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h>      | ||||||
|  | 
 | ||||||
|  | #if XVT_OS == XVT_OS_WIN | ||||||
|  | #define STRICT | ||||||
|  | #include <windows.h> | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| #include <applicat.h> | #include <applicat.h> | ||||||
| #include <form.h> | #include <form.h> | ||||||
| @ -1073,7 +1078,7 @@ class TForm_number : public TForm_string | |||||||
| protected: // TForm_string
 | protected: // TForm_string
 | ||||||
|   virtual const char* class_name() const { return "NUMERO"; } |   virtual const char* class_name() const { return "NUMERO"; } | ||||||
|   virtual bool parse_head(TScanner& scanner); |   virtual bool parse_head(TScanner& scanner); | ||||||
|   virtual bool update(); | virtual bool update(); | ||||||
|   virtual int height() const { return 0; } |   virtual int height() const { return 0; } | ||||||
| 
 | 
 | ||||||
| protected:   | protected:   | ||||||
| @ -1433,10 +1438,51 @@ public: | |||||||
| // TPrint_section
 | // TPrint_section
 | ||||||
| ///////////////////////////////////////////////////////////
 | ///////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
|  | HIDDEN bool font_handler(TMask_field& f, KEY key) | ||||||
|  | { | ||||||
|  |   if (key == K_SPACE) | ||||||
|  |   {                 | ||||||
|  |     main_app().begin_wait();            | ||||||
|  | 
 | ||||||
|  |     const char* family = f.get(); | ||||||
|  |     const int MAXSIZES = 16; | ||||||
|  |     long sizes[MAXSIZES];  | ||||||
|  |     BOOLEAN scalable; | ||||||
|  |     const int num_sizes = (int)xvt_fmap_get_family_sizes(printer().get_printrcd(),  | ||||||
|  |                                                          (char*)family, sizes, &scalable, MAXSIZES); | ||||||
|  |      | ||||||
|  |     TToken_string pn1(80), pn2(80);                                                     | ||||||
|  |     if (scalable) | ||||||
|  |     { | ||||||
|  |       for (int i = 4; i <= 32; i++) | ||||||
|  |       { | ||||||
|  |         pn1.add(i); | ||||||
|  |         pn2.add(i); | ||||||
|  |       }                | ||||||
|  |     }   | ||||||
|  |     else                            | ||||||
|  |     { | ||||||
|  |       if (num_sizes > 0) | ||||||
|  |       { | ||||||
|  |         for (int i = 0; i < num_sizes; i++) | ||||||
|  |           pn1.add(sizes[i]); | ||||||
|  |       } | ||||||
|  |       else pn1.add(printer().get_char_size()); | ||||||
|  |       pn2 = pn1; | ||||||
|  |     } | ||||||
|  |     TList_field& lst = (TList_field&)f.mask().field(F_SIZE); | ||||||
|  |     lst.replace_items(pn1, pn2); | ||||||
|  |     lst.set(format("%d",printer().get_char_size())); | ||||||
|  |      | ||||||
|  |     main_app().end_wait();            | ||||||
|  |   }    | ||||||
|  |   return TRUE; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| TMask* TPrint_section::_msk = NULL; | TMask* TPrint_section::_msk = NULL; | ||||||
| 
 | 
 | ||||||
| TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub)  | TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub)  | ||||||
| : _height(0), _x(0), _y(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE), | : _height(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE), | ||||||
|   _subsection(sub), _repeat_count(0) |   _subsection(sub), _repeat_count(0) | ||||||
| {} | {} | ||||||
| 
 | 
 | ||||||
| @ -1453,8 +1499,6 @@ const TPrint_section& TPrint_section::copy(const TPrint_section& ps) | |||||||
| { | { | ||||||
|   _item = ps._item; |   _item = ps._item; | ||||||
|   _height = ps._height; |   _height = ps._height; | ||||||
|   _x = ps._x; |  | ||||||
|   _y = ps._y; |  | ||||||
|   return ps; |   return ps; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -1471,8 +1515,8 @@ TPrintrow& TPrint_section::row(int num) | |||||||
| 
 | 
 | ||||||
| void TPrint_section::offset(int& x, int& y) const | void TPrint_section::offset(int& x, int& y) const | ||||||
| {                           | {                           | ||||||
|   if (x >= 0) x += _x; |   if (x >= 0) x += form().offset_x(); | ||||||
|   if (y >= 0) y += _y + (_height * _repeat_count); |   if (y >= 0) y += form().offset_y() + (_height * _repeat_count); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -1501,12 +1545,10 @@ TForm_item* TPrint_section::parse_item(TScanner& scanner) | |||||||
|   return parse_item(scanner.key()); |   return parse_item(scanner.key()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| bool TPrint_section::parse(TScanner& scanner) | bool TPrint_section::parse(TScanner& scanner) | ||||||
| { | { | ||||||
|   _height = scanner.integer(); |   _height = scanner.integer();   | ||||||
|   _x = scanner.integer(); |   scanner.integer();scanner.integer(); // Eat offset X and Y of Print_section if present
 | ||||||
|   _y = scanner.integer(); |  | ||||||
| 
 | 
 | ||||||
|   while (scanner.popkey() != "EN") |   while (scanner.popkey() != "EN") | ||||||
|   { |   { | ||||||
| @ -1546,21 +1588,8 @@ bool TPrint_section::update() | |||||||
| bool TPrint_section::read_from(const TRectype& prof) | bool TPrint_section::read_from(const TRectype& prof) | ||||||
| { | { | ||||||
|   CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM"); |   CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM"); | ||||||
|   int i; |  | ||||||
|    |    | ||||||
|   bool changed = FALSE; |   bool changed = FALSE; | ||||||
|   i = prof.get_int("X"); |  | ||||||
|   if (_x != i)  |  | ||||||
|   { |  | ||||||
|     _x = i; |  | ||||||
|     changed = TRUE; |  | ||||||
|   } |  | ||||||
|   i = prof.get_int("Y"); |  | ||||||
|   if (_y != i)  |  | ||||||
|   { |  | ||||||
|     _y = i; |  | ||||||
|     changed = TRUE; |  | ||||||
|   } |  | ||||||
|   const word h = (word)prof.get_int("HGT"); |   const word h = (word)prof.get_int("HGT"); | ||||||
|   if (_height != h)  |   if (_height != h)  | ||||||
|   { |   { | ||||||
| @ -1574,11 +1603,35 @@ void TPrint_section::print_on(TRectype& prof) | |||||||
| { | { | ||||||
|   CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM"); |   CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM"); | ||||||
|   prof.put("ID", 0); |   prof.put("ID", 0); | ||||||
|   prof.put("X", _x); |   prof.put("X", 0); | ||||||
|   prof.put("Y", _x); |   prof.put("Y", 0); | ||||||
|   prof.put("HGT", _height); |   prof.put("HGT", _height); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | typedef struct { | ||||||
|  |   char name_1[80];  // Fontname old
 | ||||||
|  |   char name_2[80];  // Fontname new
 | ||||||
|  |   int  size_1;      // size (height) of old font
 | ||||||
|  |   int  size_2;      // size (height) of new font
 | ||||||
|  |   double ratio;     // ratio (width_old_font/width_new_font)
 | ||||||
|  | } s_data;                 | ||||||
|  | 
 | ||||||
|  | BOOLEAN XVT_CALLCONV1 wpr (long data) | ||||||
|  | {                         | ||||||
|  |   s_data* st =(s_data*)data; | ||||||
|  |   WINDOW prwin = xvt_print_create_win(printer().get_printrcd(),""); | ||||||
|  |   long width_old,width_new; | ||||||
|  |   TString spc(100); | ||||||
|  |   spc.fill('m'); | ||||||
|  |   xvt_set_font(prwin,st->name_1, XVT_FS_NONE, st->size_1);   | ||||||
|  |   width_old = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 100); | ||||||
|  |   xvt_set_font(prwin,st->name_2, XVT_FS_NONE, st->size_2);   | ||||||
|  |   width_new = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 100); | ||||||
|  |   st->ratio = (double)width_old / (double)width_new; | ||||||
|  |   xvt_vobj_destroy(prwin); | ||||||
|  | 
 | ||||||
|  |   return FALSE; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| bool TPrint_section::edit(const char* title) | bool TPrint_section::edit(const char* title) | ||||||
| {                         | {                         | ||||||
| @ -1588,11 +1641,32 @@ bool TPrint_section::edit(const char* title) | |||||||
|   { |   { | ||||||
|     TMask m("ba2100s");   |     TMask m("ba2100s");   | ||||||
|     m.set_caption(title); |     m.set_caption(title); | ||||||
|      |  | ||||||
|     m.set(F_HEIGHT, _height); |     m.set(F_HEIGHT, _height); | ||||||
|     m.set(F_X, _x); |     m.set(F_X, form().offset_x()); | ||||||
|     m.set(F_Y, _y); |     m.set(F_Y, form().offset_y());  | ||||||
|      |      | ||||||
|  |   { | ||||||
|  |     const int MAX_FAMILIES = 128; | ||||||
|  |     char* family[MAX_FAMILIES]; | ||||||
|  |     const int num_families = (int)xvt_fmap_get_families(printer().get_printrcd(), family, MAX_FAMILIES); | ||||||
|  |     bool  font_found = FALSE; | ||||||
|  |     TToken_string pn1(256), pn2(256);                                                     | ||||||
|  | 
 | ||||||
|  |     for (int i = 0; i < num_families; i++) | ||||||
|  |     { | ||||||
|  |       pn1.add(family[i]); | ||||||
|  |       pn2.add(family[i]); | ||||||
|  |       if (!font_found)  | ||||||
|  |         if (form().fontname() == family[i]) font_found = TRUE; | ||||||
|  |       xvt_mem_free(family[i]); | ||||||
|  |     }   | ||||||
|  |     TList_field& lst = (TList_field&)m.field(F_FONT); | ||||||
|  |     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()); | ||||||
|  |   } | ||||||
|  |     printer().set_char_size(form().fontsize()); | ||||||
|  |     m.set_handler(F_FONT,font_handler); | ||||||
|     if (m.run() == K_ESC) |     if (m.run() == K_ESC) | ||||||
|       return FALSE; |       return FALSE; | ||||||
| 
 | 
 | ||||||
| @ -1600,9 +1674,64 @@ bool TPrint_section::edit(const char* title) | |||||||
|      |      | ||||||
|     if (dirty) |     if (dirty) | ||||||
|     { |     { | ||||||
|       _height = m.get_int(F_HEIGHT); |       if (_height != (word)m.get_int(F_HEIGHT) ) | ||||||
|       _x  = m.get_int(F_X); |       { | ||||||
|       _y = m.get_int(F_Y); |         _height = m.get_int(F_HEIGHT); | ||||||
|  |         _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); | ||||||
|  |         form().offset_y() = m.get_int(F_Y); | ||||||
|  |         form().set_dirty(); | ||||||
|  |         _dirty = TRUE; | ||||||
|  |       } | ||||||
|  |        | ||||||
|  |       TString80 name(m.get(F_FONT)); | ||||||
|  |       int size = m.get_int(F_SIZE); | ||||||
|  |       if (name != form().fontname() || size != form().fontsize()) | ||||||
|  |       {    | ||||||
|  |         if (!form().dirty()) form().set_dirty(); | ||||||
|  |         _dirty = TRUE; | ||||||
|  |         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; | ||||||
|  |         // Next 3 lines may be changed
 | ||||||
|  |         xvt_print_open(); | ||||||
|  |         xvt_print_start_thread (wpr, (long)&prm);  | ||||||
|  |         xvt_print_close(); | ||||||
|  | 
 | ||||||
|  |         form().fontname() = name; | ||||||
|  |         form().fontsize() = size;                    | ||||||
|  |         const char sechar[4] = { 'B', 'F', 'G',  'H' }; | ||||||
|  |         for (int sn = 0; sn < 4 ; sn++)  | ||||||
|  |         { | ||||||
|  |           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); | ||||||
|  |                 if (fi.x() > 0 && (prm.ratio != 1.0)) | ||||||
|  |                 { | ||||||
|  |                   real x_pos; | ||||||
|  |                   x_pos = fi.x() * prm.ratio; | ||||||
|  |                   x_pos.round(); | ||||||
|  |                   fi.x() = (short)x_pos.integer(); | ||||||
|  |                   fi.set_dirty(); | ||||||
|  |                 } | ||||||
|  |               } | ||||||
|  |             } | ||||||
|  |           }     | ||||||
|  |         }   | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|    |    | ||||||
| @ -1706,7 +1835,7 @@ void TPrint_section::print_on(ostream& out) const | |||||||
|   default: |   default: | ||||||
|     out << "ODD"; break; |     out << "ODD"; break; | ||||||
|   } |   } | ||||||
|   out << ' ' << _height << ' ' << _x << ' ' << _y << endl << endl; |   out << ' ' << _height << endl << endl; | ||||||
|   for(word i = 0; i < fields(); i++) |   for(word i = 0; i < fields(); i++) | ||||||
|     out << field(i); |     out << field(i); | ||||||
| } | } | ||||||
| @ -1929,6 +2058,39 @@ void TForm::print_description(ostream& out) const | |||||||
|   out << "END\n" << endl; |   out << "END\n" << endl; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | bool TForm::parse_general(TScanner &scanner) | ||||||
|  | { | ||||||
|  |   bool ok = scanner.popkey() == "GE"; | ||||||
|  |   if (ok) | ||||||
|  |   { | ||||||
|  |     while (scanner.pop() != "END") | ||||||
|  |     {   | ||||||
|  |       if (scanner.popkey() == "OF")   // Offsets
 | ||||||
|  |       { | ||||||
|  |         _x = scanner.integer(); | ||||||
|  |         _y = scanner.integer(); | ||||||
|  |       } | ||||||
|  |       else scanner.push();     | ||||||
|  |       if (scanner.popkey() == "FO")   // Font name
 | ||||||
|  |         _fontname = scanner.string(); | ||||||
|  |       else scanner.push();     | ||||||
|  |       if (scanner.popkey() == "SI")   // Font size
 | ||||||
|  |         _fontsize = scanner.integer(); | ||||||
|  |       else scanner.push();     | ||||||
|  |     } | ||||||
|  |   } else scanner.push(); | ||||||
|  |    | ||||||
|  |   return (ok); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void TForm::print_general(ostream& out) const | ||||||
|  | { | ||||||
|  |   out << "GENERAL\nBEGIN\n"; | ||||||
|  |   out << "  OFFSET " << _x << " " << _y << "\n"; | ||||||
|  |   out << "  FONT " << "\"" << _fontname << "\"\n"; | ||||||
|  |   out << "  SIZE " << _fontsize << "\n" ; | ||||||
|  |   out << "END\n" << endl; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| TPrint_section* TForm::exist(char s, pagetype t, bool create) | TPrint_section* TForm::exist(char s, pagetype t, bool create) | ||||||
| { | { | ||||||
| @ -2083,6 +2245,8 @@ bool TForm::print(long from, long to) | |||||||
|   pr.setheaderhandler(header_handler); |   pr.setheaderhandler(header_handler); | ||||||
|   pr.setfooterhandler(footer_handler); |   pr.setfooterhandler(footer_handler); | ||||||
|   pr.formlen(height()); |   pr.formlen(height()); | ||||||
|  |   pr.set_char_size(_fontsize);                     // Set font name and size
 | ||||||
|  |   pr.set_fontname(_fontname);                      // according to current form
 | ||||||
|   const bool was_open = pr.isopen(); |   const bool was_open = pr.isopen(); | ||||||
| 
 | 
 | ||||||
|   _lastpage = FALSE;                               // non e' l'ultima pagina
 |   _lastpage = FALSE;                               // non e' l'ultima pagina
 | ||||||
| @ -2167,7 +2331,9 @@ void TForm::print_on(ostream& out) const | |||||||
|   { |   { | ||||||
|     out << *relation() << "\nEND" << endl; |     out << *relation() << "\nEND" << endl; | ||||||
|     print_description(out); |     print_description(out); | ||||||
|   }   |   } | ||||||
|  |    | ||||||
|  |   print_general(out);   | ||||||
|    |    | ||||||
|   print_section(out, 'G'); |   print_section(out, 'G'); | ||||||
|   print_section(out, 'H'); |   print_section(out, 'H'); | ||||||
| @ -2201,32 +2367,48 @@ word TForm::height() | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| bool TForm::read_profile() | bool TForm::read_profile() | ||||||
| {           | {       | ||||||
|   TLocalisamfile prof(LF_RFORM); |   TLocalisamfile prof(LF_FORM);   | ||||||
|  |   TLocalisamfile rprof(LF_RFORM);  | ||||||
|  |    | ||||||
|   prof.zero(); |   prof.zero(); | ||||||
|   prof.put("TIPOPROF", _name); |   prof.put("TIPOPROF",_name); | ||||||
|   prof.put("CODPROF", _code); |   prof.put("CODPROF",_code); | ||||||
|   const TRectype filter(prof.curr()); |   if (prof.read(_isequal) == NOERR) | ||||||
|    |   { | ||||||
|   for (int err = prof.read(_isgteq); err == NOERR && prof.curr() == filter; err = prof.next()) |     bool complete = FALSE; | ||||||
|   {               |     rprof.zero(); | ||||||
|     const TString& s = prof.get("SEZ");  |     rprof.put("TIPOPROF", _name); | ||||||
|     const char sec = s[0]; |     rprof.put("CODPROF", _code); | ||||||
|     const pagetype pt = char2page(s[1]); |     const TRectype filter(rprof.curr()); | ||||||
|     const short id = prof.get_int("ID"); |  | ||||||
|      |      | ||||||
|     if (id == 0) |     for (int err = rprof.read(_isgteq); err == NOERR && rprof.curr() == filter; err = rprof.next()) | ||||||
|     { |     {               | ||||||
|       TPrint_section& se = section(sec, pt); |       const TString& s = rprof.get("SEZ");  | ||||||
|       se.read_from(prof.curr()); |       const char sec = s[0]; | ||||||
|  |       const pagetype pt = char2page(s[1]); | ||||||
|  |       const short id = rprof.get_int("ID"); | ||||||
|  |        | ||||||
|  |       if (!complete) complete=TRUE; | ||||||
|  |       if (id == 0) | ||||||
|  |       { | ||||||
|  |         TPrint_section& se = section(sec, pt); | ||||||
|  |         se.read_from(rprof.curr()); | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |       { | ||||||
|  |         TForm_item& item = find_field(sec, pt, id); | ||||||
|  |         item.read_from(rprof.curr()); | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|     else |     if (complete) // Get general data from header of form only if it's complete.
 | ||||||
|     { |     {             // Complete means that there's at least a row
 | ||||||
|       TForm_item& item = find_field(sec, pt, id); |       _x = prof.get_int("OFFX"); | ||||||
|       item.read_from(prof.curr()); |       _y = prof.get_int("OFFY"); | ||||||
|  |       _fontname = prof.get("FONTNAME"); | ||||||
|  |       _fontsize = prof.get_int("FONTSIZE"); | ||||||
|     } |     } | ||||||
|   } |   }              | ||||||
|    |  | ||||||
|   return TRUE; |   return TRUE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -2234,6 +2416,23 @@ bool TForm::write_profile() | |||||||
| { | { | ||||||
|   const char sechar[4] = { 'B', 'F', 'G',  'H' }; |   const char sechar[4] = { 'B', 'F', 'G',  'H' }; | ||||||
|    |    | ||||||
|  |   TLocalisamfile form(LF_FORM); | ||||||
|  |   form.zero(); | ||||||
|  |   form.put("TIPOPROF",_name); | ||||||
|  |   form.put("CODPROF",_code); | ||||||
|  |   if (form.read(_isequal,_lock) == NOERR) | ||||||
|  |   { | ||||||
|  |     if (_dirty) | ||||||
|  |     { | ||||||
|  |       form.put("OFFY",_y); | ||||||
|  |       form.put("OFFX",_x); | ||||||
|  |       form.put("FONTNAME",_fontname); | ||||||
|  |       form.put("FONTSIZE",_fontsize); | ||||||
|  |       form.rewrite();     | ||||||
|  |       _dirty=FALSE; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |    | ||||||
|   TLocalisamfile rform(LF_RFORM); |   TLocalisamfile rform(LF_RFORM); | ||||||
|   TRectype& cur = rform.curr();  |   TRectype& cur = rform.curr();  | ||||||
|    |    | ||||||
| @ -2273,7 +2472,7 @@ bool TForm::write_profile() | |||||||
|       }   |       }   | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|    |   form.reread(_unlock); | ||||||
|   if (err != NOERR) |   if (err != NOERR) | ||||||
|     return error_box("Errore di salvataggio profilo: %d", err); |     return error_box("Errore di salvataggio profilo: %d", err); | ||||||
|    |    | ||||||
| @ -2282,7 +2481,8 @@ bool TForm::write_profile() | |||||||
| 
 | 
 | ||||||
| TForm::TForm(const char* name, long code, int lev, const char* desc)  | TForm::TForm(const char* name, long code, int lev, const char* desc)  | ||||||
| : _name(name), _code(code), _relation(NULL), _cursor(NULL), _rel_desc(NULL),  | : _name(name), _code(code), _relation(NULL), _cursor(NULL), _rel_desc(NULL),  | ||||||
|   _isnew(FALSE), _editlevel(lev), _desc(desc) |   _isnew(FALSE), _editlevel(lev), _desc(desc), _fontname("Courier New"), | ||||||
|  |   _fontsize(12), _x(0), _y(0), _dirty(FALSE) | ||||||
| {  | {  | ||||||
|   main_app().begin_wait(); |   main_app().begin_wait(); | ||||||
| 
 | 
 | ||||||
| @ -2301,6 +2501,10 @@ TForm::TForm(const char* name, long code, int lev, const char* desc) | |||||||
|       forms.put("TIPOPROF", _name); |       forms.put("TIPOPROF", _name); | ||||||
|       forms.put("CODPROF", _code);    |       forms.put("CODPROF", _code);    | ||||||
|       forms.put("DESC",    _desc); |       forms.put("DESC",    _desc); | ||||||
|  |       forms.put("OFFY",_y); | ||||||
|  |       forms.put("OFFX",_x); | ||||||
|  |       forms.put("FONTNAME",_fontname); | ||||||
|  |       forms.put("FONTSIZE",_fontsize); | ||||||
|       forms.write(); |       forms.write(); | ||||||
|     }                 |     }                 | ||||||
|     else _desc = forms.get("DESC"); |     else _desc = forms.get("DESC"); | ||||||
| @ -2320,6 +2524,8 @@ TForm::TForm(const char* name, long code, int lev, const char* desc) | |||||||
|     parse_description(scanner);                         // Parse description
 |     parse_description(scanner);                         // Parse description
 | ||||||
|   }  |   }  | ||||||
|   else scanner.push();    |   else scanner.push();    | ||||||
|  |    | ||||||
|  |   if (ok) parse_general(scanner);                       // Parse general
 | ||||||
| 
 | 
 | ||||||
|   while (ok) |   while (ok) | ||||||
|   {                          |   {                          | ||||||
|  | |||||||
| @ -35,7 +35,6 @@ class TPrint_section : public TArray | |||||||
|   static TMask* _msk; |   static TMask* _msk; | ||||||
| 
 | 
 | ||||||
|   word _height;           // Altezza della sezione
 |   word _height;           // Altezza della sezione
 | ||||||
|   int _x, _y;             // Offset di stampa   
 |  | ||||||
|   bool _dirty;            // Flag di modifica parametri
 |   bool _dirty;            // Flag di modifica parametri
 | ||||||
| 
 | 
 | ||||||
|   TForm* _form;           // Form cui appartiene alla sezione
 |   TForm* _form;           // Form cui appartiene alla sezione
 | ||||||
| @ -62,8 +61,6 @@ public: | |||||||
| 
 | 
 | ||||||
|   word fields() const { return _item.items(); } |   word fields() const { return _item.items(); } | ||||||
|   word height() const { return _height; } |   word height() const { return _height; } | ||||||
|   int offset_x() const { return _x; } |  | ||||||
|   int offset_y() const { return _y; } |  | ||||||
|   void offset(int& x, int& y) const; |   void offset(int& x, int& y) const; | ||||||
|   void set_repeat_count(int x) { _repeat_count = x; } |   void set_repeat_count(int x) { _repeat_count = x; } | ||||||
|    |    | ||||||
| @ -93,9 +90,14 @@ public: | |||||||
| class TForm : public TObject | class TForm : public TObject | ||||||
| {                     | {                     | ||||||
|   friend class TForm_editor; |   friend class TForm_editor; | ||||||
|  |   friend class TPrint_section; | ||||||
| 
 | 
 | ||||||
|   TString16 _name;        // Profile name                     
 |   TString16 _name;        // Profile name                     
 | ||||||
|   long      _code;        // Profile code                    
 |   long      _code;        // Profile code                    
 | ||||||
|  |   TString80 _fontname;    // Font name
 | ||||||
|  |   int       _fontsize;    // Font size
 | ||||||
|  |   int       _x, _y;       // Offset validi per tutte le sezioni
 | ||||||
|  |   bool      _dirty;       // Flag per ragistrare i parametri(font ed offset)
 | ||||||
|    |    | ||||||
|   TRelation* _relation;   // Can be NULL
 |   TRelation* _relation;   // Can be NULL
 | ||||||
|   TCursor* _cursor;       // Can be NULL
 |   TCursor* _cursor;       // Can be NULL
 | ||||||
| @ -132,6 +134,9 @@ protected: | |||||||
|   bool parse_description(TScanner&); |   bool parse_description(TScanner&); | ||||||
|   void print_description(ostream& out) const; |   void print_description(ostream& out) const; | ||||||
|    |    | ||||||
|  |   bool parse_general(TScanner&); | ||||||
|  |   void print_general(ostream& out) const; | ||||||
|  |    | ||||||
|   bool read_profile(); |   bool read_profile(); | ||||||
|   bool write_profile(); |   bool write_profile(); | ||||||
|    |    | ||||||
| @ -159,7 +164,13 @@ public: | |||||||
|   virtual bool validate(TForm_item& fld, TToken_string& val); |   virtual bool validate(TForm_item& fld, TToken_string& val); | ||||||
|    |    | ||||||
|   TForm_item& find_field(char sec, pagetype pag, short id) const; |   TForm_item& find_field(char sec, pagetype pag, short id) const; | ||||||
|    |   int& offset_x()  { return _x; } | ||||||
|  |   int& offset_y()  { return _y; } | ||||||
|  |   TString80& fontname() { return _fontname; } | ||||||
|  |   int&  fontsize()   { return _fontsize; } | ||||||
|  |   bool dirty() const { return _dirty; } | ||||||
|  |   void set_dirty(bool d = TRUE) { _dirty = d; } | ||||||
|  | 
 | ||||||
|   // if code == NULL it's a base form
 |   // if code == NULL it's a base form
 | ||||||
|   // otherwise it's integrated by a file definition                                       
 |   // otherwise it's integrated by a file definition                                       
 | ||||||
|   TForm(const char* form, long code = 0L, int editlevel = 0, const char* desc = ""); |   TForm(const char* form, long code = 0L, int editlevel = 0, const char* desc = ""); | ||||||
| @ -219,6 +230,8 @@ public: | |||||||
|   short id() const { return _id; }      |   short id() const { return _id; }      | ||||||
|   virtual int width() const { return _width; }  |   virtual int width() const { return _width; }  | ||||||
|   virtual int height() const { return _height; } |   virtual int height() const { return _height; } | ||||||
|  |   virtual short& x() { return _x; } | ||||||
|  |   virtual short& y() { return _y; } | ||||||
| 
 | 
 | ||||||
|   virtual bool parse(TScanner&); |   virtual bool parse(TScanner&); | ||||||
|   virtual bool update(); |   virtual bool update(); | ||||||
|  | |||||||
| @ -314,6 +314,9 @@ public: | |||||||
|   int         get_char_size()      const { return _ch_size; } |   int         get_char_size()      const { return _ch_size; } | ||||||
|   char*       fontname()           const { return (char*)(const char*)_fontname; } |   char*       fontname()           const { return (char*)(const char*)_fontname; } | ||||||
|    |    | ||||||
|  |   void        set_char_size(int size)    { _ch_size = size; } | ||||||
|  |   void        set_fontname(const char *name) { _fontname = name; } | ||||||
|  |    | ||||||
|   void read_configuration(const char* parag = NULL); |   void read_configuration(const char* parag = NULL); | ||||||
| 
 | 
 | ||||||
|   // bookmarks
 |   // bookmarks
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user