From f69408386cf274afbe3ee1e4b242eed055c91fe3 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 9 Nov 1995 08:07:36 +0000 Subject: [PATCH] maskfld.cpp Corretta picture_data per non trimmare sempre msksheet.cpp Aggiunta funzione set_column_justify msksheet.h Dichiarazione della funzione precedente git-svn-id: svn://10.65.10.50/trunk@2116 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/maskfld.cpp | 3 +- include/msksheet.cpp | 80 ++++++++++++++++++++++++++++++++------------ include/msksheet.h | 3 ++ 3 files changed, 63 insertions(+), 23 deletions(-) diff --git a/include/maskfld.cpp b/include/maskfld.cpp index 6977a8339..fb18bf3c3 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -2179,7 +2179,8 @@ const char* TEdit_field::format(const char* d) const const char* TEdit_field::picture_data(const char* data, bool video) const { fpark = video ? data : format(data); - return fpark.trim(); + if (_flags.trim) fpark.trim(); + return fpark; } diff --git a/include/msksheet.cpp b/include/msksheet.cpp index e9dfe3a4b..fa5815e00 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -126,6 +126,9 @@ protected: // @cmember Permette di fare tutti gli aggiornamenti necessari (indicati in //

) void on_idle(); + + // @cmember Cerca la colonna col + XI_OBJ* TSpreadsheet::find_column(int col) const; // @access Public Member public: @@ -170,7 +173,8 @@ public: void set_column_width(const int col, const int width) const; // @cmember Setta il titolo della colonna void set_column_header(const int col, const TString& header) const; - + // @cmember Setta l'allinemento di una colonna + void set_column_justify(int col, bool right); // @cmember Permette di abilitare/disabilitare una singola cella void enable_cell(int row, int column, bool on = TRUE); // @cmember Controlla se una cella e' disabilitata @@ -1200,6 +1204,7 @@ public: void move_column( const int fromindex, const int toindex ) const; void set_column_width( const int col, const int width ) const; void set_column_header( const int col, const TString& header ) const; + void set_column_justify(int col, bool right); void enable_cell(int row, int column, bool on = TRUE); bool cell_disabled(int row, int column) const; @@ -1400,11 +1405,13 @@ void TSpreadsheet::enable_column( if (on) attr |= XI_ATR_ENABLED; else attr &= ~XI_ATR_ENABLED; - xi_move_focus(_itf); // Set focus to interface +// xi_move_focus(_itf); // Set focus to interface xi_set_attrib(column, attr); // Set new attributes +/* RCT r; xi_get_rect(column, &r); xi_set_column_width(column, (r.right-r.left+1) / CHARX); // Force redraw - +*/ + update(-1); break; } @@ -1412,16 +1419,34 @@ void TSpreadsheet::enable_column( #endif } -// Matteo - +// @mfunc Cerca la colonna col +XI_OBJ* TSpreadsheet::find_column( + int col) const // @param Indice o identificatore colonna +{ + CHECKD(col >= 0, "Bad column ", col); + if (col < columns()) // Se e' un indice trasformalo in identificatore + col += FIRST_FIELD; + int num; + XI_OBJ** columns = xi_get_member_list(_list, &num); + for (int c = 1; c < num; c++) + { + if (columns[c]->cid == col) + break; + } + + if (c == num) + { + yesnofatal_box("Can't find column with id=%d", col); + c = 0; + } + + return columns[c]; +} + void TSpreadsheet::delete_column( const int col ) const { #if XVT_OS == XVT_OS_WIN - int num; - XI_OBJ** columns = xi_get_member_list(_list, &num); - CHECKD( col+1 < num, "Can't delete column ", col ); - XI_OBJ* column = columns[ col+1]; - + XI_OBJ* column = find_column(col); xi_delete( column ); #endif } @@ -1430,7 +1455,6 @@ void TSpreadsheet::delete_column( const int col ) const void TSpreadsheet::move_column( const int fromindex, const int toindex) const { #if XVT_OS == XVT_OS_WIN - int num; XI_OBJ** columns = xi_get_member_list(_list, &num); CHECKD(fromindex+1 < num, "Can't move column ", fromindex); @@ -1481,11 +1505,7 @@ void TSpreadsheet::swap_rows( const int fromindex, const int toindex) void TSpreadsheet::set_column_width(const int col, const int width) const { #if XVT_OS == XVT_OS_WIN - int num; - XI_OBJ** columns = xi_get_member_list(_list, &num); - CHECKD(col+1 < num, "Can't set column width ", col); - XI_OBJ* column = columns[col+1]; - + XI_OBJ* column = find_column(col); xi_set_column_width(column, width); // Force redraw #endif } @@ -1493,18 +1513,26 @@ void TSpreadsheet::set_column_width(const int col, const int width) const void TSpreadsheet::set_column_header(const int col, const TString& header) const { #if XVT_OS == XVT_OS_WIN - int num; - XI_OBJ** columns = xi_get_member_list(_list, &num); - CHECKD(col+1 < num, "Can't set column width ", col); - XI_OBJ* column = columns[col+1]; - + XI_OBJ* column = find_column(col); xi_set_text(column, (char *)(const char *)header ); RCT r; xi_get_rect(column, &r); xi_set_column_width(column, (r.right-r.left+1) / CHARX); // Force redraw #endif } - +void TSpreadsheet::set_column_justify(int col, bool right) +{ +#if XVT_OS == XVT_OS_WIN + XI_OBJ* column = find_column(col); + dword attr = xi_get_attrib(column); + if (right) + attr |= XI_ATR_RJUST; + else + attr &= ~XI_ATR_RJUST; + xi_set_attrib(column, attr); // Set new attribute + update(-1); +#endif +} // Certified 99% // @mfunc Controlla se una cella o un'intera riga e' disabilitata @@ -1890,6 +1918,14 @@ void TSheet_field::set_column_header( const int col, const TString& header ) con _sheet->set_column_header(col, header); } +void TSheet_field::set_column_justify(int col, bool right) +{ + if (col < FIRST_FIELD) + col += FIRST_FIELD; + sheet_mask().field(col).set_justify(right); + _sheet->set_column_justify(col, right); +} + TMask& TSheet_field::sheet_mask() const { return _sheet->sheet_mask(); diff --git a/include/msksheet.h b/include/msksheet.h index 381edc35a..4a2dfd655 100755 --- a/include/msksheet.h +++ b/include/msksheet.h @@ -123,6 +123,9 @@ public: void set_column_width( const int col, const int width ) const; // @cmember Setta il titolo della colonna void set_column_header( const int col, const TString& header ) const; + // @cmember Setta l'allineamento della colonna + void set_column_justify(int col, bool right); + // @cmember Setta il member

con il valore di

void set_append(bool on = TRUE) { _append = on;}