Files correlati : ba0.exe Ricompilazione Demo : [ ] Commento : Migliorata gestione sfondi git-svn-id: svn://10.65.10.50/trunk@20562 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			3500 lines
		
	
	
		
			84 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			3500 lines
		
	
	
		
			84 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| //EDITOR DI MASCHERE
 | ||
| #include <xvt.h>
 | ||
| #include "ba2600.h"
 | ||
| 
 | ||
| //Costruttore della classe TEditMask_window: gestisce la maschera
 | ||
| TEditMask_window::TEditMask_window(short x,short y,short dx,short dy,
 | ||
|      const char*title,long flags, WIN_TYPE wt)      
 | ||
| {
 | ||
|    create(x,y,dx,dy,title,flags,wt);
 | ||
|    _controllo=NULL;
 | ||
|    _controls=NULL;
 | ||
|    _pixmap=TRUE;   
 | ||
|    set_font();   
 | ||
|    _sheet=NULL;
 | ||
|    _total_page=_page=1;    
 | ||
|    _name.add(TR("Maschera"),0);  
 | ||
|    _name.add(TR("Maschera"),1);  
 | ||
|    _type_vz="a";      _coordx=x;
 | ||
|    _coordy=y;         _alt=dy;
 | ||
|    _lung=dx;       
 | ||
|    _tool=FALSE;    
 | ||
|    _mode=TRUE;
 | ||
|    _y_tool=19;
 | ||
|    _rt.left=_rt.right=_rt.bottom=0;
 | ||
|    _rt.top=_y_tool*ROWY; 
 | ||
|    _rct_sel.left=_rct_sel.top=_rct_sel.bottom=_rct_sel.right=0;
 | ||
|    _nsheet=0;
 | ||
| }  
 | ||
| 
 | ||
| //Permette il ridimensionamento 
 | ||
| RCT& TEditMask_window::resize_rect(short x, short y, short dx, short dy, 
 | ||
|                                    WIN_TYPE wt, bool intool) const
 | ||
| {
 | ||
|   static RCT r;      
 | ||
|   
 | ||
|     if (_tool) // Mask with Toolbar
 | ||
|     {
 | ||
|       if (y >= 0) 
 | ||
|       {    
 | ||
| /*      Scommentare quando verranno inseriti i tab buttons
 | ||
|         if (_total_page>1)
 | ||
|           y++;
 | ||
| */          
 | ||
|       }  
 | ||
|       if (x > 0 || (wt != WO_TE && x == 0))
 | ||
|       { 
 | ||
|         RCT pc; xvt_vobj_get_client_rect(win(), &pc);        
 | ||
|         const int width = pc.right;               
 | ||
|         const int tot = 80*CHARX;
 | ||
|         if (width > tot) x += (width-tot) / (2*CHARX);
 | ||
|       }
 | ||
|     }
 | ||
|     wt = WC_TEXTEDIT;
 | ||
| 
 | ||
|     r.left   = (x+1)*CHARX;
 | ||
|     r.top    = y*ROWY;
 | ||
|     r.right  = dx*CHARX;
 | ||
|     r.bottom = (CHARY << 1) - (CHARY-2);
 | ||
|     
 | ||
|     if (y >= 0 && _tool && intool)
 | ||
|       r.top += ROWY*_y_tool;
 | ||
|     
 | ||
|     if (dy > 1)
 | ||
|       r.bottom += ROWY*(dy-1);
 | ||
| 
 | ||
|   if (x < 0 || y < 0 || dx <= 0 || dy <= 0)
 | ||
|   {
 | ||
|     RCT pc;
 | ||
|     xvt_vobj_get_client_rect(win(), &pc);   
 | ||
|     const short MAXX = pc.right;
 | ||
|     const short MAXY = (_tool && !intool) ? ROWY*_y_tool : pc.bottom;
 | ||
| 
 | ||
|     if (x < 0)
 | ||
|     {
 | ||
|       x = -x;
 | ||
|       if (wt != WC_TEXTEDIT && x == 1) x = 11;
 | ||
|       if (x > 10)
 | ||
|       {
 | ||
|         const int num = x/10 -1;
 | ||
|         const int tot = x%10;
 | ||
|         const int spc = (MAXX - tot*r.right) / (tot+1);
 | ||
|         r.left = spc + num*(spc+r.right);
 | ||
|       }
 | ||
|       else
 | ||
|         r.left = MAXX - r.right - x*CHARX;
 | ||
|     }
 | ||
| 
 | ||
|     if (y < 0)
 | ||
|     {
 | ||
|       y = -y;
 | ||
|       if (wt != WC_TEXTEDIT && y == 1) y = 11;
 | ||
|       if (y > 10)
 | ||
|       {
 | ||
|         const int num = y/10 -1;
 | ||
|         const int tot = y%10;
 | ||
|         const int spc = (MAXY - tot*r.bottom) / (tot+1);
 | ||
|         r.top = spc + num*(spc+r.bottom);
 | ||
|       }
 | ||
|       else
 | ||
|         r.top = MAXY - r.bottom - (y-1)*ROWY;
 | ||
|     }
 | ||
| 
 | ||
|     if (dx <= 0) r.right = MAXX + dx*CHARX;
 | ||
|     else r.right += r.left;
 | ||
|     if (dy <= 0) r.bottom = MAXY + dy*ROWY;
 | ||
|     else r.bottom += r.top;
 | ||
|   }
 | ||
|   else
 | ||
|   {
 | ||
|     r.right += r.left;
 | ||
|     r.bottom += r.top;
 | ||
|   }
 | ||
|   return r;
 | ||
| }
 | ||
| 
 | ||
| //Costruttore della classe TEditMask_control che gestisce i controlli
 | ||
| TEditMask_control::TEditMask_control(TEditMask_window* parent)
 | ||
| {  
 | ||
| 
 | ||
|    _intool=FALSE;
 | ||
|    _parent=parent;  
 | ||
|    _pag=parent->page();  
 | ||
|    _left=_top=1;  
 | ||
|    _latox=15;      
 | ||
|    _latoy=1;          
 | ||
|    resize_rect();
 | ||
|    _id="DLG_USER";
 | ||
|    _type_field="control";
 | ||
|    _selected=FALSE;
 | ||
|    _focus=0;
 | ||
| }
 | ||
| 
 | ||
| //Costruttore della classe TEditMask_control per definirne la copia
 | ||
| TEditMask_control::TEditMask_control(const TEditMask_control& ctl)
 | ||
| {  
 | ||
|    _intool=ctl._intool;
 | ||
|    _parent=ctl._parent;
 | ||
|    _focus=ctl._focus;
 | ||
|    _pag=ctl._pag;          _rct=ctl._rct;
 | ||
|    _left=ctl._left;        _top=ctl._top;
 | ||
|    _prompt=ctl._prompt;    _id=ctl._id;
 | ||
|    _latox=ctl._latox;      _latoy=ctl._latoy;  
 | ||
|    _field=ctl._field;      _key=ctl._key; 
 | ||
|    _warning=ctl._warning;  _check=ctl._check;
 | ||
|    _flag=ctl._flag;        _group=ctl._group; 
 | ||
|    _message=ctl._message; 
 | ||
|    _selected=ctl._selected;
 | ||
|    _type_field=ctl._type_field;  
 | ||
| } 
 | ||
| 
 | ||
| //Permette il riordino dei controlli in base alla priorit<69> del focus 
 | ||
| static int compare(const TObject** o1,const TObject** o2) 
 | ||
| {                                             
 | ||
|   if (o1 == o2)
 | ||
|     return 0; 
 | ||
| 
 | ||
|   TEditMask_control* s1 = (TEditMask_control*)*o1;
 | ||
|   TEditMask_control* s2 = (TEditMask_control*)*o2;
 | ||
|   return (s1->get_focus() - s2->get_focus());
 | ||
| }
 | ||
| 
 | ||
| //Ricerca durante la lettura la maschera corrispondente allo spread numero i
 | ||
| TEditMask_control* TEditMask_window::find_sheet(int i)
 | ||
| {
 | ||
|    for(int j=0; j<_controls.items(); j++) 
 | ||
|    {
 | ||
|      TEditMask_control& sh=(TEditMask_control& )_controls[j];
 | ||
|      if (sh.get_idsheet()==i) 
 | ||
|        return &sh;
 | ||
|    }                    
 | ||
|   return NULL;
 | ||
| }
 | ||
| 
 | ||
| //Definisce la presenza di pagine prive di controlli
 | ||
| int TEditMask_window::page_null(int page) 
 | ||
| {
 | ||
|    bool cont=FALSE;
 | ||
|       
 | ||
|    for(int i=0; i<_controls.items(); i++) 
 | ||
|    {
 | ||
|      TEditMask_control& down=(TEditMask_control& )_controls[i];
 | ||
|      if (down.page()==page)
 | ||
|      {
 | ||
|        cont=TRUE; 
 | ||
|        break;
 | ||
|      }  
 | ||
|    }
 | ||
|     return cont;
 | ||
| } 
 | ||
| 
 | ||
| //Salva su file la scrittura delle pagine
 | ||
| void TEditMask_window::save_page(ostream& out)
 | ||
