msksheet.cpp Corretta gestione focus

real.cpp      Corretta string con i long double


git-svn-id: svn://10.65.10.50/trunk@2057 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-10-31 14:01:20 +00:00
parent 28806b097d
commit 187fdac4fc
2 changed files with 43 additions and 58 deletions

View File

@ -458,18 +458,18 @@ int TSpreadsheet::row2rec(int& row)
if (row < 0) if (row < 0)
{ {
row = 0; row = 0;
r = (int)rec[row]-1; r = (int)rec[row] /* -1 */;
} }
else else
if (row >= rows) if (row >= rows)
{ {
row = rows-1; row = rows-1;
r = (int)rec[row]+1; r = (int)rec[row] /* +1 */;
} }
else else
r = (int)rec[row]; r = (int)rec[row];
CHECKD(r >= 0 && r <= items(), "Sheet line out of range: ", row); CHECKD(r >= 0 && r < items(), "Sheet line out of range: ", row);
return r; return r;
} }
@ -809,7 +809,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
{ {
notify_change(); notify_change();
_cell_dirty = TRUE; _cell_dirty = TRUE;
_edit_field->set_focusdirty(); _edit_field->set_dirty();
} }
break; break;
case XIE_BUTTON: case XIE_BUTTON:
@ -1824,7 +1824,7 @@ void TSheet_field::highlight() const
{ {
int rows; xi_get_list_info(_sheet->_list, &rows); int rows; xi_get_list_info(_sheet->_list, &rows);
if (rows > 0) if (rows > 0)
{ {
_sheet->set_focus_cell(_sheet->_cur_row, _sheet->_cur_col); _sheet->set_focus_cell(_sheet->_cur_row, _sheet->_cur_col);
_sheet->str2mask(selected()); _sheet->str2mask(selected());
} }
@ -1921,19 +1921,22 @@ bool TSheet_field::on_key(KEY k)
{ {
if (!test_focus_change()) if (!test_focus_change())
return FALSE; return FALSE;
}; }
if (k == K_ROWEDIT )
if (k == K_TAB && !focusdirty() && items() > 0)
{
select(0);
}
if (k == K_ROWEDIT && items() > 0)
{ {
if ( items( ) ) select(items()-1);
{ XI_EVENT xie;
_sheet->select( _sheet->items( ) - 1 ); xie.type = XIE_DBL_CELL;
XI_EVENT xie; xie.v.xi_obj = NULL;
xie.type = XIE_DBL_CELL; _sheet->list_handler( &xie );
xie.v.xi_obj = NULL; return TRUE;
_sheet->list_handler( &xie ); }
return TRUE;
}
};
return TMask_field::on_key(k); return TMask_field::on_key(k);
} }

View File

@ -122,48 +122,30 @@ char *real::string (
// <nl>Nel secondo caso ritorna la stringa con il formato stabilito in // <nl>Nel secondo caso ritorna la stringa con il formato stabilito in
// <p picture>. // <p picture>.
{ {
if (dec != UNDEFINED) TString16 fmt("%");
{ if (pad != ' ') fmt << '0';
if (len != 0) if (len != 0) fmt << len;
sprintf(__string, "%*.*Lf", len, dec, _dec); if (dec != UNDEFINED) fmt << '.' << dec;
else fmt << "Lf";
sprintf(__string, "%.*Lf", dec, _dec); sprintf(__string, fmt, _dec);
}
else
{
if (len != 0)
sprintf(__string, "%*Lf", len, _dec);
else
sprintf(__string, "%Lf", _dec);
if (strchr(__string, '.') != NULL)
{
int cut = strlen (__string);
for (int i = cut-1; i >= 0; i--)
{
if (__string[i] == '0')
cut--;
else
{
if(__string[i] == '.')
cut--;
break;
}
}
__string[cut] = '\0';
}
}
const int lun = strlen (__string);
if (lun < len)
{
const int delta = len - lun;
for (int i = lun; i >= 0; i--)
__string[i + delta] = __string[i];
for (i = 0; i < delta; i++)
__string[i] = pad;
}
if (len == 0 && dec == UNDEFINED && strchr(__string, '.') != NULL)
{
int cut = strlen (__string);
for (int i = cut-1; i >= 0; i--)
{
if (__string[i] == '0')
cut--;
else
{
if(__string[i] == '.')
cut--;
break;
}
}
__string[cut] = '\0';
}
return __string; return __string;
} }