Aggiunti bottoni agli sheet
git-svn-id: svn://10.65.10.50/trunk@752 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									433135c22a
								
							
						
					
					
						commit
						386624b650
					
				@ -45,16 +45,17 @@ ACCEL MENU_FILE "f" ALT
 | 
			
		||||
	XI_CURSOR_HAND    cursor DISCARDABLE f:\p.due\bmp\hand.cur
 | 
			
		||||
	XI_CURSOR_VRESIZE cursor DISCARDABLE f:\p.due\bmp\vresize.cur
 | 
			
		||||
	COMBO_ICON        icon   DISCARDABLE f:\p.due\bmp\combo.ico
 | 
			
		||||
	ICO_SEARCH        icon   DISCARDABLE f:\p.due\bmp\search.ico
 | 
			
		||||
	BMP_OK            bitmap DISCARDABLE f:\p.due\bmp\ok.bmp
 | 
			
		||||
	BMP_CANCEL        bitmap DISCARDABLE f:\p.due\bmp\cancel.bmp
 | 
			
		||||
	BMP_QUIT          bitmap DISCARDABLE f:\p.due\bmp\quit.bmp
 | 
			
		||||
	BMP_QUITDN        bitmap DISCARDABLE f:\p.due\bmp\quitdn.bmp
 | 
			
		||||
	BMP_SELECT        bitmap DISCARDABLE f:\p.due\bmp\select.bmp
 | 
			
		||||
	BMP_FIRSTREC      bitmap DISCARDABLE f:\p.due\bmp\firstrec.bmp
 | 
			
		||||
	BMP_PREVREC       bitmap DISCARDABLE f:\p.due\bmp\prevrec.bmp
 | 
			
		||||
	BMP_STOPREC       bitmap DISCARDABLE f:\p.due\bmp\stoprec.bmp
 | 
			
		||||
	BMP_NEXTREC       bitmap DISCARDABLE f:\p.due\bmp\nextrec.bmp
 | 
			
		||||
	BMP_LASTREC       bitmap DISCARDABLE f:\p.due\bmp\lastrec.bmp
 | 
			
		||||
//        BMP_FIRSTREC      bitmap DISCARDABLE f:\p.due\bmp\firstrec.bmp
 | 
			
		||||
//        BMP_PREVREC       bitmap DISCARDABLE f:\p.due\bmp\prevrec.bmp
 | 
			
		||||
//        BMP_STOPREC       bitmap DISCARDABLE f:\p.due\bmp\stoprec.bmp
 | 
			
		||||
//        BMP_NEXTREC       bitmap DISCARDABLE f:\p.due\bmp\nextrec.bmp
 | 
			
		||||
//        BMP_LASTREC       bitmap DISCARDABLE f:\p.due\bmp\lastrec.bmp
 | 
			
		||||
	BMP_SAVEREC       bitmap DISCARDABLE f:\p.due\bmp\saverec.bmp
 | 
			
		||||
	BMP_SAVERECDN     bitmap DISCARDABLE f:\p.due\bmp\saverecd.bmp
 | 
			
		||||
	BMP_NEWREC        bitmap DISCARDABLE f:\p.due\bmp\newrec.bmp
 | 
			
		||||
 | 
			
		||||
@ -10,6 +10,12 @@ const short FIRST_FIELD = 101;
 | 
			
		||||
#include <xil.h>
 | 
			
		||||
#include <colors.h>
 | 
			
		||||
 | 
			
		||||
extern "C"
 | 
			
		||||
{
 | 
			
		||||
#include <cpb.h>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// TSpreadsheet
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
@ -41,12 +47,15 @@ class TSpreadsheet : public TWindow
 | 
			
		||||
  bool _row_dirty;               // Current row changed
 | 
			
		||||
  bool _check_enabled;           // Perform OFF_ROW checks
 | 
			
		||||
  
 | 
			
		||||
  short _icon;
 | 
			
		||||
 | 
			
		||||
  static void xiev_handler(XI_OBJ *itf, XI_EVENT *xiev);
 | 
			
		||||
  void init();
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  void list_handler(XI_EVENT *xiev);
 | 
			
		||||
 | 
			
		||||
  TMask_field* col2field(int pos) const;
 | 
			
		||||
  TMask_field* cell2field(const XI_OBJ* cell) const;
 | 
			
		||||
  void update_rec(int rec);
 | 
			
		||||
  TMask_field* field(short id) const;
 | 
			
		||||
@ -120,7 +129,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
 | 
			
		||||
                           TSheet_field* o)
 | 
			
		||||