| {
 | ||
|    RCT r={_rt.top,0,_rt.bottom,_rt.right}; 
 | ||
| 
 | ||
|    _controls.sort(compare);//ordinamento secondo la priorit<69> focus
 | ||
| 
 | ||
|    for (int k=1; k <= _total_page ; k++)
 | ||
|    {
 | ||
|      if (page_null(k)) 
 | ||
|      {
 | ||
|        out << "PAGE \""<< _name[k] <<"\" "<< _coordx <<" " <<_coordy;
 | ||
|        out << " " <<_lung <<" " <<_alt << "\n\n";
 | ||
|        for(int i=0; i<_controls.items(); i++) 
 | ||
|        {
 | ||
|          TEditMask_control& up=(TEditMask_control& )_controls[i];
 | ||
|          if(up.page()==k)  {
 | ||
|            PNT p={up.rectangle().top,up.rectangle().left};
 | ||
|            if(up.type()=="BUTTON  ")
 | ||
|            {
 | ||
|              TString tipo=up.ident();
 | ||
|              if(tipo=="DLG_OK" || tipo=="DLG_CANCEL" ||\
 | ||
|                 tipo=="DLG_DELREC" ||tipo=="DLG_QUIT" || tipo=="DLG_PRINT" ||\
 | ||
|                 tipo=="DLG_SELECT")   up.set_prompt("");
 | ||
|            }     
 | ||
|            if(xvt_rect_has_point(&r,p) != 0)  ;
 | ||
|            else out<<_controls[i]; 
 | ||
|          }
 | ||
|        } 
 | ||
|        out << "ENDPAGE\n\n";     
 | ||
|      } 
 | ||
|    }
 | ||
|    out << "\nENDMASK\n\n";
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Creazione del file .uml
 | ||
| void TEditMask_window::create_file()
 | ||
| { 
 | ||
|    _file.lower();
 | ||
|    _file.ext("uml");                       
 | ||
|    ofstream file(_file); 
 | ||
|    RCT r={_rt.top,0,_rt.bottom,_rt.right};                               
 | ||
|    _file.ext("h");
 | ||
| 
 | ||
|    file<<"#include \"" << _file<<"\"\n\n";
 | ||
|    _file.ext("uml");
 | ||
|    int k=101;
 | ||
|   
 | ||
|    
 | ||
|    if(_tool) 
 | ||
|    { 
 | ||
|      file<<"TOOLBAR  \"TOOLBAR\" 0 "<<_y_tool<<" 0 0\n\n";
 | ||
|      for(int i=0; i<_controls.items(); i++)   
 | ||
|      {  //i controlli della toolbar
 | ||
|        TEditMask_control& up=(TEditMask_control& )_controls[i];
 | ||
|        PNT p={up.rectangle().top,up.rectangle().left};
 | ||
|        if(up.type()=="BUTTON  ")
 | ||
|        {
 | ||
|          TString tipo=up.ident();
 | ||
|          if (tipo=="DLG_OK" || tipo=="DLG_CANCEL" ||
 | ||
|                 tipo=="DLG_DELREC" ||tipo=="DLG_QUIT" || tipo=="DLG_PRINT" ||
 | ||
|                   tipo=="DLG_SELECT")   
 | ||
|             up.set_prompt("");
 | ||
|        }     
 | ||
|        if(xvt_rect_has_point(&r,p) != 0)
 | ||
|          file<<_controls[i];
 | ||
|      }
 | ||
|      file<<"ENDPAGE\n\n";     
 | ||
|    }
 | ||
|    save_page(file);  //controlli della finestra principale
 | ||
|    
 | ||
|    for(int i=0; i<_controls.items(); i++)   //controlli dello spread
 | ||
|    {
 | ||
|      TEditMask_control& up=(TEditMask_control& )_controls[i];
 | ||
|      if(up.figlio()!=NULL)
 | ||
|        up.figlio()->save_page(file);      
 | ||
|    }  
 | ||
|    
 | ||
|    file.close();    
 | ||
| }
 | ||
| 
 | ||
| //Creazione del file .h
 | ||
| void TEditMask_window::create_fileh()
 | ||
| { 
 | ||
|   TFilename header(_file);
 | ||
|   header.lower();
 | ||
|   header.ext("h");
 | ||
|   ofstream fileh(header); 
 | ||
|   int k=101;
 | ||
|      
 | ||
|   for(int i=0; i<_controls.items(); i++)  
 | ||
|   {
 | ||
|     TEditMask_control& up=(TEditMask_control& )_controls[i];
 | ||
|     if(up.ident()!=("DLG_NULL")) 
 | ||
|     {
 | ||
|       fileh<<"#define  "<<up.ident()<< "    "<< k <<'\n';
 | ||
|       k++; 
 | ||
|     }
 | ||
|   } 
 | ||
| }
 | ||
| 
 | ||
| //Definizione di un controllo disabilitato o nascosto
 | ||
| int TEditMask_control::flag_crt() const
 | ||
| {
 | ||
|    if(_flag.find('H')!=-1 || _flag.find('h')!=-1)
 | ||
|      return 1; 
 | ||
|    if(_flag.find('D')!=-1 || _flag.find('d')!=-1)
 | ||
|      return 2;
 | ||
|    
 | ||
|    return 0;  
 | ||
| }             
 | ||
| 
 | ||
| //Ridimensiona le coordinate e le dimensioni del controllo <TEditMask_window::resize_rect(..)>
 | ||
| RCT& TEditMask_control::resize_rect(short x, short y, short dx, short dy, WIN_TYPE wt,bool intool)const
 | ||
| {  
 | ||
|   return  _parent->resize_rect(x,y,dx,dy,wt,intool);
 | ||
| }
 | ||
| 
 | ||
| //Ridimensiona come sopra
 | ||
| void TEditMask_control::resize_rect()
 | ||
| {  
 | ||
|    set_dim(_latox,_latoy);                                
 | ||
| }
 | ||
| 
 | ||
| //Definisce il padre
 | ||
| TEditMask_window& TEditMask_control::padre() const
 | ||
| {
 | ||
|    CHECK(_parent,"Campo senza maschera");
 | ||
|     return *_parent;
 | ||
| }
 | ||
| 
 | ||
| //Setta il prompt
 | ||
| const TString& TEditMask_control::set_prompt(const TString& prompt) 
 | ||
| {
 | ||
|    return _prompt=(prompt);
 | ||
| }
 | ||
| 
 | ||
| //Setta il tipo di controllo
 | ||
| const TString& TEditMask_control::set_type(const TString& fld)
 | ||
| {
 | ||
|    return _type_field=(fld);
 | ||
| }
 | ||
| 
 | ||
| //Setta l'identificativo
 | ||
| const TString& TEditMask_control::set_id(const TString& id)
 | ||
| { 
 | ||
|    return _id=(id);
 | ||
| }            
 | ||
| 
 | ||
| //Setta il campo FLAGS
 | ||
| const TString& TEditMask_control::set_flag(const TString& fl)
 | ||
| { 
 | ||
|    return _flag=(fl);
 | ||
| }            
 | ||
| 
 | ||
| //Setta il campo GROUP
 | ||
| const TString& TEditMask_control::set_group(const TString& gr)
 | ||
| { 
 | ||
|    return _group=(gr);
 | ||
| }            
 | ||
| 
 | ||
| //Setta il campo CHECKTYPE
 | ||
| const TString& TEditMask_control::set_check(const TString& ck)
 | ||
| { 
 | ||
|    return  _check=(ck);
 | ||
| }            
 | ||
| 
 | ||
| //Setta il flag relativo alla selezione
 | ||
| bool TEditMask_control::set_selected(bool sl)
 | ||
| {
 | ||
|    _selected=sl; 
 | ||
|     return _selected;
 | ||
| }
 | ||
| 
 | ||
| //Disegna linee
 | ||
| void TEditMask_control::line(short x0,short y0,short x1,short y1) const
 | ||
| {
 | ||
|    PNT f = {y0,x0};
 | ||
|    PNT t = {y1,x1};
 | ||
| 
 | ||
|    xvt_dwin_draw_set_pos(maschera(), f);
 | ||
|    xvt_dwin_draw_line(maschera(), t);
 | ||
| }
 | ||
| 
 | ||
| //Scrive il prompt sul controllo
 | ||
| void TEditMask_control::frase(short x, short y) const
 | ||
| {
 | ||
|    padre().stringat(x, y,_prompt);
 | ||
| } 
 | ||
| 
 | ||
| //Setta i campi comuni sulla maschera di supporto
 | ||
| void TEditMask_control::set_field(TMask& mask)
 | ||
| {
 | ||
|    mask.set(F_PROMPT,_prompt);
 | ||
|    mask.set(F_PAGE,_pag);
 | ||
|    mask.set(F_FOCUS,_focus);
 | ||
|    mask.set(F_IDENT,_id);        
 | ||
|    mask.set(F_LEFT,_left);   
 | ||
|    mask.set(F_UPPER,_top); 
 | ||
|    mask.set(F_INTOOL,_intool ? "X" : " "); 
 | ||
| } 
 | ||
| 
 | ||
| //Legge i MESSAGE dalla maschera di supporto
 | ||
| void TEditMask_control::get_message(TSheet_field& sp)
 | ||
| {
 | ||
|    _message=sp.rows_array();
 | ||
| } 
 | ||
| 
 | ||
| //Setta i MESSAGE sulla maschera di supporto
 | ||
| void TEditMask_control::set_message(TSheet_field& sp)
 | ||
| {
 | ||
|    sp.rows_array()=_message;
 | ||
| } 
 | ||
| 
 | ||
| //Stampa su file.uml i MESSAGE
 | ||
| void TEditMask_control::print_message(ostream& out)const
 | ||
| {   
 | ||
|    TToken_string mes;
 | ||
|    
 | ||
|    for(int i=0;i<_message.items();i++) 
 | ||
|    {
 | ||
|      mes=_message.row(i);
 | ||
|      if(!mes.blank())
 | ||
|      {
 | ||
|        mes.replace('^','|');
 | ||
|        out<<"  MESSAGE "<< mes <<"\n";   
 | ||
|      } 
 | ||
|    }  
 | ||
| } 
 | ||
| 
 | ||
| //Setta i campi opzionali comuni sulla maschera di supporto
 | ||
| void TEditMask_control::set_option(TMask& mask)
 | ||
| {  
 | ||
|    mask.set(F_FLAG,_flag);
 | ||
|    mask.set(F_GROUP,_group);
 | ||
|    mask.set(F_WARNING,_warning);
 | ||
|    mask.set(F_CHECK,_check);
 | ||
|    mask.set(F_KEY,_key); 
 | ||
|    mask.set(F_FIELD,_field);
 | ||
| } 
 | ||
| 
 | ||
| //Legge i campi comuni dalla maschera di supporto
 | ||
| void TEditMask_control::get_field(TMask& mask)
 | ||
| { 
 | ||
|    _prompt=mask.get(F_PROMPT); 
 | ||
|    _focus=mask.get_int(F_FOCUS);
 | ||
|    _left=mask.get_int(F_LEFT);
 | ||
|    _top=mask.get_int(F_UPPER);
 | ||
|    _pag=mask.get_int(F_PAGE);
 | ||
|    _id=mask.get(F_IDENT);          
 | ||
|    _intool=mask.get_bool(F_INTOOL);
 | ||
|    
 | ||
|    _pag=_parent->max_page(_pag); 
 | ||
| }        
 | ||
| 
 | ||
| //Setta le dimensioni del controllo
 | ||
| void TEditMask_control::set_dim(int ln, int lg)
 | ||
| {           
 | ||
|    _latox = ln; 
 | ||
|    _latoy = lg; 
 | ||
|    _rct = resize_rect(_left,_top,_latox,_latoy,WO_TE,_intool);
 | ||
| }
 | ||
| 
 | ||
| //Setta le coordinate del controllo
 | ||
| void TEditMask_control::set_crd(int x, int y)
 | ||
| { 
 | ||
|    _left = x;
 | ||
|    _top = y;
 | ||
| }
 | ||
| 
 | ||
| //Legge dalla maschera di supporto i campi comuni opzionali
 | ||
| void TEditMask_control::get_option(TMask& mask)
 | ||
| {
 | ||
|    _flag=mask.get(F_FLAG);
 | ||
|    _group=mask.get(F_GROUP);
 | ||
|    _warning=mask.get(F_WARNING);
 | ||
|    _check=mask.get(F_CHECK);
 | ||
|    _key=mask.get(F_KEY); 
 | ||
|    _field=mask.get(F_FIELD);
 | ||
| }
 | ||
| 
 | ||
| //Stampa su file .uml il controllo(i campi comuni e particolari)
 | ||
| void TEditMask_control::print_on(ostream& out) const
 | ||
| { 
 | ||
|   char c;               
 | ||
|     
 | ||
|   out<<" BEGIN"<<"\n" ;
 | ||
|   out<<"  PROMPT " << _left << " " <<_top<<" \""; 
 | ||
|   
 | ||
|   out<<_prompt;
 | ||
|   for(int i=off(); i > 0; i--)
 | ||
|     out << ' '; 
 | ||
|   out<<"\"\n";  
 | ||
|      
 | ||
|   if(_flag.not_empty()) 
 | ||
|   {              
 | ||
|     for(int j=0;j<_flag.len();j++)  
 | ||
|     {
 | ||
|       c=toupper(_flag.operator[](j));
 | ||
|       if (c!=' ') 
 | ||
|         out<<"  FLAGS "<<"\""<< c <<"\"\n";
 | ||
|     }
 | ||
|   }
 | ||
|      
 | ||
|   print_message(out); 
 | ||
|      
 | ||
|   if(_group.not_empty())
 | ||
|     out<<"  GROUP "<<_group<<"\n";
 | ||
|      
 | ||
|   if(_field.not_empty())
 | ||
|   {
 | ||
|     out<<"  FIELD ";
 | ||
|     for(int f=0;f<_field.len();f++)  
 | ||
|     {
 | ||
|       c=toupper(_field.operator[](f));
 | ||
|       out<<c;
 | ||
|     } 
 | ||
|     out<<"\n";
 | ||
|   }
 | ||
|        
 | ||
|   if(_key.not_empty())
 | ||
|     out<<"  KEY "<<_key<<"\n";
 | ||
|   
 | ||
|      
 | ||
|   if(_check.not_empty())
 | ||
|   {
 | ||
|     if(_check!=("a"))
 | ||
|       out<<"  CHECKTYPE ";
 | ||
|     if (_check==("b")) out << "NORMAL\n";
 | ||
|     if (_check==("c")) out << "REQUIRED\n";
 | ||
|     if (_check==("d")) out << "SEARCH\n";
 | ||
|     if (_check==("e")) out << "FORCED\n";
 | ||
|   }                                
 | ||
|                                      
 | ||
|   if(_warning.not_empty())
 | ||
|     out<<"  WARNING \"" << _warning << "\"\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml lecaratteristiche comuni dei controlli
 | ||
| void TEditMask_control::read_field(TScanner& scanner,const TString& tok,bool intool)
 | ||
| {
 | ||
|    TString s; 
 | ||
|    
 | ||
|    if(tok=="PROMPT")
 | ||
|    {
 | ||
|      _left = scanner.integer();   
 | ||
|      _top = scanner.integer();    
 | ||
|      _prompt = scanner.string();
 | ||
|      _intool = intool;
 | ||
|      _rct = resize_rect(_left,_top,_latox,_latoy,WO_TE,intool);
 | ||
|    }          
 | ||
| 
 | ||
|    if(tok=="FLAGS" || tok=="WARNING")   
 | ||
|    {                                  
 | ||
|      s=(scanner.string()); 
 | ||
|      if(tok=="FLAGS") 
 | ||
|        _flag <<' '<<(s); 
 | ||
|      else  _warning=(s);
 | ||
|    }  
 | ||
| 
 | ||
|    if(tok=="KEY" || tok=="FIELD" ||\
 | ||
|       tok=="GROUP" || tok=="MESSAGE")
 | ||
|    {
 | ||
|      TString kf=scanner.line();
 | ||
| 
 | ||
|      if(tok=="KEY")   _key <<(kf); 
 | ||
|      else if(tok=="FIELD") _field=(kf);
 | ||
|        else if(tok=="GROUP") _group <<' '<<(kf);
 | ||
|          else
 | ||
|          {
 | ||
|            kf.replace('|','^');
 | ||
|            _message.add(kf);
 | ||
|          }  
 | ||
|    }
 | ||
|      
 | ||
|    if(tok=="CHECKTYPE")  
 | ||
|    {
 | ||
|      s=scanner.pop();
 | ||
|      if(s==("NORMAL"))   set_check("b");  
 | ||
|      if(s==("REQUIRED")) set_check("c");
 | ||
|      if(s==("SEARCH"))   set_check("d");
 | ||
|      if(s==("FORCED"))   set_check("e");
 | ||
|    }
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_string :controllo tipo STRING
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo STRING
 | ||
| TEditMask_string::TEditMask_string(TEditMask_window* parent):
 | ||
|                   TEditMask_control(parent)
 | ||
| { 
 | ||
|    _lungvd=_lungsz=15;
 | ||
|    _lngspt=0;
 | ||
|    _offset = 1;
 | ||
|    set_prompt(PR("Stringa"));      
 | ||
|    set_type("STRING  ");
 | ||
|    set_id("F_STRING"); 
 | ||
|    set_dim(_lungvd+prompt_len()+off(),1);
 | ||
| }                  
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_string::TEditMask_string(const TEditMask_string& ctl):
 | ||
|                   TEditMask_control(ctl)
 | ||
| { 
 | ||
|    _lungvd=_lungsz=ctl._lungvd;
 | ||
|    _lngspt=ctl._lngspt;
 | ||
|    _offset =ctl._offset;
 | ||
|    set_prompt(ctl.prt());      
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    set_dim(_lungvd+prompt_len()+off(),1);
 | ||
| }                  
 | ||
| 
 | ||
| //Setta l'offset
 | ||
| void TEditMask_string::set_offset(int d)
 | ||
| { 
 | ||
|    _offset=d;
 | ||
| }
 | ||
| 
 | ||
| //Controlla l'assenza di valori per le lunghezze
 | ||
| void TEditMask_string::error_lung(int lsz, int lvd)
 | ||
| {
 | ||
|    if(lsz==0) _lungsz=8;
 | ||
|    if (_lungvd<=0) 
 | ||
|    {
 | ||
|      _lungvd=_lungsz;
 | ||
|      _lngspt=0; 
 | ||
|    }
 | ||
|    else _lngspt=_lungvd;
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_string::update()const
 | ||
| {
 | ||
|    RCT r=rectangle();
 | ||
|    int lenght=prompt_len()*CHARX;
 | ||
|    int off=_offset*CHARX;
 | ||
|     
 | ||
|    RCT ret={r.top,r.left+lenght+off,r.bottom-(CHARY-2)/8,r.right};
 | ||
|    
 | ||
|    padre().set_pen(COLOR_BLACK);
 | ||
|    if(flag_crt()==2) padre().set_brush(MASK_BACK_COLOR);
 | ||
|    else padre().set_brush(NORMAL_BACK_COLOR);
 | ||
|    xvt_dwin_draw_rect(maschera(),&ret);
 | ||
|     
 | ||
|    padre().hide_brush();
 | ||
|    frase(r.left,r.top);
 | ||
| }        
 | ||
| 
 | ||
| //Setta solo browse e offset sulla maschera di supporto
 | ||
| void TEditMask_string::set_bwoff(TMask& m)
 | ||
| {  
 | ||
|    m.set(F_USE,_use);       
 | ||
|    m.set(F_OFFSET,_offset);
 | ||
| }                          
 | ||
| 
 | ||
| //Setta solo le lunghezze sulla maschera di supporto
 | ||
| void TEditMask_string::set_lngz(TMask& m)
 | ||
| {  
 | ||
|    m.set(F_LONGEFF,_lungsz);       
 | ||
|    m.set(F_LONGEVD,_lungvd);
 | ||
| }                          
 | ||
| 
 | ||
| //Legge dalla maschera di supporto solo le lunghezze
 | ||
| void TEditMask_string::get_lngz(TMask& m)
 | ||
| {
 | ||
|    _lungsz=m.get_int(F_LONGEFF);       
 | ||
|    _lungvd=m.get_int(F_LONGEVD);   
 | ||
|    error_lung(_lungsz,_lungvd);
 | ||
| }
 | ||
| 
 | ||
| //Legge dalla maschera di supporto solo browse e offset
 | ||
| void TEditMask_string::get_bwoff(TMask& m)
 | ||
| {
 | ||
|    _use=m.get(F_USE);       
 | ||
|    _offset=m.get_int(F_OFFSET);
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_string::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600g");
 | ||
|    TSheet_field& s=_mask.sfield(F_MESSAGE);
 | ||
|    
 | ||
|    set_lngz(_mask);
 | ||
|    _mask.set(F_ADDR,_addr);
 | ||
|    set_bwoff(_mask);             
 | ||
|    set_field(_mask);             
 | ||
|    set_option(_mask);              
 | ||
|    set_message(s);
 | ||
|    KEY k = _mask.run();
 | ||
|    if (k == K_ENTER)
 | ||
|    {
 | ||
|      get_lngz(_mask);
 | ||
|      get_message(s);
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);   
 | ||
|      get_bwoff(_mask);
 | ||
|      _addr=_mask.get(F_ADDR);
 | ||
|      set_dim(_lungvd+prompt_len()+off(),1);  
 | ||
|    }
 | ||
| 
 | ||
|     return k;
 | ||
| }                                           
 | ||
| 
 | ||
| //Stampa su file .uml solo le lunghezze
 | ||
| void TEditMask_string::print_lngz(ostream& out) const
 | ||
| {
 | ||
|    if(_lngspt<=0)
 | ||
|      out << _lungsz <<'\n';
 | ||
|    else  
 | ||
|      out<< _lungsz <<' '<< _lungvd <<'\n';
 | ||
| }
 | ||
| 
 | ||
| //Stampa su file .uml solo il browse
 | ||
| void TEditMask_string::print_use(ostream& out)const
 | ||
| {   
 | ||
|    TString in;
 | ||
|    
 | ||
|    if(_use.not_empty())
 | ||
|    { 
 | ||
|      for(int k=0;;k++)
 | ||
|      {
 | ||
|        int y;
 | ||
|        for(y = 0;_use[k]!='\n' && _use[k];k++,y++)
 | ||
|          in[y]=_use[k];
 | ||
|        in[y]='\0';
 | ||
|        out<<"  "<< in <<"\n";
 | ||
|        if(!_use[k]) break;
 | ||
|      }       
 | ||
|    } 
 | ||
| } 
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_string::print_on(ostream& out) const
 | ||
| { 
 | ||
|    out<<type()<< ident() << ' ';
 | ||
|    print_lngz(out);
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    if(_addr.not_empty())
 | ||
|      out<<"  ADD RUN "<<_addr<<"\n";
 | ||
|    print_use(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml solo i valori delle lunghezze
 | ||
| void TEditMask_string::read_lngz(TScanner& scanner)
 | ||
| {
 | ||
|    _lungsz=scanner.integer();
 | ||
|    if(_lungsz<=0) _lungsz=8;
 | ||
|    _lungvd=scanner.integer(); 
 | ||
|    if(_lungvd <=0 )
 | ||
|    {
 | ||
|      _lungvd=_lungsz;
 | ||
|      _lngspt=0;
 | ||
|    }
 | ||
|    else _lngspt=_lungvd;  
 | ||
| }   
 | ||
| 
 | ||
| //Legge da file .uml solo l'offset
 | ||
| int TEditMask_string::read_off(const TString& prt)
 | ||
| {
 | ||
|    int off=0;
 | ||
| 
 | ||
|    for(int i = prt.len()-1; i >= 0 && !isalpha(prt[i]) && !ispunct(prt[i]); i--)
 | ||
|      off++;
 | ||
|   return _offset=off;   
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml solo il browse
 | ||
| void TEditMask_string::read_use(TScanner& scanner,const TString& tok)
 | ||
| {
 | ||
|    if(tok=="USE" || tok=="JOIN" || tok=="INPUT" ||\
 | ||
|       tok=="OUTPUT" || tok=="DISPLAY" || tok=="COPY")
 | ||
|    {  
 | ||
|      _use <<(tok);
 | ||
|      _use <<(' ');
 | ||
|      _use <<(scanner.line());
 | ||
|      _use <<('\n'); 
 | ||
|    }  
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_string::read_from(TScanner& scanner, bool intool)
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop());
 | ||
|    read_lngz(scanner);
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok, intool);
 | ||
|      read_use(scanner,tok);
 | ||
|      if(tok=="ADD")    
 | ||
|      {
 | ||
|        tok=scanner.pop();
 | ||
|        tok=scanner.pop();
 | ||
|        _addr=(tok);
 | ||
|      }
 | ||
|      tok=scanner.pop();
 | ||
|    }  
 | ||
|    tok=prt();  read_off(tok);  tok.rtrim();  set_prompt(tok);
 | ||
|    set_dim(_lungvd+prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_number :controllo tipo NUMBER
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo NUMBER
 | ||
| TEditMask_number::TEditMask_number(TEditMask_window* parent)
 | ||
|                                    :TEditMask_string(parent)
 | ||
| {
 | ||
|    _latox=10;   
 | ||
|    _decimals=0;                     
 | ||
|    set_prompt(PR("Numero"));
 | ||
|    set_type("NUMBER  ");
 | ||
|    set_id("F_NUMBER");
 | ||
|    set_dim(_latox + prompt_len() + off(),1);
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_number::TEditMask_number(const TEditMask_number& ctl)
 | ||
|                                    :TEditMask_string(ctl)
 | ||
| {
 | ||
|    _latox=ctl._latox;   
 | ||
|    _decimals=ctl._decimals;                     
 | ||
|    _picture=ctl._picture;
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    set_dim(_latox + prompt_len() + off(),1);
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Setta i decimali
 | ||
| void TEditMask_number::set_decimal(int d)
 | ||
| { 
 | ||
|    _decimals=d;
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_number::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600r");
 | ||
|    TSheet_field& s=_mask.sfield(F_MESSAGE);
 | ||
|    
 | ||
|    _mask.set(F_LONGEFF,_latox);
 | ||
|    _mask.set(F_PICTURE,_picture);
 | ||
|    _mask.set(F_DECIMAL,_decimals);
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    set_message(s);
 | ||
|    set_bwoff(_mask);
 | ||
|    KEY k = _mask.run();
 | ||
|    if (k == K_ENTER)
 | ||
|    {
 | ||
|      get_message(s);
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);
 | ||
|      get_bwoff(_mask);          
 | ||
|      _latox=_mask.get_int(F_LONGEFF);
 | ||
|      _picture=_mask.get(F_PICTURE);  
 | ||
|      _decimals=_mask.get_int(F_DECIMAL);
 | ||
|      set_dim(_latox + prompt_len() + off(),1);
 | ||
|    }
 | ||
|     return k;
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_number::print_on(ostream& out) const
 | ||
| { 
 | ||
|    if(_decimals<=0)
 | ||
|      out<<type()<<ident() << "  "<< _latox <<'\n';
 | ||
|    else  
 | ||
|      out<<type()<<ident() << "  "<< _latox <<"  "<<_decimals<<'\n';
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    if(_picture.not_empty())
 | ||
|      out<<"  PICTURE \""<<_picture<<"\"\n";
 | ||
|    print_use(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_number::read_from(TScanner& scanner,bool intool)
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop());          
 | ||
|    _latox=scanner.integer();
 | ||
|    _decimals=scanner.integer(); 
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      read_use(scanner,tok);
 | ||
|      if(tok=="PICTURE") 
 | ||
|        _picture=(scanner.string());
 | ||
|      tok=scanner.pop();
 | ||
|    }             
 | ||
| 
 | ||
|    tok=prt();  read_off(tok);  tok.rtrim();  set_prompt(tok);
 | ||
|    set_dim(_latox+prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| const TString& TEditMask_number::set_picture(const TString& pic) 
 | ||
| {
 | ||
|    return _picture=(pic);
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_currency :controllo tipo CURRENCY
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo CURRENCY
 | ||
| TEditMask_currency::TEditMask_currency(TEditMask_window* parent)
 | ||
|                                    :TEditMask_number(parent)
 | ||
| {
 | ||
|    _latox=10;   
 | ||
|    set_picture("");
 | ||
|    set_prompt(PR("Valuta  "));
 | ||
|    set_type("CURRENCY  ");
 | ||
|    set_id("F_CUR");
 | ||
|    set_dim(_latox + prompt_len(),1);
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_currency::TEditMask_currency(const TEditMask_currency& ctl)
 | ||
|                                    :TEditMask_number(ctl)
 | ||
| {
 | ||
|    _latox=ctl._latox;   
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    set_dim(_latox + prompt_len(),1);
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_currency::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600y");
 | ||
|    TSheet_field& s=_mask.sfield(F_MESSAGE);
 | ||
|    
 | ||
|    _mask.set(F_LONGEFF,_latox);
 | ||
|    _mask.set(F_PICTURE,_picture);
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    set_message(s);
 | ||
|    set_bwoff(_mask);
 | ||
|    KEY k = _mask.run();
 | ||
|    if (k == K_ENTER)
 | ||
|    {
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);
 | ||
|      get_message(s);
 | ||
|      get_bwoff(_mask);          
 | ||
|      _latox=_mask.get_int(F_LONGEFF);
 | ||
|      _picture=_mask.get(F_PICTURE);  
 | ||
|      set_picture(_picture);
 | ||
|      set_dim(_latox + prompt_len() + off(),1);
 | ||
|    }
 | ||
|     return k;
 | ||
| }             
 | ||
|    
 | ||
| void TEditMask_currency::read_from(TScanner& scanner,bool intool)
 | ||
| {
 | ||
|    TEditMask_number::read_from(scanner,intool);
 | ||
|    set_decimal(0);
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_date :controllo tipo DATE
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo DATE
 | ||
| TEditMask_date::TEditMask_date(TEditMask_window* parent)
 | ||
|       :TEditMask_string(parent)
 | ||
| {
 | ||
|    set_prompt(PR("Data"));
 | ||
|    set_type("DATE  ");
 | ||
|    set_dim(10+prompt_len()+off(),1);
 | ||
|    set_id("F_DATE");
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_date::TEditMask_date(const TEditMask_date& ctl)
 | ||
|       :TEditMask_string(ctl)
 | ||
| {
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    set_dim(10+prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_date::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600e");
 | ||
|    TSheet_field& s=_mask.sfield(F_MESSAGE);
 | ||
|    
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    set_message(s);
 | ||
|    set_bwoff(_mask);
 | ||
|    KEY k= _mask.run();      
 | ||
|    if(k==K_ENTER) 
 | ||
|    {
 | ||
|      get_field(_mask); 
 | ||
|      get_option(_mask);
 | ||
|      get_message(s);
 | ||
|      get_bwoff(_mask);    
 | ||
|      set_dim(12 + prompt_len() + off(),1);  
 | ||
|    }     
 | ||
|     return k;
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_date::print_on(ostream& out) const
 | ||
| { 
 | ||
|    TString id=ident(); 
 | ||
|    
 | ||
|    out<<type()<<ident() <<"\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    print_use(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_date::read_from(TScanner& scanner,bool intool)
 | ||
| {
 | ||
|    TString id,tok;
 | ||
| 
 | ||
|    set_id(scanner.pop());
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      read_use(scanner,tok);
 | ||
|      tok=scanner.pop();
 | ||
|    }  
 | ||
|    tok=prt();  read_off(tok);  tok.rtrim();  set_prompt(tok);
 | ||
|    set_dim(12+prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_boolean :controllo tipo BOOLEAN
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo BOOLEAN
 | ||
| TEditMask_boolean::TEditMask_boolean(TEditMask_window* parent)
 | ||
|       :TEditMask_control(parent)
 | ||
| {
 | ||
|    set_type("BOOLEAN  ");
 | ||
|    set_id("F_CHECK");
 | ||
|    set_prompt(PR("Booleano "));
 | ||
|    set_dim(prompt_len()+2,1);
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_boolean::TEditMask_boolean(const TEditMask_boolean& ctl)
 | ||
|       :TEditMask_control(ctl)
 | ||
| {
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_dim(prompt_len()+2,1);
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_boolean::update()const
 | ||
| {
 | ||
|    RCT r=rectangle();   
 | ||
|    int lato=(r.bottom - r.top)/2;
 | ||
|    r.bottom=r.top+(CHARY-2);
 | ||
|    int top = r.top;
 | ||
|    r.top = r.bottom - lato;
 | ||
|    
 | ||
|    padre().set_pen(MASK_LIGHT_COLOR);
 | ||
|    line(r.left,r.top,r.left+lato,r.top);
 | ||
|    line(r.left,r.top,r.left,r.bottom);
 | ||
| 
 | ||
|    padre().set_pen(MASK_DARK_COLOR);
 | ||
|    line(r.left+lato,r.top,r.left+lato,r.bottom);
 | ||
|    line(r.left,r.bottom,r.left+lato,r.bottom);
 | ||
| 
 | ||
|    padre().set_pen(COLOR_BLACK);
 | ||
|    frase(r.left+lato+CHARX,top);
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_boolean::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600k");
 | ||
|    TSheet_field& s=_mask.sfield(116);
 | ||
|   
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    set_message(s);
 | ||
|    KEY k= _mask.run();
 | ||
|    if(k==K_ENTER) 
 | ||
|    {
 | ||
|      get_field(_mask); 
 | ||
|      get_option(_mask);
 | ||
|      get_message(s);
 | ||
|      set_dim(prompt_len()+2,1);
 | ||
|    } 
 | ||
|     return k;
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_boolean::print_on(ostream& out) const
 | ||
| { 
 | ||
|    out<<type()<<ident()<< "\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_boolean::read_from(TScanner& scanner,bool intool)  
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop());
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      tok=scanner.pop();
 | ||
|    }  
 | ||
|    set_dim(prompt_len()+2,1);
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_text :controllo tipo TEXT
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo TEXT
 | ||
| TEditMask_text::TEditMask_text(TEditMask_window* parent)
 | ||
|              :TEditMask_string(parent)
 | ||
| {
 | ||
|    set_prompt(PR("Testo"));
 | ||
|    set_dim(prompt_len(),1);
 | ||
|    set_type("TEXT  ");
 | ||
|    set_id("DLG_NULL");
 | ||
|    set_focus(-1);
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_text::TEditMask_text(const TEditMask_text& ctl)
 | ||
|              :TEditMask_string(ctl)
 | ||
| {
 | ||
|    _flag=ctl._flag;
 | ||
|    _group=ctl._group;
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    set_dim(prompt_len(),1);
 | ||
|    set_focus(-1);
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_text::update() const
 | ||
| {
 | ||
|    RCT r=rectangle();
 | ||
|    if(flag_crt()==2) padre().set_pen(MASK_BACK_COLOR);
 | ||
|    else padre().set_pen(COLOR_BLACK);
 | ||
|    frase(r.left,r.top);
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_text::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600t");
 | ||
|   
 | ||
|    set_field(_mask);
 | ||
|    _mask.set(F_FLAG,_flag);
 | ||
|    _mask.set(F_GROUP,_group);
 | ||
|    KEY k= _mask.run();
 | ||
|    if(k==K_ENTER) {
 | ||
|      get_field(_mask);       
 | ||
|      _flag=_mask.get(F_FLAG);   
 | ||
|      _group=_mask.get(F_GROUP);       
 | ||
|      set_flag(_flag);
 | ||
|      set_group(_group);
 | ||
|      set_dim(prompt_len(),1);  
 | ||
|    } 
 | ||
|     return k;
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_text::print_on(ostream& out) const
 | ||
| { 
 | ||
|    
 | ||
|    out<<type()<< ident() <<"\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_text::read_from(TScanner& scanner,bool intool)
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop()); 
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      tok=scanner.pop();
 | ||
|    }  
 | ||
|    set_dim(prompt_len(),1);
 | ||
| } 
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_button :controllo tipo BUTTON
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore
 | ||
| TEditMask_button::TEditMask_button(TEditMask_window* parent)
 | ||
|     :TEditMask_control(parent)
 | ||
| {
 | ||
|    _latox=10;
 | ||
|    _latoy=2;
 | ||
|    
 | ||
|    set_prompt(FR("Bottone"));
 | ||
|    set_type("BUTTON  ");
 | ||
|    set_id("DLG_NULL");
 | ||
|    set_dim(_latox+2,_latoy);
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_button::TEditMask_button(const TEditMask_button& ctl)
 | ||
|     :TEditMask_control(ctl)
 | ||
| {
 | ||
|    _latox=ctl._latox;
 | ||
|    _latoy=ctl._latoy;
 | ||
|    
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    set_dim(_latox+2,_latoy);
 | ||
| }
 | ||
| 
 | ||
| //Definisce i bottoni standard
 | ||
| void TEditMask_button::type_button(const TString& id,const TString& pr)
 | ||
| {
 | ||
|     if(pr=="")
 | ||
|     {
 | ||
| //      if(id=="DLG_NULL") ;
 | ||
|       if(id=="DLG_OK")     set_prompt(BR("Conferma", 9)) ;
 | ||
| 			else
 | ||
| 				if(id=="DLG_CANCEL") set_prompt(BR("Annulla", 9));
 | ||
| 				else
 | ||
| 					if(id=="DLG_DELREC") set_prompt(BR("Elimina", 9));
 | ||
| 					else
 | ||
| 						if(id=="DLG_QUIT")   set_prompt(BR("Fine", 9));    
 | ||
| 						else
 | ||
| 				      if(id=="DLG_PRINT")  set_prompt(BR("Stampa", 9));
 | ||
| 							else
 | ||
| 								if(id=="DLG_SELECT") set_prompt(BR("Seleziona", 9));
 | ||
|     }
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_button::update()const
 | ||
| {
 | ||
|    RCT rt=rectangle();           
 | ||
|    RCT r={rt.top,rt.left,rt.bottom-(CHARY-2)/2,rt.right}; 
 | ||
|    int lenght=prompt_len()*CHARX;
 | ||
|    int latol=(r.right-r.left);
 | ||
|    int posfx=(latol-lenght)/2;
 | ||
|    int posfy=((r.bottom-r.top)/2);
 | ||
|    
 | ||
|    if(flag_crt()==2) padre().set_brush(DISABLED_BACK_COLOR);
 | ||
|    else padre().set_brush(BTN_BACK_COLOR);
 | ||
|    xvt_dwin_draw_rect(maschera(),&r);
 | ||
| 
 | ||
|    padre().set_pen(BTN_LIGHT_COLOR,2);
 | ||
|    line(r.left+2,r.top+2,r.right-2,r.top+2);
 | ||
|    line(r.left+2,r.top+2,r.left+2,r.bottom-2);
 | ||
| 
 | ||
|    padre().set_pen(BTN_DARK_COLOR,2);
 | ||
|    line(r.right-2,r.top+2,r.right-2,r.bottom-2);
 | ||
|    line(r.left+2,r.bottom-2,r.right-2,r.bottom-2);
 | ||
|    padre().set_pen(COLOR_BLACK,1);
 | ||
|    frase(r.left+posfx,r.top+posfy-10);
 | ||
|         
 | ||
| }                         
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_button::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600n");  
 | ||
|    TSheet_field& s=_mask.sfield(F_MESSAGE);
 | ||
| 
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    set_message(s);
 | ||
|    _mask.set(F_LONGEFF,_latox);
 | ||
|    _mask.set(F_LARGE,_latoy);
 | ||
|    KEY k= _mask.run();      
 | ||
|    if(k==K_ENTER) {
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);      
 | ||
|      get_message(s);
 | ||
|      _latox=_mask.get_int(F_LONGEFF);
 | ||
|      _latoy=_mask.get_int(F_LARGE);        
 | ||
|      set_dim(_latox+2,_latoy); 
 | ||
|      type_button(ident(),prt());
 | ||
|    }                                          
 | ||
| 
 | ||
|     return k;                        
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_button::print_on(ostream& out) const     
 | ||
| { 
 | ||
|    const TString tipo=prt();
 | ||
|    
 | ||
|    out<<type()<<ident()<<" "<<_latox<<" "<<_latoy<<"\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge fa dile .uml il controllo
 | ||
| void TEditMask_button::read_from(TScanner& scanner,bool intool)  
 | ||
| {
 | ||
|    TString id,tok;
 | ||
|    
 | ||
|    id=scanner.pop();  set_id(id); 
 | ||
|    _latox=scanner.integer();
 | ||
|    if(_latox<=0) _latox=10;
 | ||
|    _latoy=scanner.integer(); 
 | ||
|    if(_latoy<=0) _latoy=2;
 | ||
|    set_dim(_latox+2,_latoy); 
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      tok=scanner.pop();
 | ||
|    }  
 | ||
|    tok=prt(); 
 | ||
|    type_button(id,tok); 
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_group :controllo tipo GROUP
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo GROUP
 | ||
| TEditMask_group::TEditMask_group(TEditMask_window* parent)
 | ||
|      :TEditMask_control(parent)
 | ||
| {
 | ||
|    set_prompt(PR("Gruppo"));
 | ||
|    set_type("GROUPBOX  ");
 | ||
|    set_id("DLG_NULL");
 | ||
|    _latox=18;
 | ||
|    _latoy=6;
 | ||
|    set_dim(_latox,_latoy);
 | ||
|    set_focus(-2);
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_group::TEditMask_group(const TEditMask_group& ctl)
 | ||
|      :TEditMask_control(ctl)
 | ||
| {
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    _latox=ctl._latox;
 | ||
|    _latoy=ctl._latoy;
 | ||
|    set_dim(_latox,_latoy);
 | ||
|    set_focus(-2);
 | ||
| }
 | ||
| 
 | ||
| //Presenza o no del flags "R"
 | ||
| bool TEditMask_group::fl_crt() const
 | ||
| {
 | ||
|   TString fl=flag();
 | ||
|   if(fl.find('R')!=-1 || fl.find('r')!=-1)
 | ||
|     return TRUE;
 | ||
|   return FALSE; 
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_group::update()const
 | ||
| {
 | ||
|   RCT r=rectangle();
 | ||
|  
 | ||
|   if(fl_crt()) 
 | ||
|     padre().set_pen(MASK_DARK_COLOR);
 | ||
|   else 
 | ||
|     padre().set_pen(MASK_LIGHT_COLOR);
 | ||
|   line(r.left,r.top+1+ROWY/2,r.right,r.top+1+ROWY/2);
 | ||
|   line(r.left,r.top+1+ROWY/2,r.left,r.bottom+1-ROWY/2);
 | ||
|   if(fl_crt()) 
 | ||
|     padre().set_pen(MASK_LIGHT_COLOR);
 | ||
|   else 
 | ||
|     padre().set_pen(MASK_DARK_COLOR);
 | ||
|   line(r.right,r.top+1+ROWY/2,r.right,r.bottom+1-ROWY/2);
 | ||
|   line(r.left,r.bottom+1-ROWY/2,r.right,r.bottom+1-ROWY/2);
 | ||
|   padre().set_pen(COLOR_BLACK);
 | ||
|   frase(r.left+2,r.top);
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_group::main_loop()
 | ||
| { 
 | ||
|   TMask _mask("ba2600p");
 | ||
|   TSheet_field& s=_mask.sfield(F_MESSAGE);
 | ||
|   
 | ||
|     
 | ||
|   set_field(_mask);
 | ||
|   set_option(_mask);
 | ||
|   set_message(s);
 | ||
|   _mask.set(F_LARGE,_latoy);
 | ||
|   _mask.set(F_LONGEFF,_latox);
 | ||
|   KEY k= _mask.run();      
 | ||
|   if(k==K_ENTER) 
 | ||
|   {
 | ||
|     get_field(_mask); 
 | ||
|     get_option(_mask);
 | ||
|     get_message(s);
 | ||
|     _latoy=_mask.get_int(F_LARGE);
 | ||
|     _latox=_mask.get_int(F_LONGEFF);
 | ||
|     set_dim(_latox,_latoy);
 | ||
|   }
 | ||
|   return k; 
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_group::print_on(ostream& out) const     
 | ||
| { 
 | ||
|    
 | ||
|    out<<type()<<ident()<<" "<<_latox<<" "<<_latoy<<"\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_group::read_from(TScanner& scanner,bool intool)       
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop()); 
 | ||
|    _latox=scanner.integer();
 | ||
|    _latoy=scanner.integer(); 
 | ||
|    set_dim(_latox,_latoy); 
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      tok=scanner.pop();
 | ||
|    }  
 | ||
| } 
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_list :controllo tipo LIST
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo LIST
 | ||
| TEditMask_list::TEditMask_list(TEditMask_window* parent)
 | ||
|                               :TEditMask_string(parent)
 | ||
| {
 | ||
|    _num_item=0;
 | ||
|    _offset=1;
 | ||
|    set_id("F_LIST");
 | ||
|    set_prompt(PR("Lista"));
 | ||
|    set_type("LIST  ");
 | ||
|    set_dim(dim_video()+ prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_list::TEditMask_list(const TEditMask_list& ctl)
 | ||
|                               :TEditMask_string(ctl)
 | ||
| {
 | ||
|    _num_item=ctl._num_item;
 | ||
|    _offset=ctl._offset;                       
 | ||
|    _item=ctl._item;
 | ||
|    set_id(ctl.ident());
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_dim(dim_video()+ prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| //Disegna la freccia del controllo
 | ||
| void TEditMask_list::image()const 
 | ||
| {
 | ||
|    RCT r=rectangle();
 | ||
|    int lato=r.bottom-r.top;
 | ||
| 
 | ||
|    PNT rt[]= {{r.top+lato/2-4,r.right-lato/2-2}, {r.top+lato/2-4,r.right-lato/2+1}, 
 | ||
|               {r.top+lato/2,r.right-lato/2+1},{r.top+lato/2,r.right-lato/2-2},
 | ||
|               {r.top+lato/2-4,r.right-lato/2-2}};
 | ||
| 
 | ||
|    PNT p[] = {{r.top+lato/2,r.right-lato+5}, {r.top+lato/2,r.right-5}, 
 | ||
|               {r.top+lato/2+3,r.right-(lato/2)},{r.top+lato/2,r.right-lato+5}};
 | ||
| 
 | ||
|    padre().set_brush(COLOR_BLACK); 
 | ||
|    xvt_dwin_draw_polygon(maschera(), rt, 5); 
 | ||
|    xvt_dwin_draw_polygon(maschera(), p, 4); 
 | ||
|    line(r.right-lato+5,r.top+lato/2+5,r.right-5,r.top+lato/2+5);
 | ||
|    padre().hide_brush();
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_list::update()const
 | ||
| {
 | ||
|    RCT r=rectangle();
 | ||
|    r.bottom=r.bottom-(CHARY-2)/8;
 | ||
|    int lato=(r.bottom-r.top);    
 | ||
|    RCT rt={r.top, r.right-lato,r.bottom,r.right};
 | ||
|    
 | ||
|    TEditMask_string::update();                           
 | ||
|    
 | ||
|    padre().set_brush(BTN_BACK_COLOR);
 | ||
|    xvt_dwin_draw_rect(maschera(),&rt);
 | ||
|    
 | ||
|    padre().set_pen(BTN_LIGHT_COLOR,2);
 | ||
|    line((r.right+2)-lato,r.top+2,(r.right-2),r.top+2);
 | ||
|    line((r.right+2)-lato,r.top+2,(r.right+2)-lato,r.bottom-2); 
 | ||
|    
 | ||
|    padre().set_pen(BTN_DARK_COLOR,2);
 | ||
|    line((r.right-2),r.top+2,r.right-2,r.bottom-2);
 | ||
|    line((r.right+2)-lato,r.bottom-2,r.right-2,r.bottom-2);
 | ||
|    padre().set_pen(COLOR_BLACK,1);
 | ||
|    image();
 | ||
|    
 | ||
| }
 | ||
| 
 | ||
| //Setta sulla maschera di supporto solo _item
 | ||
| void TEditMask_list::set_item(TSheet_field& sp)
 | ||
| {
 | ||
|    sp.rows_array()=_item;
 | ||
| } 
 | ||
| 
 | ||
| //Legge dalla maschera di supporto solo _item
 | ||
| void TEditMask_list::get_item(TSheet_field& sp)
 | ||
| {
 | ||
|    _item=sp.rows_array();
 | ||
|    _num_item=sp.items();
 | ||
| } 
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_list::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600x");
 | ||
|    TSheet_field& s=_mask.sfield(F_ITEM);
 | ||
|    
 | ||
|    set_lngz(_mask);
 | ||
|    _mask.set(F_OFFSET,_offset);
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    set_item(s);
 | ||
|   
 | ||
|    KEY k= _mask.run();       
 | ||
|   
 | ||
|    if(k==K_ENTER)
 | ||
|    {
 | ||
|      get_lngz(_mask);
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);
 | ||
|      get_item(s);
 | ||
|      _offset=_mask.get_int(F_OFFSET);
 | ||
|      set_offset(_offset);
 | ||
|      set_dim(dim_video()+prompt_len()+off(),1);
 | ||
|    }
 | ||
|     return k;
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml solo _item
 | ||
| void TEditMask_list::print_item(ostream& out)const
 | ||
| {   
 | ||
|    TString message,codice,desc;
 | ||
|    
 | ||
|    for(int i=0;i<_item.items();i++)
 | ||
|    {
 | ||
|      TToken_string& it=(TToken_string&)_item.row(i);
 | ||
|      codice=it.get(0);
 | ||
|      desc=it.get();
 | ||
|      if(!codice.blank() && !desc.blank())   
 | ||
|      {
 | ||
|        out<<"  ITEM \""<<codice<<'|'<<desc<<"\"\n";            
 | ||
|        message=it.get(2);
 | ||
|        if(!message.blank())
 | ||
|        {
 | ||
|          message.replace('^','|');
 | ||
|          out<<"  MESSAGE "<< message<<"\n";  
 | ||
|        }  
 | ||
|      }
 | ||
|    }
 | ||
| }     
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_list::print_on(ostream& out) const
 | ||
| { 
 | ||
|    
 | ||
|    out<<type() << ident() <<' ';
 | ||
|    print_lngz(out);
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    print_item(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml solo _item
 | ||
| TString& TEditMask_list::read_item(TScanner& scanner, TString& tok) 
 | ||
| {
 | ||
|    TToken_string it,mes;
 | ||
| 
 | ||
|    if(tok=="ITEM")        
 | ||
|    {
 | ||
|      _num_item++;
 | ||
|      it=scanner.string();
 | ||
|      tok=scanner.pop();    
 | ||
|      if(tok=="MESSAGE")
 | ||
|      {         
 | ||
|        mes=scanner.line();
 | ||
|        mes.replace('|','^');
 | ||
|        it.add(mes);
 | ||
|        tok=scanner.pop();
 | ||
|      }
 | ||
|    }  
 | ||
|    else tok=scanner.pop();
 | ||
|    
 | ||
|    if(it.ok() && !it.blank())  _item.add(it);
 | ||
|    
 | ||
|   return tok; 
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_list::read_from(TScanner& scanner,bool intool) 
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop()); 
 | ||
|    read_lngz(scanner);
 | ||
|    tok=scanner.pop();  //tralascio BEGIN
 | ||
|    while(tok!="END")
 | ||
|    { 
 | ||
|      tok=read_item(scanner,tok);
 | ||
|      read_field(scanner,tok,intool);
 | ||
|    }  
 | ||
|    tok=prt();  read_off(tok);  tok.rtrim();  set_prompt(tok);
 | ||
|    set_dim(dim_video()+prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_radio :controllo tipo RADIOBUTTON
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo RADIOBUTTON
 | ||
| TEditMask_radio::TEditMask_radio(TEditMask_window* parent)
 | ||
|           :TEditMask_list(parent)
 | ||
| {
 | ||
|    _latox=20;      
 | ||
|    _latoy=4;
 | ||
|    set_id("F_RADIO");
 | ||
|    set_prompt(PR("Pulsantiera"));
 | ||
|    set_type("RADIOBUTTON  ");
 | ||
|    set_dim(_latox,_latoy);
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_radio::TEditMask_radio(const TEditMask_radio& ctl)
 | ||
|           :TEditMask_list(ctl)
 | ||
| {
 | ||
|    _latox=ctl._latox;      
 | ||
|    _latoy=ctl._latoy;
 | ||
|    set_id(ctl.ident());
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_dim(_latox,_latoy);
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_radio::update() const
 | ||
| {
 | ||
|    
 | ||
|    RCT r=rectangle();
 | ||
|    
 | ||
|    padre().hide_brush();
 | ||
| 
 | ||
|    padre().set_pen(MASK_LIGHT_COLOR);
 | ||
|    line(r.left,r.top+ROWY,r.right,r.top+ROWY);
 | ||
|    line(r.left,r.top+ROWY,r.left,r.bottom);
 | ||
|    padre().set_pen(MASK_DARK_COLOR);
 | ||
|    line(r.right,r.top+ROWY,r.right,r.bottom);
 | ||
|    line(r.left,r.bottom,r.right,r.bottom);
 | ||
|    padre().set_pen(COLOR_BLACK);    
 | ||
| 
 | ||
|    padre().set_pen(MASK_LIGHT_COLOR);
 | ||
|    int i,k;
 | ||
|    for (i = 0, k = ROWY; i < n_item(); i++, k+=ROWY)
 | ||
|    {
 | ||
|      line(r.left+(ROWY-10),r.top+ROWY+k,r.left+ROWY-2,r.top+(ROWY-8)+k);
 | ||
|      line(r.left+(ROWY-2),r.top+(ROWY+8)+k,r.left+(ROWY-10),r.top+ROWY+k); 
 | ||
|    }
 | ||
|    i=0; k=ROWY;                                                         
 | ||
| 
 | ||
|    padre().set_pen(MASK_DARK_COLOR);
 | ||
|    for (;i<n_item(); i++, k=k+ROWY)
 | ||
|    {
 | ||
|      line(r.left+(ROWY+6),r.top+ROWY+k,r.left+(ROWY-2),r.top+(ROWY+8)+k);
 | ||
|      line(r.left+(ROWY-2),r.top+(ROWY-8)+k,r.left+(ROWY+6),r.top+ROWY+k);
 | ||
|    } 
 | ||
|    i=0; k=ROWY;
 | ||
| 
 | ||
|    for (;i<n_item(); i++, k=k+ROWY) 
 | ||
|    {                                                     
 | ||
|      TToken_string it=item().row(i);
 | ||
|      padre().stringat(r.left+(ROWY+10),r.top+(ROWY-8)+k,it.get(1));
 | ||
|    }
 | ||
| 
 | ||
|    frase(r.left+2,r.top);
 | ||
|    padre().set_pen(COLOR_BLACK);
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_radio::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600o");
 | ||
|    TSheet_field& s=_mask.sfield(F_ITEM);
 | ||
| 
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    _mask.set(F_LONGEFF,_latox);
 | ||
|    set_item(s);
 | ||
| 
 | ||
|    KEY k= _mask.run();
 | ||
|  
 | ||
|    if(k==K_ENTER) {
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);
 | ||
|      get_item(s);
 | ||
|      _latox=_mask.get_int(F_LONGEFF);
 | ||
|      if(n_item()==0) set_dim(_latox,4);
 | ||
|      else 
 | ||
|      {
 | ||
|        _latoy=16/CHARX;
 | ||
|        _latoy+=n_item();         //per mantenere l'altezza
 | ||
|        set_dim(_latox,_latoy);
 | ||
|      }  
 | ||
|    } 
 | ||
|    else
 | ||
|      if(k==K_ESC)  
 | ||
|        set_dim(_latox,_latoy);
 | ||
| 
 | ||
|     return k;
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_radio::print_on(ostream& out) const     
 | ||
| { 
 | ||
|    out<<type() <<ident()<<" "<<_latox<<"\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    print_item(out);                             
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_radio::read_from(TScanner& scanner,bool intool)   
 | ||
| {
 | ||
|    TString tok;            
 | ||
|    
 | ||
|    set_id(scanner.pop()); 
 | ||
|    _latox=scanner.integer();
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      tok=read_item(scanner,tok);
 | ||
|      read_field(scanner,tok,intool);
 | ||
|    }  
 | ||
|    if(n_item()==0) _latoy=4;
 | ||
|    else
 | ||
|    {
 | ||
|      _latoy=16/CHARX;
 | ||
|      _latoy+=n_item();
 | ||
|    }  
 | ||
|    set_dim(_latox,_latoy);
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_memo :controllo tipo MEMO
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo MEMO
 | ||
| TEditMask_memo::TEditMask_memo(TEditMask_window* parent)
 | ||
|              :TEditMask_control(parent)
 | ||
| {
 | ||
|    _latox=40;
 | ||
|    _latoy=10;
 | ||
|    set_prompt(PR("Memo"));
 | ||
|    set_type("MEMO  ");
 | ||
|    set_id("F_MEMO");
 | ||
|    set_dim(_latox,_latoy);
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_memo::TEditMask_memo(const TEditMask_memo& ctl)
 | ||
|              :TEditMask_control(ctl)
 | ||
| {
 | ||
|    _latox=ctl._latox;
 | ||
|    _latoy=ctl._latoy;
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    set_dim(_latox,_latoy);
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_memo::update()const
 | ||
| {
 | ||
|    RCT r=rectangle();
 | ||
|    RCT ret={r.top+ROWY,r.left,r.bottom,r.right};
 | ||
| 
 | ||
|    padre().set_brush(NORMAL_BACK_COLOR);
 | ||
|    padre().set_pen(COLOR_BLACK,2);
 | ||
|    xvt_dwin_draw_rect(maschera(),&ret);
 | ||
|    padre().hide_brush();          
 | ||
|    padre().set_pen(COLOR_BLACK,1);
 | ||
|    frase(r.left,r.top);
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_memo::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600m");  
 | ||
|    TSheet_field& s=_mask.sfield(F_MESSAGE);
 | ||
|   
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    set_message(s);
 | ||
|    _mask.set(F_LONGEFF,_latox);
 | ||
|    _mask.set(F_LARGE,_latoy);
 | ||
|    KEY k= _mask.run();
 | ||
|    if(k==K_ENTER) 
 | ||
|    {
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);
 | ||
|      get_message(s);
 | ||
|      _latox=_mask.get_int(F_LONGEFF);
 | ||
|      _latoy=_mask.get_int(F_LARGE); 
 | ||
|      set_dim(_latox,_latoy);
 | ||
|    }
 | ||
|     return k;
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_memo::print_on(ostream& out)const
 | ||
| { 
 | ||
|    
 | ||
|    out<<type() <<ident()<<" "<<_latox<<" "<<_latoy<<"\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_memo::read_from(TScanner& scanner,bool intool) 
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop()); 
 | ||
|    _latox=scanner.integer();  _latoy=scanner.integer();
 | ||
|    set_dim(_latox,_latoy); 
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      tok=scanner.pop();
 | ||
|    }  
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_spread :controllo tipo SPREADSHEET
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo SPREADSHEET
 | ||
| TEditMask_sheet::TEditMask_sheet(TEditMask_window* parent)
 | ||
|                                    :TEditMask_control(parent),
 | ||
|                                    _sheetmask(1,5,60,12,"Sheet",WSF_SIZE,W_DOC)
 | ||
| {  
 | ||
|    _latox=40;
 | ||
|    _latoy=6;                         
 | ||
|    set_dim(_latox,_latoy);
 | ||
|    set_prompt(PR("Tabella"));
 | ||
|    set_type("SPREADSHEET  ");
 | ||
|    set_id("F_SPREAD");
 | ||
|    _sheetmask.set_sheet(this);
 | ||
|    _sheetmask.open();
 | ||
|    if(padre().get_mod()) window_sheet(); //in read non deve creare bottoni in pi<70>
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_sheet::TEditMask_sheet(const TEditMask_sheet& ctl)
 | ||
|                                    :TEditMask_control(ctl),
 | ||
|                                    _sheetmask(1,5,60,12,"Sheet",WSF_SIZE,W_DOC)
 | ||
| {  
 | ||
|    _latox=ctl._latox;
 | ||
|    _latoy=ctl._latoy;                    
 | ||
|    set_dim(_latox,_latoy);
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_id(ctl.ident());
 | ||
|    _sheetmask.set_sheet(this);
 | ||
|    _sheetmask.open();
 | ||
|    if(padre().get_mod()) window_sheet(); 
 | ||
| }
 | ||
| 
 | ||
| //Crea sulla maschera (in fase di creazione) 3 bottoni standard
 | ||
| void TEditMask_sheet::window_sheet()
 | ||
| {  
 | ||
|    DRAW_CTOOLS t;
 | ||
|    
 | ||
|    TEditMask_control* btn_ok=_sheetmask.addbutton();
 | ||
|    btn_ok->set_prompt(BR("Conferma", 9));
 | ||
|    btn_ok->set_id("DLG_OK");  
 | ||
|    btn_ok->set_crd(-13,-1);
 | ||
|    btn_ok->set_dim(10+2,2);
 | ||
|    
 | ||
|    TEditMask_control* btn_cancel=_sheetmask.addbutton();
 | ||
|    btn_cancel->set_prompt(BR("Annulla", 9));
 | ||
|    btn_cancel->set_id("DLG_CANCEL");
 | ||
|    btn_cancel->set_crd(-23,-1);
 | ||
|    btn_cancel->set_dim(10+2,2);
 | ||
|    
 | ||
|    
 | ||
|    TEditMask_control* btn_del=_sheetmask.addbutton();
 | ||
|    btn_del->set_prompt(BR("Elimina", 9));
 | ||
|    btn_del->set_id("DLG_DELREC");
 | ||
|    btn_del->set_crd(-33,-1);
 | ||
|    btn_del->set_dim(10+2,2);
 | ||
|    
 | ||
|    xvt_app_get_default_ctools(&t);   //per eliminare la modalit<69> M_XOR
 | ||
|    xvt_dwin_set_draw_ctools(maschera(),&t);
 | ||
| }                                         
 | ||
| 
 | ||
| //Fa l'update del controllo
 | ||
| void TEditMask_sheet::update()const  
 | ||
| {
 | ||
|    RCT r=rectangle();
 | ||
|    int longe=r.right-(r.left+3*CHARX);  
 | ||
|    int large=r.bottom-(r.top+ROWY);
 | ||
|    int latolong=longe/6;  
 | ||
| 
 | ||
|    RCT rt={r.top,r.left,r.top+ROWY,r.right-10}; //orizzontale
 | ||
|    RCT rc={r.top,r.left,r.top+ROWY+3*CHARY,r.left+3*CHARX};//verticale
 | ||
|    RCT rg={r.top,r.left,r.bottom,r.right};
 | ||
|    RCT rn={r.top+ROWY,r.left+3*CHARX,r.top+ROWY+3*CHARY,r.right-10};
 | ||
| 
 | ||
|    padre().set_brush(MASK_DARK_COLOR);    
 | ||
|    xvt_dwin_draw_rect(maschera(),&rg);
 | ||
|                                                          
 | ||
|    padre().set_brush(NORMAL_BACK_COLOR);    
 | ||
|    xvt_dwin_draw_rect(maschera(),&rn);
 | ||
|                                                          
 | ||
|    padre().set_brush(BTN_BACK_COLOR);   
 | ||
|    xvt_dwin_draw_rect(maschera(),&rc);
 | ||
|    xvt_dwin_draw_rect(maschera(),&rt); 
 | ||
|    padre().hide_brush();
 | ||
| 
 | ||
|    padre().set_pen(BTN_LIGHT_COLOR,2);
 | ||
|    line(r.left+2,r.top+2,r.right-12,r.top+2);
 | ||
|    line(r.left+2,r.top+2,r.left+2,r.top+ROWY+3*CHARY); 
 | ||
|    line(r.left+3*CHARX+2,r.top+2,r.left+3*CHARX+2,r.top+ROWY-2);//primo pezz..verticale
 | ||
|    line(r.left+2,r.top+ROWY+2,r.left+3*CHARX,r.top+ROWY+2); //primo pezz..orizz.
 | ||
|    for (int i=2;i<6;i+=2)  //verticali
 | ||
|      line(r.left+3*CHARX+i*latolong+2,r.top+2,r.left+3*CHARX+i*latolong+2,r.top+ROWY-2);
 | ||
|    for (int s=1;s<3;s++)  //orizz.
 | ||
|      line(r.left+2,r.top+ROWY+2+s*CHARY,r.left+3*CHARX-2,r.top+ROWY+s*CHARY+2);
 | ||
|      
 | ||
|    padre().set_pen(BTN_DARK_COLOR,2);
 | ||
|    line(r.left+2,r.top+ROWY-2,r.right-10,r.top+ROWY-2);//orizz.
 | ||
|    line(r.left+3*CHARX,r.top,r.left+3*CHARX,r.top+ROWY+3*CHARY); //verticale
 | ||
|    line(r.right-12,r.top+1,r.right-12,r.top+ROWY);
 | ||
|    for (int f=2;f<6;f+=2)   //righe verticali
 | ||
|      line(r.left+3*CHARX+f*latolong,r.top+2,r.left+3*CHARX+f*latolong,r.top+ROWY-2);
 | ||
|    for (int h=1;h<4;h++) //righe orizzontali
 | ||
|      line(r.left+2,r.top+ROWY+h*CHARY,r.left+3*CHARX-2,r.top+ROWY+h*CHARY);
 | ||
| 
 | ||
|    padre().set_pen(COLOR_BLACK,2);
 | ||
|    line(r.left+2,r.top+ROWY,r.right-12,r.top+ROWY);//orizz.
 | ||
|    line(r.right-12,r.top+1,r.right-12,r.top+ROWY);
 | ||
|    
 | ||
|    padre().set_pen(COLOR_BLACK,1);
 | ||
|    for (int j=2;j<6;j+=2) //verticali
 | ||
|      line(r.left+3*CHARX+j*latolong,r.top+ROWY,r.left+3*CHARX+j*latolong,r.top+ROWY+3*CHARY);
 | ||
|    for (int y=1;y<3;y++) //orizzontali
 | ||
|      line(r.left+3*CHARX,r.top+ROWY+y*CHARY,r.right-10,r.top+ROWY+y*CHARY);
 | ||
|    padre().stringat(r.left+2*CHARX,r.top+ROWY,"1");
 | ||
|    padre().stringat(r.left+2*CHARX,r.top+2*CHARY+CHARX,"2");
 | ||
|    padre().stringat(r.left+2*CHARX,r.top+3*CHARY+CHARX,"3");
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| //Setta sulla maschera di supporto solo _item e  browse
 | ||
| void TEditMask_sheet::set_itbr(TMask& m,TSheet_field& sp)
 | ||
| {  
 | ||
|    sp.rows_array()=_item;
 | ||
|    m.set(F_USE,_browse);
 | ||
| }
 | ||
| 
 | ||
| //Legge dalla maschera di supporto solo _item e browse
 | ||
| void TEditMask_sheet::getitbr(TMask& m,TSheet_field& sp)
 | ||
| {  
 | ||
|    _item=sp.rows_array();
 | ||
|    _browse=m.get(F_USE);
 | ||
| }                    
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_sheet::main_loop()
 | ||
| { 
 | ||
|    TToken_string spr, sd;
 | ||
|    TMask _mask("ba2600d");
 | ||
|    TSheet_field& s=_mask.sfield(F_ITEM);
 | ||
|   
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    _mask.set(F_LONGEFF,_latox);
 | ||
|    _mask.set(F_LARGE,_latoy);
 | ||
|    set_itbr(_mask,s);
 | ||
|    KEY k= _mask.run();
 | ||
|    if(k==K_ENTER)
 | ||
|    {
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);
 | ||
|      getitbr(_mask,s);
 | ||
|      _latox=_mask.get_int(F_LONGEFF);
 | ||
|      _latoy=_mask.get_int(F_LARGE);
 | ||
|      set_dim(_latox,_latoy);
 | ||
|    }
 | ||
|     return k; 
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml solo _item
 | ||
| void TEditMask_sheet::print_item(ostream& out)const
 | ||
| {   
 | ||
|    TString message,desc;
 | ||
|    
 | ||
|    for(int i=0;i<_item.items();i++)
 | ||
|    {
 | ||
|      TToken_string& it=(TToken_string&)_item.row(i);
 | ||
|      desc=it.get(0);
 | ||
|      if(!desc.blank())   
 | ||
|      {
 | ||
|        out<<"  ITEM \""<<desc<<"\"\n";            
 | ||
|        message=it.get(1);
 | ||
|        if(!message.blank())
 | ||
|          out<<"  MESSAGE "<< message<<"\n";  
 | ||
|      }
 | ||
|    }
 | ||
| }     
 | ||
| 
 | ||
| //Stampa su file .uml solo il browse
 | ||
| void TEditMask_sheet::print_browse(ostream& out)const
 | ||
| {  
 | ||
|    TString in;
 | ||
|    
 | ||
|    if(_browse.not_empty())
 | ||
|    { 
 | ||
|      for(int k=0;;k++)
 | ||
|      {
 | ||
|        int y;
 | ||
|        for(y = 0;_browse[k]!='\n' && _browse[k]; k++, y++)
 | ||
|          in[y]=_browse[k];
 | ||
|        in[y]='\0';
 | ||
|        out<<"  "<<in<<"\n";
 | ||
|        if(!_browse[k]) break;
 | ||
|      }       
 | ||
|    } 
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_sheet::print_on(ostream& out)const
 | ||
| {  
 | ||
|    out<<type() <<ident()<<" "<<_latox<<" "<<_latoy<<"\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    print_item(out);
 | ||
|    print_browse(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml solo gli _item
 | ||
| TString& TEditMask_sheet::read_item(TScanner& scanner,TString& tok) 
 | ||
| {
 | ||
|    TString sh;
 | ||
|    
 | ||
|    if(tok=="ITEM")        
 | ||
|    {
 | ||
|      sh=scanner.string();
 | ||
|      if(sh.ok() && !sh.blank())  _item.add(sh);
 | ||
|    }  
 | ||
|    tok=scanner.pop();
 | ||
| 
 | ||
|   return tok; 
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml solo il browse
 | ||
| void TEditMask_sheet::read_browse(TScanner& scanner,const TString& tok)
 | ||
| {
 | ||
|    if(tok=="USE" || tok=="JOIN" || tok=="INPUT" ||\
 | ||
|       tok=="OUTPUT" || tok=="DISPLAY" || tok=="COPY")
 | ||
|    {  
 | ||
|      _browse <<(tok);
 | ||
|      _browse <<(scanner.line());
 | ||
|      _browse <<('\n');  
 | ||
|    }  
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_sheet::read_from(TScanner& scanner,bool intool)
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop()); 
 | ||
|    _latox=scanner.integer();
 | ||
|    _latoy=scanner.integer(); 
 | ||
|    set_dim(_latox,_latoy);
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      tok=read_item(scanner,tok);
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      read_browse(scanner,tok);
 | ||
|    }  
 | ||
| }
 | ||
| 
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| //   TeditMask_zoom :controllo tipo ZOOM
 | ||
| ///////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Costruttore del controllo ZOOM
 | ||
| TEditMask_zoom::TEditMask_zoom(TEditMask_window* parent)
 | ||
|                                  :TEditMask_list(parent)
 | ||
| {  
 | ||
|    _latox=15;
 | ||
|    _offset=1;
 | ||
|    set_id("F_ZOOM");
 | ||
|    set_prompt(PR("Zoom"));
 | ||
|    set_type("ZOOM  ");
 | ||
|    set_dim(_latox+prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| //Costruttore copia del controllo
 | ||
| TEditMask_zoom::TEditMask_zoom(const TEditMask_zoom& ctl)
 | ||
|                                  :TEditMask_list(ctl)
 | ||
| {  
 | ||
|    _latox=ctl._latox;
 | ||
|    _offset=ctl._offset;
 | ||
|    set_id(ctl.ident());
 | ||
|    set_prompt(ctl.prt());
 | ||
|    set_type(ctl.type());
 | ||
|    set_dim(_latox+prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto
 | ||
| KEY TEditMask_zoom::main_loop()
 | ||
| { 
 | ||
|    TMask _mask("ba2600z");
 | ||
|    TSheet_field& s=_mask.sfield(F_MESSAGE);
 | ||
| 
 | ||
|    set_field(_mask);
 | ||
|    set_option(_mask);
 | ||
|    set_message(s);
 | ||
|    _mask.set(F_LONGEFF,_latox);
 | ||
|    _mask.set(F_OFFSET,_offset);
 | ||
|    KEY k= _mask.run();
 | ||
|    if(k==K_ENTER) 
 | ||
|    {
 | ||
|      get_field(_mask);
 | ||
|      get_option(_mask);           
 | ||
|      get_message(s);
 | ||
|      _latox=_mask.get_int(F_LONGEFF);
 | ||
|      _offset=_mask.get_int(F_OFFSET);
 | ||
|      set_offset(_offset);
 | ||
|      set_dim(_latox+prompt_len()+off(),1);
 | ||
|    }
 | ||
|     return k; 
 | ||
| }             
 | ||
| 
 | ||
| //Stampa su file .uml il controllo
 | ||
| void TEditMask_zoom::print_on(ostream& out) const
 | ||
| { 
 | ||
|    TString id=ident();
 | ||
|    
 | ||
|    out<<type() << ident() <<"  "<<_latox<<"\n";
 | ||
|    TEditMask_control::print_on(out);
 | ||
|    out <<" END"<<"\n\n";
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml il controllo
 | ||
| void TEditMask_zoom::read_from(TScanner& scanner,bool intool)
 | ||
| {
 | ||
|    TString tok;
 | ||
|    
 | ||
|    set_id(scanner.pop()); 
 | ||
|    _latox=scanner.integer(); 
 | ||
|    tok=scanner.pop();
 | ||
|    while(tok!="END")
 | ||
|    {
 | ||
|      read_field(scanner,tok,intool);
 | ||
|      tok=scanner.pop();
 | ||
|    }  
 | ||
|    tok=prt();  read_off(tok);  tok.rtrim();  set_prompt(tok);
 | ||
|    set_dim(_latox+prompt_len()+off(),1);
 | ||
| }
 | ||
| 
 | ||
| //----------------------------------------
 | ||
| 
 | ||
| //Inizializza il rettangolo di selezione
 | ||
| void TEditMask_window::inizialition()
 | ||
| {
 | ||
|    _rct_sel.left=_rct_sel.top=0;
 | ||
|    _rct_sel.right=_rct_sel.bottom=0;
 | ||
| }
 | ||
| 
 | ||
| //Intercetta un punto all'interno del controllo
 | ||
| bool TEditMask_control::contains(const PNT pnt)
 | ||
| {
 | ||
|    bool dentro=xvt_rect_has_point(&_rct,pnt) != 0;
 | ||
|     return dentro;
 | ||
| }
 | ||
| 
 | ||
| //Ritorna il controllo avente il punto pnt
 | ||
| TEditMask_control* TEditMask_window::search(const PNT& pnt)
 | ||
| {
 | ||
|   for(int i=_controls.items()-1; i >= 0; i--)   
 | ||
|   {
 | ||
|     TEditMask_control& down=(TEditMask_control& )_controls[i];
 | ||
|     if (_page==down.page() && down.contains(pnt)) 
 | ||
|     {
 | ||
|       down.set_selected(TRUE);
 | ||
|       return &down;    
 | ||
|     }  
 | ||
|   }                    
 | ||
|   return NULL;
 | ||
| }
 | ||
| 
 | ||
| //Ritorna TRUE  se esistono controlli selezionati
 | ||
| bool TEditMask_window::search(RCT* rct)
 | ||
| {
 | ||
|   bool sel=FALSE;         
 | ||
|    
 | ||
|   for(int i=_controls.items()-1; i >= 0; i--)
 | ||
|   {
 | ||
|     TEditMask_control& down=(TEditMask_control& )_controls[i];
 | ||
|     PNT p={down.rectangle().top,down.rectangle().left};
 | ||
|     bool selected=xvt_rect_has_point(rct,p) != 0;
 | ||
| 
 | ||
|     if (selected && _page == down.page())
 | ||
|     {
 | ||
|       down.set_selected(TRUE);  
 | ||
|       sel=TRUE;
 | ||
|       selected=FALSE;
 | ||
|     }
 | ||
|   }  
 | ||
|   return sel;
 | ||
| }
 | ||
| 
 | ||
| //Ridisegna il controllo spostato
 | ||
| bool TEditMask_control::redesign(int dx, int dy)
 | ||
| {                           
 | ||
|    PNT dev; dev.h = _rct.left; dev.v = _rct.top;
 | ||
|    PNT log = padre().logic(dev, _intool);
 | ||
|    
 | ||
|    _left = log.h + dx / CHARX;
 | ||
|    if (_left < 0) _left = 0;
 | ||
|    if (_left > 78) _left = 78;
 | ||
|    
 | ||
|    _top = log.v + dy / ROWY ;
 | ||
|    if (_top < 0) _top = 0;
 | ||
|    if (_top > ROWY) _top = ROWY;
 | ||
| 
 | ||
|    resize_rect();
 | ||
|    
 | ||
|    return TRUE;
 | ||
| }
 | ||
| 
 | ||
| //Ridisegna il rettangolo di selezione
 | ||
| bool TEditMask_window::redesign(RCT* rct, int dx, int dy)
 | ||
| {
 | ||
|    int height = xvt_rect_get_height(rct);
 | ||
|    int width = xvt_rect_get_width(rct); 
 | ||
|    bool intool;
 | ||
|    PNT dev; dev.h = rct->left; dev.v = rct->top;
 | ||
|    PNT log = logic(dev, intool);
 | ||
|    
 | ||
|    int x = log.h + dx/CHARX;
 | ||
|    if (x < 0) x = 0;
 | ||
|    if (x > 78) x = 78;
 | ||
|    
 | ||
|    int y = log.v + dy/ROWY;
 | ||
|    if (y < 0) y = 0;
 | ||
|    if (y > 19) y = 19;
 | ||
|    
 | ||
|    *rct = resize_rect(x,y,1,1,WO_TE,intool);
 | ||
|    rct->right = rct->left +width;
 | ||
|    rct->bottom=rct->top + height;
 | ||
|    
 | ||
|     return TRUE;
 | ||
| }
 | ||
| 
 | ||
| //Permette di spostare uno o pi<70> controlli selezionati
 | ||
| void TEditMask_window::move(RCT* rct,PNT pntinz, PNT pntfin)
 | ||
| {
 | ||
|    int dx=(pntfin.h-pntinz.h);  //trasla lungo x
 | ||
|    int dy=(pntfin.v-pntinz.v);  //trasla lungo y
 | ||
| 
 | ||
|    if(pntfin.h/CHARX==pntinz.h/CHARX && pntfin.v/ROWY==pntinz.v/ROWY) ;
 | ||
|    else
 | ||
|    {
 | ||
|      redesign(rct,dx,dy);
 | ||
|      for(int i=0; i<_controls.items(); i++) 
 | ||
|      {
 | ||
|        TEditMask_control& down=(TEditMask_control& )_controls[i];
 | ||
|        if (down.get_selected()) 
 | ||
|          down.redesign(dx,dy);  
 | ||
|      } 
 | ||
|    }  
 | ||
| }
 | ||
| 
 | ||
| //Distrugge il controllo con tasto ELIMINA di maschera di supporto
 | ||
| void TEditMask_window::destroy_control(TEditMask_control* c)
 | ||
| { 
 | ||
|    for(int i=_controls.last(); i >= 0; i--) 
 | ||
|    {
 | ||
|      if (_controls.objptr(i) == c)
 | ||
|      {
 | ||
|        _controls.destroy(i, TRUE);
 | ||
|        break;
 | ||
|      }
 | ||
|    }
 | ||
|    _controllo=NULL;
 | ||
| } 
 | ||
| 
 | ||
| //Controllo sull'ordine delle pagine 
 | ||
| int TEditMask_window::max_page(int pag)
 | ||
| {
 | ||
|    if(pag>_total_page)
 | ||
|    {
 | ||
|      int diff=pag-_total_page;
 | ||
|      if(diff==1) _total_page=pag;
 | ||
|      else 
 | ||
|      {
 | ||
|        error_box("Non esagerare, va avanti una pagina per volta! Ti aiuto io... ");       
 | ||
|        _total_page+=1;
 | ||
|        pag=_total_page;
 | ||
|      }     
 | ||
|      _name.add("Maschera",pag);   
 | ||
|      _name.pack();
 | ||
|    }
 | ||
|   return pag;
 | ||
| }
 | ||
| 
 | ||
| //Copia i controlli selezionati
 | ||
| void TEditMask_window::copy_crt_sel()
 | ||
| {
 | ||
|    int items=_controls.items();
 | ||
|    PNT inz={_rct_sel.top,_rct_sel.left};
 | ||
|    PNT fin={1*ROWY,1*CHARX};
 | ||
| 
 | ||
|    for(int i=items-1; i>=0; i--) 
 | ||
|    {
 | ||
|      TEditMask_control& down=(TEditMask_control& )_controls[i];
 | ||
|      if (down.get_selected()) 
 | ||
|      {
 | ||
|        down.set_selected(FALSE);
 | ||
|        int j=_controls.add(down);
 | ||
|        TEditMask_control& gr=(TEditMask_control& )_controls[j];
 | ||
|        gr.set_selected(TRUE);
 | ||
|      }  
 | ||
|    }   
 | ||
|    move(&_rct_sel,inz,fin);
 | ||
|    force_update();
 | ||
| } 
 | ||
| 
 | ||
| //Cancella i controlli selezionati
 | ||
| void TEditMask_window::erase_crt_sel()
 | ||
| { 
 | ||
|    for(int i=_controls.last(); i >= 0; i--) 
 | ||
|    {
 | ||
|      TEditMask_control& down=(TEditMask_control& )_controls[i];
 | ||
|      if (down.get_selected()) 
 | ||
|        _controls.destroy(i, TRUE);
 | ||
|    }
 | ||
|    _controllo=NULL;
 | ||
|    inizialition();  
 | ||
|    xvt_win_set_cursor(win(), CURSOR_ARROW);
 | ||
|    force_update();
 | ||
| } 
 | ||
| 
 | ||
| //Muove nella pagina richiesta(se permessa)i controlli selezionati
 | ||
| void TEditMask_window::move_crt_sel()
 | ||
| {
 | ||
|    int pag;
 | ||
|    TMask m("ba2600l");
 | ||
| 
 | ||
|    KEY k=m.run();
 | ||
|    if(k==K_ENTER)
 | ||
|    { 
 | ||
|      if(xvt_rect_is_empty(&_rct_sel))
 | ||
|        warning_box(TR("Pensi di avere selezionato qualcosa??"));
 | ||
|      else 
 | ||
|      {
 | ||
|        pag=m.get_int(101);
 | ||
|    
 | ||
|        if(pag==0)
 | ||
|        {
 | ||
|          warning_box(TR("La pagina 0 non esiste! Lascio tutto ancora nella stessa pagina."));
 | ||
|          pag=_page;
 | ||
|        }        
 | ||
|        else 
 | ||
|        {
 | ||
|          pag=max_page(pag);
 | ||
|    
 | ||
|          for(int i=0; i<_controls.items(); i++)
 | ||
|          {
 | ||
|            TEditMask_control& down=(TEditMask_control& )_controls[i];
 | ||
|            if (down.get_selected()) 
 | ||
|              down.set_page(pag);
 | ||
|          }
 | ||
|        }
 | ||
|      }  
 | ||
|    }   
 | ||
| }
 | ||
| 
 | ||
| //Disegna una linea sulla "maschera"
 | ||
| void TEditMask_window::line(short x0,short y0,short x1,short y1) const
 | ||
| {
 | ||
|    PNT f = {y0,x0};
 | ||
|    PNT t = {y1,x1};
 | ||
| 
 | ||
|    xvt_dwin_draw_set_pos(win(), f);
 | ||
|    xvt_dwin_draw_line(win(), t);
 | ||
| }
 | ||
| 
 | ||
| //Gestisce l'evento legato ad E_CHAR 
 | ||
| void TEditMask_window::o_key(KEY key) 
 | ||
| {
 | ||
|   switch(key)
 | ||
|   {
 | ||
|     case K_NEXT:
 | ||
|       if(_page==_total_page) ;
 | ||
|       else
 | ||
|         _page+=1;               
 | ||
|       update();
 | ||
|      break;
 | ||
|     case K_PREV: 
 | ||
|       if(_page!=1 && _page>1)
 | ||
|         _page-=1;
 | ||
|       update();
 | ||
|      break;
 | ||
|     case K_DEL:
 | ||
|       erase_crt_sel();
 | ||
|      break; 
 | ||
|     case K_F6:
 | ||
|       copy_crt_sel();
 | ||
|      break; 
 | ||
|     case K_F2:
 | ||
|     {
 | ||
|       move_crt_sel();
 | ||
|       force_update();
 | ||
|     }  
 | ||
|      break; 
 | ||
|     case K_F3:
 | ||
|     {
 | ||
|       vision_ctrl();
 | ||
|     }
 | ||
|      break;
 | ||
|     case K_F4:
 | ||
|     {
 | ||
|       vision_spread();
 | ||
|     }
 | ||
|      break;
 | ||
|     case K_F5:
 | ||
|     {
 | ||
|       vision_sp_ctl();
 | ||
|     }
 | ||
|      break;
 | ||
|     default: 
 | ||
|      break;
 | ||
|   }
 | ||
| } 
 | ||
| 
 | ||
| //Deseleziona i controlli selezionati
 | ||
| void TEditMask_window::deselection()  
 | ||
| {
 | ||
|   for(int i=0; i<_controls.items(); i++) 
 | ||
|   {
 | ||
|     TEditMask_control& down=(TEditMask_control& )_controls[i];
 | ||
|     down.set_selected(FALSE);
 | ||
|    }    
 | ||
|    xvt_win_set_cursor(win(), CURSOR_ARROW); 
 | ||
| }
 | ||
| 
 | ||
| //Controlla l'appartenenza di un punto al rettangolo di selezione
 | ||
| bool TEditMask_window::selection(RCT* rct,PNT pnt)
 | ||
| {
 | ||
|    return (xvt_rect_has_point(rct,pnt) != 0);
 | ||
| }
 | ||
| 
 | ||
| //Crea il rettangolo di selezione
 | ||
| void TEditMask_window::rubber_rect(WINDOW win, RCT*rctp,PNT p)
 | ||
| {
 | ||
|    RCT rct;
 | ||
|    DRAW_CTOOLS t;
 | ||
| 
 | ||
|    xvt_app_get_default_ctools(&t);
 | ||
|    t.pen.color=COLOR_BLACK;
 | ||
|    t.brush.color=MASK_BACK_COLOR;
 | ||
|    t.pen.pat=PAT_RUBBER;
 | ||
|    t.brush.pat=PAT_HOLLOW;
 | ||
|    t.mode=M_XOR;
 | ||
|    xvt_dwin_set_draw_ctools(win,&t);
 | ||
|    normalize_rect(&rct,rctp);
 | ||
|    xvt_dwin_draw_rect(win,&rct);
 | ||
| }
 | ||
| 
 | ||
| //Normalizza un rettangolo
 | ||
| void TEditMask_window::normalize_rect(RCT *norm_rctp, RCT*rctp)
 | ||
| {
 | ||
|    xvt_rect_set(norm_rctp, min(rctp->left, rctp->right),
 | ||
|    min(rctp->top, rctp->bottom),max(rctp->left, rctp->right),
 | ||
|    max(rctp->top, rctp->bottom));
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la selezione
 | ||
| void TEditMask_window::selected_crt(WINDOW win, EVENT* ep)
 | ||
| {
 | ||
|   static PNT last_pnt,posinz,posfin;
 | ||
|   static bool first_move,down=FALSE,sel=FALSE;
 | ||
|   static bool is_rect=FALSE;
 | ||
|   
 | ||
|   switch(ep->type) {
 | ||
|    case E_MOUSE_DOWN:
 | ||
|       if(ep->v.mouse.button==0)   //solo con il tasto sinistro
 | ||
|       {
 | ||
|         down=TRUE;
 | ||
|         last_pnt=posinz=ep->v.mouse.where;  //punto iniziale
 | ||
|         if(xvt_rect_is_empty(&_rct_sel))  //fase primordiale
 | ||
|         { 
 | ||
|           _controllo=search(posinz);
 | ||
|           if(_controllo) {
 | ||
|             _rct_sel=_controllo->rectangle();  //diventa il controllo stesso
 | ||
|             _controllo->set_selected(TRUE);
 | ||
|             is_rect=TRUE;
 | ||
|           }  
 | ||
|         }                 
 | ||
|         if(selection(&_rct_sel,last_pnt))
 | ||
|         {
 | ||
|          is_rect=TRUE;
 | ||
|          sel=TRUE;                      
 | ||
|         } 
 | ||
|         else 
 | ||
|         { 
 | ||
|           is_rect=FALSE;
 | ||
|           deselection(); //deseleziono i controlli
 | ||
|           _rct_sel.left=ep->v.mouse.where.h;   //si definisce la posizione iniziale
 | ||
|           _rct_sel.top=ep->v.mouse.where.v;
 | ||
|           first_move=TRUE; //per dire se esiste un rubber rect  
 | ||
|         }
 | ||
|        xvt_win_trap_pointer(win);     //arresta tutti gli altri possibili eventi
 | ||
|     }  
 | ||
|     break;
 | ||
|    case E_MOUSE_MOVE:
 | ||
|     last_pnt=ep->v.mouse.where;
 | ||
|      if(!down)   //non ho premuto down percio' non disegno
 | ||
|      {
 | ||
|        bool in_rct = selection(&_rct_sel,last_pnt);
 | ||
|        xvt_win_set_cursor(win, in_rct ? CURSOR_PLUS : CURSOR_ARROW); 
 | ||
|        is_rect = in_rct;
 | ||
|       return ;
 | ||
|      }  
 | ||
|     if(!selection(&_rct_sel,last_pnt))
 | ||
|     {
 | ||
|       if(!is_rect) {
 | ||
|         if(!first_move)
 | ||
|           rubber_rect(win,&_rct_sel,last_pnt);    //cancella il vecchio rettangolo
 | ||
|         first_move=FALSE;   //risetto solamente
 | ||
|         _rct_sel.right=ep->v.mouse.where.h;   //disegno il nuovo rettangolo->rinnova sempre 
 | ||
|         _rct_sel.bottom=ep->v.mouse.where.v;   //le coordinate finali per disegnarlo mentre si muove il mouse
 | ||
|         rubber_rect(win,&_rct_sel,last_pnt);  
 | ||
|      }
 | ||
|     }
 | ||
|     break;
 | ||
|    case E_MOUSE_UP:
 | ||
|      DRAW_CTOOLS t;
 | ||
|      posfin=ep->v.mouse.where;
 | ||
|      if(sel)  
 | ||
|      {
 | ||
|        move(&_rct_sel,posinz,posfin);
 | ||
|        force_update();
 | ||
|        sel=FALSE;  
 | ||
|      }  
 | ||
|      else
 | ||
|      {
 | ||
|        if(posinz.h==posfin.h && posinz.v==posfin.v)
 | ||
|          inizialition();
 | ||
|        if(!first_move)
 | ||
|          rubber_rect(win,&_rct_sel,last_pnt);   //cancella il rubber rettangolo 
 | ||
|        if(!xvt_rect_is_empty(&_rct_sel))
 | ||
|        {
 | ||
|          if(!search(&_rct_sel))     
 | ||
|          {
 | ||
|            inizialition();
 | ||
|            deselection();
 | ||
|          }  
 | ||
|          else is_rect=TRUE;
 | ||
|        }                                                 
 | ||
|        xvt_win_set_cursor(win, CURSOR_ARROW); 
 | ||
|        xvt_win_release_pointer();   //rilascia gli eventi
 | ||
|      }
 | ||
|      down=FALSE;
 | ||
|      xvt_app_get_default_ctools(&t);   //per eliminare la modalit<69> M_XOR
 | ||
|      xvt_dwin_set_draw_ctools(win,&t);
 | ||
|      break;
 | ||
|    }
 | ||
| }
 | ||
| 
 | ||
| //Converte da pixel a caratteri
 | ||
| PNT& TEditMask_window::logic(const PNT& p, bool& intool)
 | ||
| {
 | ||
| 	 static PNT pnt;
 | ||
|    RCT r; 
 | ||
|    const int MAXX=640;
 | ||
|    
 | ||
|    xvt_vobj_get_client_rect(win(), &r);  //client_area
 | ||
|    const int width = r.right;
 | ||
|        
 | ||
|    int x = p.h;    
 | ||
|    if (width > MAXX)    
 | ||
|    { 
 | ||
|      const int dim = (width - MAXX) / 2;
 | ||
|      x -= dim;
 | ||
|    }
 | ||
|    
 | ||
|    pnt.h = x < 2*CHARX ? 0 : x/CHARX-1;
 | ||
|    pnt.v = p.v/ROWY;
 | ||
| 
 | ||
| /*      Scommentare quando verranno inseriti i tab buttons
 | ||
|    if (_tool && _total_page > 1)
 | ||
|    {
 | ||
|      if (pnt.v > 0)
 | ||
|        pnt.v--;
 | ||
|    }
 | ||
| */   
 | ||
| 
 | ||
|    if (_tool && pnt.v > _y_tool)
 | ||
|    {
 | ||
|      pnt.v -= _y_tool;
 | ||
|      intool = TRUE;
 | ||
|    }               
 | ||
|    else            
 | ||
|      intool = FALSE;
 | ||
| 
 | ||
|    return pnt;
 | ||
| }
 | ||
| 
 | ||
| //Gestisce gli eventi
 | ||
| long TEditMask_window::handler(WINDOW win, EVENT *ep)
 | ||
| {   
 | ||
|   static bool down=FALSE;       
 | ||
|   
 | ||
|    switch (ep->type)
 | ||
|    {
 | ||
|      case E_MOUSE_DOWN:
 | ||
|      {        
 | ||
|        _controllo=search(ep->v.mouse.where);
 | ||
|        if(_controllo && _controllo->type()=="SPREADSHEET  ") 
 | ||
|        {
 | ||
|          _controllo->set_hismask(TRUE);
 | ||
|          _idsheet=_controllo->get_idsheet();
 | ||
|        }
 | ||
|        if(ep->v.mouse.button==1)
 | ||
|        {
 | ||
|          if (_controllo)
 | ||
|          {
 | ||
|            KEY k = _controllo->main_loop();
 | ||
|            if (k == K_DEL) 
 | ||
|              destroy_control(_controllo);
 | ||
|          }
 | ||
|          else  
 | ||
|            main_loop();
 | ||
|          update();
 | ||
|         break; 
 | ||
|        }
 | ||
|      }       
 | ||
|      case E_MOUSE_UP:
 | ||
|      case E_MOUSE_MOVE:
 | ||
|      {
 | ||
|        TString80 s;        
 | ||
|        const PNT& p = ep->v.mouse.where;
 | ||
|        bool intool;
 | ||
|        const PNT pnt=logic(p, intool);
 | ||
|        s.format(FR("Coordinate:%3d,%3d"), pnt.h , pnt.v);
 | ||
|        xvtil_statbar_set(s);                                   
 | ||
|        if(win)
 | ||
|          selected_crt(win,ep);   
 | ||
|      }
 | ||
|       break;
 | ||
|      case E_CHAR:
 | ||
|      {
 | ||
|        TString16 p;
 | ||
|        o_key(e_char_to_key(ep));
 | ||
|        p.format(FR("Pag.%d"),_page);
 | ||
|        xvtil_statbar_set(p);  
 | ||
|        set_caption(_name.row(_page));
 | ||
|      } 
 | ||
|       break;
 | ||
|      default:
 | ||
|       break;
 | ||
|    }
 | ||
|    return TWindow::handler(win, ep);
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo STRING
 | ||
| TEditMask_control* TEditMask_window::addstring()  
 | ||
| {
 | ||
|    TEditMask_string* c=new TEditMask_string(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();   
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo NUMBER
 | ||
| TEditMask_control* TEditMask_window::addnumber()  
 | ||
| {
 | ||
|    TEditMask_number* c=new TEditMask_number(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo CURRENCY
 | ||
| TEditMask_control* TEditMask_window::addcurrency()  
 | ||
| {
 | ||
|    TEditMask_currency* c=new TEditMask_currency(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo DATE
 | ||
| TEditMask_control* TEditMask_window::adddate()      
 | ||
| {
 | ||
|    TEditMask_date* c=new TEditMask_date(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo BOOLEAN
 | ||
| TEditMask_control* TEditMask_window::addboolean()      
 | ||
| {
 | ||
|    TEditMask_boolean* c=new TEditMask_boolean(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo TEXT
 | ||
| TEditMask_control* TEditMask_window::addtext()  
 | ||
| {
 | ||
|    TEditMask_text* c=new TEditMask_text(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo BUTTON
 | ||
| TEditMask_control* TEditMask_window::addbutton()
 | ||
| {
 | ||
|    TEditMask_button* c=new TEditMask_button(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();  
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo GROUP
 | ||
| TEditMask_control* TEditMask_window::addgroup()  
 | ||
| {
 | ||
|    TEditMask_group* c=new TEditMask_group(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo RADIOBUTTON
 | ||
| TEditMask_control* TEditMask_window::addradio()
 | ||
| {
 | ||
|    TEditMask_radio* c=new TEditMask_radio(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo MEMO
 | ||
| TEditMask_control* TEditMask_window::addmemo()
 | ||
| {
 | ||
|    TEditMask_memo* c=new TEditMask_memo(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo ZOOM
 | ||
| TEditMask_control* TEditMask_window::addzoom()
 | ||
| {
 | ||
|    TEditMask_zoom* c=new TEditMask_zoom(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo SPREADSHEET
 | ||
| TEditMask_control* TEditMask_window::addsheet()
 | ||
| {
 | ||
|    TEditMask_sheet* c=new TEditMask_sheet(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo tipo LISTBOX
 | ||
| TEditMask_control* TEditMask_window::addlist()
 | ||
| {
 | ||
|    TEditMask_list* c=new TEditMask_list(this);
 | ||
|    _controls.add(c);
 | ||
|    c->update();
 | ||
|     return c;
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo generico(esplicitato da m)
 | ||
| void TEditMask_window::add_control(MENU_TAG m)
 | ||
| {
 | ||
|    TEditMask_control* ctl=NULL;
 | ||
|    TEditMask_window* w=this;
 | ||
|    bool is_sheet = get_sheet() != NULL;
 | ||
| 
 | ||
|    for(int i=0;i<_controls.items() ;i++)
 | ||
|    {
 | ||
|      TEditMask_control& sp = (TEditMask_control&)_controls[i];
 | ||
|      if(sp.type()=="SPREADSHEET  " && _page==sp.page() && sp.get_hismask())
 | ||
|      {
 | ||
|        w =find_sheet(_idsheet)->figlio();   
 | ||
|        is_sheet= TRUE;
 | ||
|        w->set_focus();
 | ||
|        sp.set_hismask(FALSE); 
 | ||
|        break;
 | ||
|      } 
 | ||
|      else w = this; 
 | ||
|    } 
 | ||
| 
 | ||
|    switch(m) 
 | ||
|    {
 | ||
|      case MENU_ITEM_ID(31):  w->addbutton();   break;
 | ||
|      case MENU_ITEM_ID(32):  w->addboolean();  break;
 | ||
|      case MENU_ITEM_ID(33):  w->addcurrency(); break;
 | ||
|      case MENU_ITEM_ID(34):  w->adddate();     break;
 | ||
|      case MENU_ITEM_ID(35):  w->addgroup();    break;
 | ||
|      case MENU_ITEM_ID(36):  w->addlist();     break;
 | ||
|      case MENU_ITEM_ID(37):  w->addmemo();     break;
 | ||
|      case MENU_ITEM_ID(38):  w->addnumber();   break;
 | ||
|      case MENU_ITEM_ID(39):  w->addradio();    break;
 | ||
|      case MENU_ITEM_ID(311): w->addstring();   break;
 | ||
|      case MENU_ITEM_ID(312): w->addtext();     break;
 | ||
|      case MENU_ITEM_ID(313): w->addzoom();     break;
 | ||
|      case MENU_ITEM_ID(310):
 | ||
|        if (!is_sheet) {
 | ||
|          ctl = w->addsheet(); 
 | ||
|          _nsheet++;
 | ||
|          ctl->set_idsheet(_nsheet);
 | ||
|        }  
 | ||
|         break;
 | ||
|      default:
 | ||
|       break;
 | ||
|     }
 | ||
| }
 | ||
| 
 | ||
| //Setta la "maschera" a seconda della presenza o no della tool
 | ||
| void TEditMask_window::set_toolbar(bool tb)                       
 | ||
| {                       
 | ||
|    TToken_string& it=(TToken_string&)_name.row(_page);
 | ||
| 
 | ||
|    if (tb != _tool || !tb)
 | ||
|    {
 | ||
|      xvt_vobj_destroy(win());        
 | ||
|      do_events(); 
 | ||
|      _tool = tb;
 | ||
|   
 | ||
|      if (tb) 
 | ||
|        create(0,0,0,0,it,0,W_PLAIN);   
 | ||
|      else 
 | ||
|      {                                           
 | ||
|        create(_coordx,_coordy,_lung,_alt,it,WSF_SIZE,W_DOC);  
 | ||
|      }
 | ||
|      open();  
 | ||
|      set_font();
 | ||
|      for(int i=0; i<_controls.items(); i++)
 | ||
|      {
 | ||
|        TEditMask_control& up=(TEditMask_control& )_controls[i];
 | ||
|        up.resize_rect(); 
 | ||
|        up.update();       
 | ||
|      }      
 | ||
|    }
 | ||
| }
 | ||
| 
 | ||
| //Fa l'update della "maschera"
 | ||
| void TEditMask_window::update() 
 | ||
| {
 | ||
|    RCT r={_rt.top,0,_rt.bottom,_rt.right};
 | ||
| 
 | ||
|    xvt_dwin_clear(win(), MASK_BACK_COLOR);
 | ||
|    
 | ||
|    if(_tool) {   
 | ||
|      set_pen(MASK_LIGHT_COLOR);
 | ||
|      set_brush(MASK_BACK_COLOR);
 | ||
|      _rt=::resize_rect(0,_y_tool,0,0,W_DOC,win());
 | ||
|      line(0,_rt.top,_rt.right,_rt.top); 
 | ||
|      set_pen(MASK_DARK_COLOR);
 | ||
|      line(0,_rt.top-2,_rt.right-2,_rt.top-2);
 | ||
|      set_pen(PROMPT_COLOR);
 | ||
|      line(0,_rt.top-1,_rt.right-1,_rt.top-1);
 | ||
|      hide_brush();
 | ||
|    }
 | ||
| 
 | ||
|    for(int i=0; i<_controls.items(); i++)
 | ||
|    {
 | ||
|      _controls.pack();
 | ||
|      TEditMask_control& up=(TEditMask_control& )_controls[i];
 | ||
|      PNT p={up.rectangle().top,up.rectangle().left};
 | ||
|      if(up.page()==_page && up.flag_crt()!=1) 
 | ||
|        up.update();    
 | ||
|      if(xvt_rect_has_point(&r,p) != 0) 
 | ||
|        up.update();    
 | ||
|    }
 | ||
| }
 | ||
| 
 | ||
| //Setta i campi della maschera di supporto della "maschera"
 | ||
| void TEditMask_window::set_mask(TMask& m)
 | ||
| {
 | ||
|    
 | ||
|    m.set(F_PAG,_page);
 | ||
|    m.set(F_TOOL,_tool ? "X" : " "); 
 | ||
|    m.set(F_TYPE,_type_vz);
 | ||
|    m.set(F_X,_coordx);
 | ||
|    m.set(F_Y,_coordy); 
 | ||
|    m.set(F_LG,_alt);
 | ||
|    m.set(F_LN,_lung); 
 | ||
|    m.set(F_TOTALP,_total_page);
 | ||
|    m.set(F_TOOLY,_y_tool);
 | ||
| }
 | ||
| 
 | ||
| //Legge dalla maschera di supporto i campi
 | ||
| void TEditMask_window::get_mask(TMask& m)
 | ||
| { 
 | ||
|    _type_vz=m.get(F_TYPE);
 | ||
|    _coordx=m.get_int(F_X);
 | ||
|    _coordy=m.get_int(F_Y);
 | ||
|    _alt=m.get_int(F_LG);
 | ||
|    _lung=m.get_int(F_LN);
 | ||
|    _y_tool=m.get_int(F_TOOLY);
 | ||
|    
 | ||
|    if(_type_vz==("a")) 
 | ||
|      _coordx=_coordy=-1;
 | ||
| 
 | ||
|    set_toolbar(m.get_bool(F_TOOL));
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml solo i controlli
 | ||
| TEditMask_control* TEditMask_window::read_control(TScanner& scanner,const TString& k, bool intool) //aggiunge i controlli
 | ||
| {
 | ||
|   TEditMask_control* ctl=NULL;
 | ||
|   
 | ||
|   if (k == "ST")  ctl = addstring();
 | ||
|   if (k == "NU")  ctl = addnumber();
 | ||
|   if (k == "CU")  ctl = addcurrency();
 | ||
|   if (k == "DA")  ctl = adddate();
 | ||
|   if (k == "BO")  ctl = addboolean();
 | ||
|   if (k == "TE")  ctl = addtext();
 | ||
|   if (k == "BU")  ctl = addbutton();
 | ||
|   if (k == "LI")  ctl = addlist();         
 | ||
|   if (k == "ME")  ctl = addmemo();
 | ||
|   if (k == "ZO")  ctl = addzoom();
 | ||
|   if (k == "GR")  ctl = addgroup();
 | ||
|   if (k == "SP")  
 | ||
|   {
 | ||
|     ctl = addsheet();
 | ||
|     _nsheet++;
 | ||
|     ctl->set_idsheet(_nsheet);
 | ||
|   }  
 | ||
|   if (k == "RA")  ctl = addradio();
 | ||
|   
 | ||
|   if(ctl)   
 | ||
|     ctl->read_from(scanner, intool);
 | ||
| 
 | ||
|  /* else
 | ||
|    warning_box("Ce sta' un campo un po' strano.. AGGIORNAMI!! ");       */
 | ||
|   return ctl;
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml solo le propriet<65> della pagina
 | ||
| void TEditMask_window::read_page(TScanner& scanner, int pg,bool tool)
 | ||
| {
 | ||
|    if(!tool) 
 | ||
|      _name.add(TR("Maschera"),0);  
 | ||
|    _page=_total_page=pg; 
 | ||
|    _name.add(scanner.string(),_page); 
 | ||
|    set_caption(_name.row(_page));
 | ||
|    _coordx=scanner.integer(); _coordy=scanner.integer();
 | ||
|    _lung=scanner.integer(); _alt=scanner.integer();
 | ||
|    if(!tool)  set_toolbar(FALSE);
 | ||
| }
 | ||
| 
 | ||
| //Legge da file .uml solo la toolbar
 | ||
| bool TEditMask_window::read_tool(TScanner& scanner)
 | ||
| {
 | ||
|   TString s; 
 | ||
|      
 | ||
|   _name.add(scanner.string(),0);
 | ||
|   set_toolbar(TRUE);  
 | ||
|   scanner.rectangle(_rt.left, _rt.top, _rt.right, _rt.bottom);
 | ||
|   _y_tool=_rt.top;
 | ||
|   if (_y_tool < 0)
 | ||
|    _y_tool = _y_tool + 22;
 | ||
|   s=scanner.pop();
 | ||
|   int fieldno=1;
 | ||
|   while(s!="ENDPAGE") 
 | ||
|   {
 | ||
|     TEditMask_control* ctrl = read_control(scanner,scanner.key(), TRUE);
 | ||
|     if (ctrl)
 | ||
|       ctrl->set_focus(fieldno++);
 | ||
|     s=scanner.pop();
 | ||
|   }    
 | ||
|     
 | ||
|   return TRUE;
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la lettura da file .uml della "maschera"
 | ||
| void TEditMask_window::restore_mask(const char* filename)  
 | ||
| {
 | ||
|   int pg=0,sh=0;
 | ||
|   TString in;
 | ||
|   bool tool=FALSE, endpage=FALSE;
 | ||
|   _file=filename;
 | ||
|   _file.lower();
 | ||
|   TScanner scanner(_file);  
 | ||
|   TEditMask_window* w=this;
 | ||
|   
 | ||
|   in=scanner.pop();
 | ||
|      
 | ||
|   if(scanner.ok()) 
 | ||
|   { 
 | ||
|    while(!scanner.eof())  
 | ||
|    { 
 | ||
|      for(int i=-1; i<_nsheet; i++) 
 | ||
|      {
 | ||
|        if(_nsheet!=0) 
 | ||
|        {
 | ||
|          pg=0;  sh++;
 | ||
|          tool=FALSE;
 | ||
|          in=scanner.pop();
 | ||
|          w=find_sheet(sh)->figlio(); 
 | ||
|        }  
 | ||
|        while (in!="ENDMASK")
 | ||
|        {
 | ||
|          while (in!="ENDPAGE") 
 | ||
|          {
 | ||
|            if (in =="TOOLBAR")  
 | ||
|            {
 | ||
|              tool=w->read_tool(scanner);  
 | ||
|              in=scanner.pop();  
 | ||
|            }    
 | ||
|            if (in == "PAGE")
 | ||
|            {
 | ||
|              pg++; 
 | ||
|              int fieldno=1;
 | ||
|              w->read_page(scanner, pg, tool);
 | ||
|              in=scanner.pop();
 | ||
|              while (in != "ENDPAGE") 
 | ||
|              {
 | ||
|                TEditMask_control* ctrl = w->read_control(scanner,scanner.key());
 | ||
|                if (ctrl)
 | ||
|                 ctrl->set_focus(fieldno++);
 | ||
|                in=scanner.pop();
 | ||
|              } 
 | ||
|              endpage=TRUE;
 | ||
|            }  
 | ||
|            if (!endpage)  
 | ||
|              in=scanner.pop();
 | ||
|          }
 | ||
|          in=scanner.pop();
 | ||
|        }
 | ||
|      }
 | ||
|      in=scanner.pop();
 | ||
|    }
 | ||
|   }
 | ||
|   endpage=tool=FALSE;
 | ||
| }
 | ||
| 
 | ||
| //Salva come.. la "maschera" su file .uml
 | ||
| void TEditMask_window::save_as_mask()
 | ||
| {
 | ||
|    FILE_SPEC fs;  memset(&fs, 0, sizeof(FILE_SPEC));
 | ||
|    strcpy(fs.type,"UML");
 | ||
|    strcpy(fs.creator, "ba2");
 | ||
|    xvt_fsys_get_default_dir(&fs.dir);
 | ||
| 
 | ||
|    if (xvt_dm_post_file_save(&fs, TR("Salva con nome:"))== FL_OK) 
 | ||
|    { 
 | ||
|       xvt_fsys_set_dir(&fs.dir); 
 | ||
|      _file=fs.name;
 | ||
|      create_file(); 
 | ||
|      create_fileh();                 
 | ||
|    } else return;
 | ||
| }
 | ||
| 
 | ||
| //Risalva la "maschera" su file .uml
 | ||
| void TEditMask_window::save_mask()
 | ||
| {
 | ||
|    create_file(); 
 | ||
|    create_fileh();                 
 | ||
| }
 | ||
| 
 | ||
| //Visualizza i controlli della "maschera" dello spreadsheet corrente
 | ||
| void TEditMask_window::vision_sp_ctl()
 | ||
| {
 | ||
|    TEditMask_window* w=this;
 | ||
|    for(int i=0;i<_controls.items() ;i++)
 | ||
|    {
 | ||
|      TEditMask_control& sp = (TEditMask_control&)_controls[i];
 | ||
|      if(sp.type()=="SPREADSHEET  " && _page==sp.page())
 | ||
|      {
 | ||
|        w =sp.figlio();   
 | ||
|        w->vision_ctrl();
 | ||
|      }  
 | ||
|    } 
 | ||
| }
 | ||
| 
 | ||
| //Visualizza la "maschera" relativa allo spreadsheet corrente
 | ||
| void TEditMask_window::vision_spread()
 | ||
| {
 | ||
|    TEditMask_window* w=this;
 | ||
|    for(int i=0;i<_controls.items() ;i++)
 | ||
|    {
 | ||
|      TEditMask_control& sp = (TEditMask_control&)_controls[i];
 | ||
|      if(sp.type()=="SPREADSHEET  " && _page==sp.page())
 | ||
|      {
 | ||
|        w =sp.figlio();   
 | ||
|        w->set_focus();
 | ||
|      }
 | ||
|    } 
 | ||
| }
 | ||
| 
 | ||
| //Visualizza tutti i controlli presenti nella pagina corrente
 | ||
| void TEditMask_window::vision_ctrl()  
 | ||
| {  
 | ||
|    TArray_sheet elenco(-1,-1,76,20,TR("Elenco dei controlli"), HR("Tipo@15|Identificativo@15|Prompt@25|Pagina@8|Flags@10"), 0x4);
 | ||
| 
 | ||
|    for(int i=0;i<_controls.items() ;i++)
 | ||
|    {
 | ||
|      TEditMask_control& e = (TEditMask_control&)_controls[i];
 | ||
|      if(_page==e.page())
 | ||
|      {
 | ||
|        TToken_string* ts = new TToken_string(80);
 | ||
|        ts->add(e.type());
 | ||
|        ts->add(e.ident());
 | ||
|        ts->add(e.prt());
 | ||
|        ts->add(e.page());   
 | ||
|        ts->add(e.flag());
 | ||
|        elenco.add(ts);
 | ||
|      }
 | ||
|    }  
 | ||
|    KEY k = elenco.run();
 | ||
|    if (k == K_ENTER || k == K_DEL)
 | ||
|    {
 | ||
|      TEditMask_control& e = (TEditMask_control&)_controls[(int)elenco.selected()];
 | ||
|      if (k == K_ENTER)
 | ||
|        k = e.main_loop();
 | ||
|      if (k == K_DEL)
 | ||
|        destroy_control(&e);
 | ||
|      force_update();
 | ||
|    }
 | ||
| }
 | ||
| 
 | ||
| //Gestisce la maschera di supporto della "maschera"
 | ||
| KEY TEditMask_window::main_loop()
 | ||
| {
 | ||
|    TMask _mask("ba2600s");
 | ||
|    TString name;
 | ||
|    
 | ||
|    set_mask(_mask);
 | ||
|    for(int k=0;k<=_total_page;k++)
 | ||
|      if(_page==k)
 | ||
|        _mask.set(F_PRT,_name.row(k));      
 | ||
|   
 | ||
|    KEY key=_mask.run();
 | ||
|   
 | ||
|    if(key==K_ENTER) {
 | ||
| 
 | ||
|      _page=_mask.get_int(F_PAG);   
 | ||
|      max_page(_page);  
 | ||
|      _name.add(_mask.get(F_PRT),_page);
 | ||
|      _name.pack();
 | ||
|      get_mask(_mask);
 | ||
|    } 
 | ||
|    
 | ||
|     return key;
 | ||
| }    
 | ||
| 
 | ||
| 
 | ||
| ////////////////////////////////////////////////////////////////////////
 | ||
| //   TMaskEditor_application :classe per la gestione dell'applicazione
 | ||
| ////////////////////////////////////////////////////////////////////////
 | ||
| 
 | ||
| //Richiama <TApplication::create>
 | ||
| bool TMaskEditor_application::create()
 | ||
| {
 | ||
| 	dispatch_e_menu(MENU_ITEM_ID(11));
 | ||
|   return true;
 | ||
| }
 | ||
| 
 | ||
| //Richiama <TApplication::destroy>
 | ||
| bool TMaskEditor_application::destroy()
 | ||
| {
 | ||
|    destroy_window();
 | ||
|     return TApplication::destroy();
 | ||
| }
 | ||
| 
 | ||
| //Distrugge la finestra("maschera") presente
 | ||
| void TMaskEditor_application::destroy_window()
 | ||
| {
 | ||
|     if(_window) 
 | ||
|     {
 | ||
|      do_events();
 | ||
|      delete _window;
 | ||
|      _window=NULL;
 | ||
|     } 
 | ||
| }
 | ||
| 
 | ||
| //Crea una nuova finestra("maschera")
 | ||
| void TMaskEditor_application::new_mask()
 | ||
| {   
 | ||
|     destroy_window();
 | ||
| 
 | ||
|    _window = new TEditMask_window(-1,-1,78,20,TR("Maschera"), WSF_SIZE,W_DOC);
 | ||
|    _window->open();       
 | ||
|    _dirty = TRUE;
 | ||
|   
 | ||
| }
 | ||
| 
 | ||
| //Apre una "maschera"
 | ||
| void TMaskEditor_application::open_mask()
 | ||
| {
 | ||
| 
 | ||
|   TFilename in;
 | ||
|   
 | ||
|   if (_dirty && _save && yesno_box(TR("Salvare la maschera corrente?")))
 | ||
|     save_as_mask();
 | ||
|   
 | ||
|   _dirty = _save = FALSE;
 | ||
|   destroy_window();
 | ||
|   
 | ||
|   FILE_SPEC fs;
 | ||
|   memset(&fs, 0, sizeof(FILE_SPEC));
 | ||
|   strcpy(fs.type, "UML");
 | ||
|   strcpy(fs.name, "");
 | ||
|   strcpy(fs.creator, "ba2");
 | ||
|   xvt_fsys_get_default_dir(&fs.dir);
 | ||
|   if (xvt_dm_post_file_open(&fs, TR("Apri file:")) == FL_OK)  //apre solo virtualmente
 | ||
|   {
 | ||
|     xvt_fsys_set_dir(&fs.dir); 
 | ||
|     in=fs.name;
 | ||
|     in.lower();
 | ||
|   } 
 | ||
|   else return; 
 | ||
|      
 | ||
|   if(!in.exist())  
 | ||
|   {
 | ||
|     xvt_dm_post_error((char *)TR("Il file non pu<70> essere aperto... non esiste!")); 
 | ||
|     return;         
 | ||
|   }  
 | ||
|   else 
 | ||
|   {
 | ||
|     destroy_window();
 | ||
|     _window = new TEditMask_window(-1,-1,68,16,TR("Maschera"), WSF_SIZE,W_DOC);
 | ||
|     _save=TRUE;
 | ||
|     _window->set_mod(FALSE);
 | ||
|     _window->open();       
 | ||
|     _window->restore_mask(fs.name);  
 | ||
|     _window->force_update();
 | ||
|   }
 | ||
| }
 | ||
| 
 | ||
| //Risalva la "maschera"
 | ||
| void TMaskEditor_application::save_mask() 
 | ||
| {
 | ||
|    _window->save_mask();
 | ||
| }
 | ||
| 
 | ||
| //Salva come.. la "maschera"
 | ||
| void TMaskEditor_application::save_as_mask() 
 | ||
| {
 | ||
|    _save=TRUE;
 | ||
|    _window->save_as_mask();
 | ||
| }
 | ||
| 
 | ||
| //Aggiunge un controllo scelto da menu
 | ||
| void TMaskEditor_application::add_control(MENU_TAG m)
 | ||
| {
 | ||
|    _window->set_mod(TRUE);
 | ||
|    _window->add_control(m);
 | ||
| }
 | ||
| 
 | ||
| //Copia i controlli selezionati
 | ||
| void TMaskEditor_application::copy_crt_sel()
 | ||
| {
 | ||
|    _window->copy_crt_sel();
 | ||
| } 
 | ||
| 
 | ||
| //Cancella i controlli selezionati
 | ||
| void TMaskEditor_application::erase_crt_sel()
 | ||
| {
 | ||
|    _window->erase_crt_sel();
 | ||
| }
 | ||
| 
 | ||
| //Sposta in un'altra pagina i controlli selezionati
 | ||
| void TMaskEditor_application::move_crt_sel()
 | ||
| {
 | ||
|    _window->move_crt_sel();
 | ||
| }
 | ||
| 
 | ||
| //Permette di compilare la "maschera" creata
 | ||
| void TMaskEditor_application::build()
 | ||
| {
 | ||
|    TString app;
 | ||
|    if(!_window->filename().empty())
 | ||
|    {
 | ||
|      app<<"mskcomp.bat " << _window->filename();
 | ||
|      TExternal_app compile(app);
 | ||
|      compile.run();
 | ||
|    }
 | ||
|    else
 | ||
|      save_as_mask();
 | ||
| }
 | ||
| 
 | ||
| void TMaskEditor_application::execute()
 | ||
| {
 | ||
|    TString app;
 | ||
|    if(!_window->filename().empty())
 | ||
|    {
 | ||
|      TFilename name=_window->filename();
 | ||
|      name.ext("");
 | ||
|      app<<"ba3 -3 " << name;
 | ||
|      TExternal_app exe(app);
 | ||
|      exe.run();
 | ||
|    }
 | ||
|    else
 | ||
|      save_as_mask();
 | ||
| }
 | ||
| 
 | ||
| //Visualizza i controlli presenti nella pagina corrente
 | ||
| void TMaskEditor_application::vision_ctrl()
 | ||
| {
 | ||
|    _window->vision_ctrl();
 | ||
| }
 | ||
| 
 | ||
| //Visualizza la "maschera" dello spreadsheet corrente
 | ||
| void TMaskEditor_application::vision_spread()
 | ||
| {
 | ||
|    _window->vision_spread();
 | ||
| }
 | ||
| 
 | ||
| //Visualizza i controllo della "maschera" dello spreadsheet corrente
 | ||
| void TMaskEditor_application::vision_sp_ctl()
 | ||
| {
 | ||
|    _window->vision_sp_ctl();
 | ||
| }
 | ||
| 
 | ||
| //Gestisce le scelte da menu
 | ||
| bool TMaskEditor_application::menu(MENU_TAG m) 
 | ||
| {
 | ||
|    switch (m)
 | ||
|    {
 | ||
|      case MENU_ITEM_ID(11):    // Nuovo...
 | ||
|        {
 | ||
|          _save=FALSE;
 | ||
|          new_mask();
 | ||
|        }                      
 | ||
|       break;
 | ||
|      case MENU_ITEM_ID(12):   // Apri...
 | ||
|        open_mask();
 | ||
|       break;
 | ||
|      case MENU_ITEM_ID(13):   // Salva...
 | ||
|        if(_window)   
 | ||
|        {
 | ||
|          _window->deselection();
 | ||
|          _window->inizialition();
 | ||
|          if(_save)
 | ||
|            save_mask();
 | ||
|          else save_as_mask();
 | ||
|        }  
 | ||
|       break;    
 | ||
|      case MENU_ITEM_ID(14):   // Salva con nome
 | ||
|       if(_window)
 | ||
|        {
 | ||
|          _window->deselection();
 | ||
|          _window->inizialition();
 | ||
|          save_as_mask();
 | ||
|        }
 | ||
|       break;
 | ||
|      case MENU_ITEM_ID(21):   // Copia i controlli selezionati
 | ||
|        if(_window)
 | ||
|          copy_crt_sel();
 | ||
|       break;   
 | ||
|      case MENU_ITEM_ID(22):   // Elimina i controlli selezionati
 | ||
|        if(_window)
 | ||
|          erase_crt_sel();
 | ||
|       break;
 | ||
|      case MENU_ITEM_ID(23):   // Sposta i controlli selezionati in un'altra pagina
 | ||
|        if(_window)
 | ||
|          move_crt_sel();
 | ||
|       break;   
 | ||
|      //Aggiunge controlli alla maschera
 | ||
|      case MENU_ITEM_ID(31):          //bottone
 | ||
|      case MENU_ITEM_ID(32):          //checkbox
 | ||
|      case MENU_ITEM_ID(33):          //currency
 | ||
|      case MENU_ITEM_ID(34):          //data
 | ||
|      case MENU_ITEM_ID(35):          //group
 | ||
|      case MENU_ITEM_ID(36):          //lista
 | ||
|      case MENU_ITEM_ID(37):          //memo
 | ||
|      case MENU_ITEM_ID(38):          //radio_bottoni
 | ||
|      case MENU_ITEM_ID(39):          //number
 | ||
|      case MENU_ITEM_ID(310):         //spreadsheet
 | ||
|      case MENU_ITEM_ID(311):         //stringa
 | ||
|      case MENU_ITEM_ID(312):         //text
 | ||
|      case MENU_ITEM_ID(313):         //zoom
 | ||
|        if(_window)
 | ||
|        {
 | ||
|          _window->deselection();
 | ||
|          _window->inizialition();
 | ||
|          add_control(m);
 | ||
|        }  
 | ||
|       break;                            
 | ||
|      case MENU_ITEM_ID(41):   // Visualizza controlli di pag.
 | ||
|        if(_window)
 | ||
|        {
 | ||
|          _window->deselection();
 | ||
|          _window->inizialition();
 | ||
|          vision_ctrl();
 | ||
|        }  
 | ||
|       break;
 | ||
|      case MENU_ITEM_ID(42):   // Visualizza mask di spread
 | ||
|        if(_window)
 | ||
|        {
 | ||
|          _window->deselection();  
 | ||
|          _window->inizialition();
 | ||
|          vision_spread();
 | ||
|        }  
 | ||
|       break;
 | ||
|      case MENU_ITEM_ID(43):    // Visualizza controlli di mask di spread
 | ||
|        if(_window)
 | ||
|        {
 | ||
|          _window->deselection();
 | ||
|          _window->inizialition();
 | ||
|          vision_sp_ctl();
 | ||
|        }  
 | ||
|       break;
 | ||
|      case MENU_ITEM_ID(51):    // Fa la compilazione della maschera
 | ||
|        if(_window)
 | ||
|        {                    
 | ||
|          _window->deselection();
 | ||
|          _window->inizialition();
 | ||
|          build();
 | ||
|        }
 | ||
|       break;   
 | ||
|      case MENU_ITEM_ID(52):    // Fa l'esecuzione della maschera
 | ||
|        if(_window)
 | ||
|        {                    
 | ||
|          _window->deselection();
 | ||
|          _window->inizialition();
 | ||
|          execute();
 | ||
|        }
 | ||
|       break;   
 | ||
|      default:
 | ||
|       break;
 | ||
|    }
 | ||
|     return TRUE;
 | ||
| }
 | ||
|        
 | ||
| int ba2600(int argc, char* argv[])
 | ||
| {
 | ||
|    TMaskEditor_application a;
 | ||
|    a.run(argc, argv, TR("Editor di maschere"));
 | ||
|     return 0;
 | ||
| }
 |