: _mask(maskname, maskno), _notify(NULL), _edit_field(NULL), 
 | 
			
		||||
  _owner(o), _cur_row(0), _cur_col(0), _active(TRUE),
 | 
			
		||||
  _row_dirty(FALSE), _check_enabled(TRUE), _firstfocus(TRUE)
 | 
			
		||||
  _row_dirty(FALSE), _check_enabled(TRUE), _firstfocus(TRUE), _icon(0)
 | 
			
		||||
{
 | 
			
		||||
  const int NUMBER_WIDTH = 3;
 | 
			
		||||
  const int MAX_COL = 32;
 | 
			
		||||
@ -152,7 +161,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
 | 
			
		||||
    {
 | 
			
		||||
      const TString& wi = testa.mid(at+1);
 | 
			
		||||
      m = atoi(wi);
 | 
			
		||||
      if (wi[wi.len()-1] == 'F') 
 | 
			
		||||
      if (wi.find('F') >= 0) 
 | 
			
		||||
      {
 | 
			
		||||
        fixed_columns++;
 | 
			
		||||
        f_width += m+1;
 | 
			
		||||
@ -224,15 +233,36 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
 | 
			
		||||
  {
 | 
			
		||||
    const int cid = FIRST_FIELD+i;                     // Column & Field ID
 | 
			
		||||
    const TMask_field* f = field(cid);                 // Field on mask
 | 
			
		||||
    const int acqua = f->class_id();
 | 
			
		||||
 | 
			
		||||
    long flags =  XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL;
 | 
			
		||||
    if (f->class_id() == CLASS_REAL_FIELD) flags |= XI_ATR_RJUST;
 | 
			
		||||
    switch (acqua)
 | 
			
		||||
    {
 | 
			
		||||
    case CLASS_REAL_FIELD:
 | 
			
		||||
      flags |= XI_ATR_RJUST; break;
 | 
			
		||||
    case CLASS_BUTTON_FIELD:
 | 
			
		||||
      flags |= XI_ATR_SELECTABLE; break;
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
    }      
 | 
			
		||||
    if (f->active()) flags |= XI_ATR_ENABLED | XI_ATR_FOCUSBORDER | XI_ATR_AUTOSELECT;
 | 
			
		||||
    else _column_disabled.set(i);
 | 
			
		||||
 | 
			
		||||
    coldef = xi_add_column_def(listdef, cid, flags, cid, v_width[i], m_width[i], (char*)h);
 | 
			
		||||
    coldef->v.column->heading_platform = TRUE;
 | 
			
		||||
    coldef->v.column->center_heading = TRUE;
 | 
			
		||||
    if (acqua == CLASS_BUTTON_FIELD)
 | 
			
		||||
    {
 | 
			
		||||
      const TString80 testa(header.get(i));
 | 
			
		||||
      const int diesis = testa.find('#');
 | 
			
		||||
      if (diesis > 0) 
 | 
			
		||||
      {
 | 
			
		||||
        _icon = atoi(testa.mid(diesis+1));
 | 
			
		||||
        coldef->v.column->icon_x = (v_width[i]*CHARX-16) >> 1;
 | 
			
		||||
        coldef->v.column->icon_y = (CHARY-16) >> 1;  
 | 
			
		||||
        coldef->v.column->column_platform = TRUE;
 | 
			
		||||
      }  
 | 
			
		||||
    }  
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  RCT itfrct;
 | 
			
		||||
@ -291,11 +321,10 @@ int TSpreadsheet::rec2row(int record)
 | 
			
		||||
  return r;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Retrieves the corresponding field of the mask from a spredsheet cell
 | 
			
		||||
TMask_field* TSpreadsheet::cell2field(const XI_OBJ* cell) const
 | 
			
		||||
{
 | 
			
		||||
  const int& pos = cell->v.cell.column;
 | 
			
		||||
 | 
			
		||||
// Retrieves the corresponding field of the mask from a spredsheet cell
 | 
			
		||||
TMask_field* TSpreadsheet::col2field(int pos) const
 | 
			
		||||
{
 | 
			
		||||
  int num;
 | 
			
		||||
  XI_OBJ** column = xi_get_member_list(_list, &num);
 | 
			
		||||
 | 
			
		||||
@ -312,6 +341,13 @@ TMask_field* TSpreadsheet::cell2field(const XI_OBJ* cell) const
 | 
			
		||||
  return good;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Retrieves the corresponding field of the mask from a spredsheet cell
 | 
			
		||||
TMask_field* TSpreadsheet::cell2field(const XI_OBJ* cell) const
 | 
			
		||||
{
 | 
			
		||||
  return col2field(cell->v.cell.column);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TSpreadsheet::update_rec(int rec)
 | 
			
		||||
{
 | 
			
		||||
  const int riga = rec2row(rec);
 | 
			
		||||
@ -397,6 +433,7 @@ void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev)
 | 
			
		||||
void TSpreadsheet::list_handler(XI_EVENT *xiev)
 | 
			
		||||
{
 | 
			
		||||
  static KEY _lastab = K_TAB;
 | 
			
		||||
  static bool _cell_dirty;
 | 
			
		||||
 | 
			
		||||
  switch (xiev->type)
 | 
			
		||||
  {
 | 
			
		||||
@ -441,19 +478,28 @@ break;
 | 
			
		||||
    {   
 | 
			
		||||
      const int col = cid - FIRST_FIELD;
 | 
			
		||||
      TMask_field* f = field(cid);
 | 
			
		||||
      src = row(rec).get(col);                  // Set value for cell
 | 
			
		||||
      if (src && *src && (f->class_id() == CLASS_REAL_FIELD 
 | 
			
		||||
                          || f->class_id() == CLASS_DATE_FIELD))
 | 
			
		||||
      const int acqua = f->class_id();
 | 
			
		||||
      
 | 
			
		||||
      if (acqua == CLASS_BUTTON_FIELD)
 | 
			
		||||
      {
 | 
			
		||||
        src = f->picture_data(src, FALSE);      // Get formatted string
 | 
			
		||||
        xiev->v.cell_request.icon_rid = _icon;
 | 
			
		||||
        src = NULL;
 | 
			
		||||
      }
 | 
			
		||||
      if (field(cid)->has_query())
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        xiev->v.cell_request.button =
 | 
			
		||||
          xiev->v.cell_request.button_on_focus = TRUE;
 | 
			
		||||
        src = row(rec).get(col);                  // Set value for cell
 | 
			
		||||
        if (src && *src && (acqua == CLASS_REAL_FIELD || acqua == CLASS_DATE_FIELD))
 | 
			
		||||
        {
 | 
			
		||||
          src = f->picture_data(src, FALSE);      // Get formatted string
 | 
			
		||||
        }
 | 
			
		||||
        if (field(cid)->has_query())
 | 
			
		||||
        {
 | 
			
		||||
          xiev->v.cell_request.button =
 | 
			
		||||
            xiev->v.cell_request.button_on_focus = TRUE;
 | 
			
		||||
        }
 | 
			
		||||
        if (cell_disabled(rec, col))
 | 
			
		||||
          xiev->v.cell_request.back_color = MASK_BACK_COLOR;
 | 
			
		||||
      }
 | 
			
		||||
      if (cell_disabled(rec, col))
 | 
			
		||||
        xiev->v.cell_request.back_color = MASK_BACK_COLOR;
 | 
			
		||||
    }  
 | 
			
		||||
  } else src = format("%d", rec+1);
 | 
			
		||||
 | 
			
		||||
@ -478,15 +524,29 @@ break;
 | 
			
		||||
  notify(_cur_row, K_SPACE);
 | 
			
		||||
  _row_dirty = TRUE;
 | 
			
		||||
}  
 | 
			
		||||
_cell_dirty = TRUE;
 | 
			
		||||
break;
 | 
			
		||||
 case XIE_BUTTON:
 | 
			
		||||
 if (xiev->v.xi_obj->type == XIT_CELL)
 | 
			
		||||
{
 | 
			
		||||
  dispatch_e_char(win(), K_F9);
 | 
			
		||||
} else
 | 
			
		||||
if (xiev->v.xi_obj->type == XIT_LIST)
 | 
			
		||||
 else
 | 
			
		||||
 if (xiev->v.xi_obj->type == XIT_LIST)
 | 
			
		||||
  insert(-1);
 | 
			
		||||
  break;
 | 
			
		||||
 case XIE_SELECT:
 | 
			
		||||
 if (xiev->v.xi_obj->type == XIT_ROW)
 | 
			
		||||
{
 | 
			
		||||
  if (!_row_dirty)
 | 
			
		||||
  {
 | 
			
		||||
    notify(_cur_row, K_SPACE);
 | 
			
		||||
    _row_dirty = TRUE;
 | 
			
		||||
  }  
 | 
			
		||||
  TMask_field* f = col2field(xiev->v.select.column);
 | 
			
		||||
  f->on_hit();
 | 
			
		||||
  mask2str(_cur_row);
 | 
			
		||||
}    
 | 
			
		||||
xiev->refused = TRUE;
 | 
			
		||||
break;
 | 
			
		||||
 case XIE_DBL_CELL:
 | 
			
		||||
{
 | 
			
		||||
  _check_enabled = FALSE;
 | 
			
		||||
@ -552,6 +612,7 @@ break;
 | 
			
		||||
  }  
 | 
			
		||||
  else
 | 
			
		||||
  {              
 | 
			
		||||
    set_dirty();
 | 
			
		||||
    xvt_statbar_refresh();
 | 
			
		||||
  }  
 | 
			
		||||
  _check_enabled = TRUE;
 | 
			
		||||
@ -570,6 +631,7 @@ break;
 | 
			
		||||
  {  
 | 
			
		||||
    _edit_field = f;
 | 
			
		||||
    _cur_col = xiev->v.xi_obj->v.cell.column;
 | 
			
		||||
    _cell_dirty = FALSE;
 | 
			
		||||
  }  
 | 
			
		||||
}
 | 
			
		||||
break;
 | 
			
		||||
@ -577,7 +639,7 @@ break;
 | 
			
		||||
 if (_edit_field && _check_enabled)
 | 
			
		||||
{
 | 
			
		||||
  _check_enabled = FALSE;
 | 
			
		||||
  if (_row_dirty)
 | 
			
		||||
  if (_cell_dirty)
 | 
			
		||||
  {
 | 
			
		||||
    TMask_field* c = _edit_field;       // Save field, it could turn out to be NULL on error
 | 
			
		||||
    const char* nuo = c->picture_data(xi_get_text(xiev->v.xi_obj, NULL, -1), TRUE);
 | 
			
		||||
@ -645,13 +707,17 @@ break;
 | 
			
		||||
        if (_check_enabled)
 | 
			
		||||
        {
 | 
			
		||||
          _check_enabled = FALSE;                               // Disable checks
 | 
			
		||||
          if (!_row_dirty) notify(_cur_row, K_SPACE);
 | 
			
		||||
          if (!_row_dirty) 
 | 
			
		||||
          {
 | 
			
		||||
            notify(_cur_row, K_SPACE);
 | 
			
		||||
            _row_dirty = TRUE;
 | 
			
		||||
          }  
 | 
			
		||||
          if (_edit_field->on_key(k))
 | 
			
		||||
          {
 | 
			
		||||
            mask2str(_cur_row);
 | 
			
		||||
            _row_dirty = TRUE;
 | 
			
		||||
          }                               
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            if (k == K_F9)
 | 
			
		||||
            {
 | 
			
		||||
              _edit_field = &_mask.fld(_mask.focus_field());
 | 
			
		||||
@ -663,6 +729,7 @@ break;
 | 
			
		||||
                dispatch_e_char(win(), K_F9);
 | 
			
		||||
              }
 | 
			
		||||
            }  
 | 
			
		||||
          }  
 | 
			
		||||
          set_focus_cell(_cur_row, _cur_col);
 | 
			
		||||
          _check_enabled = TRUE;                                // Enable checks
 | 
			
		||||
        }  
 | 
			
		||||
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
#define VERSION 1.16
 | 
			
		||||
#define VERSION 1.1
 | 
			
		||||
 | 
			
		||||
@ -29,6 +29,8 @@
 | 
			
		||||
 | 
			
		||||
#if XVT_OS == XVT_OS_WIN
 | 
			
		||||
 | 
			
		||||
#define ICO_SEARCH    109
 | 
			
		||||
 | 
			
		||||
#define BMP_OK        101
 | 
			
		||||
#define BMP_CANCEL    102
 | 
			
		||||
#define BMP_SAVEREC   103
 | 
			
		||||
@ -63,8 +65,9 @@
 | 
			
		||||
#define BMP_NEWRECDN  155
 | 
			
		||||
#define BMP_QUITDN    164
 | 
			
		||||
#define BMP_SETPRINT  165
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* @END */
 | 
			
		||||
#endif // __URLDEFID_H
 | 
			
		||||
#endif 
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user