]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dbgrid.cpp
Rework the wxCusor ctor taking wx stock number to provide as many cursors as
[wxWidgets.git] / src / common / dbgrid.cpp
index cb3cd9c99eadc321957276794f3afaf944f62e29..634be020d86bc7e42dddf0a28f3732e90493a27e 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        dbgrid.cpp
+// Name:        src/common/dbgrid.cpp
 // Purpose:     Displays a wxDbTable in a wxGrid.
 // Author:      Roger Gammans, Paul Gammans
 // Modified by:
 // Branched From : dbgrid.cpp,v 1.18 2000/12/19 13:00:58
 ///////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "dbgrid.h"
-#endif
-
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
     #pragma hdrstop
 #endif
 
-
-#if wxUSE_ODBC
-#if wxUSE_GRID
+#if wxUSE_ODBC && wxUSE_GRID
 
 #ifndef WX_PRECOMP
     #include "wx/textctrl.h"
     #include "wx/dc.h"
+    #include "wx/app.h"
 #endif // WX_PRECOMP
 
 #include "wx/generic/gridctrl.h"
 #include "wx/dbgrid.h"
 
 // DLL options compatibility check:
-#include "wx/app.h"
 WX_CHECK_BUILD_OPTIONS("wxDbGrid")
 
 
@@ -209,11 +203,12 @@ bool wxDbGridTableBase::AssignDbTable(wxDbTable *tab, int count, bool takeOwners
 {
     wxDbGridCellAttrProvider *provider;
 
+    wxGridUpdateLocker locker(GetView());
+
     //Remove Information from grid about old data
     if (GetView())
     {
         wxGrid *grid = GetView();
-        grid->BeginBatch();
         grid->ClearSelection();
         if (grid->IsCellEditControlEnabled())
         {
@@ -256,7 +251,6 @@ bool wxDbGridTableBase::AssignDbTable(wxDbTable *tab, int count, bool takeOwners
         wxGrid * grid = GetView();
         wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_rowtotal);
         grid->ProcessTableMessage(msg);
-        grid->EndBatch();
     }
     m_dbowner = takeOwnership;
     m_rowmodified = false;
@@ -276,11 +270,16 @@ wxString wxDbGridTableBase::GetTypeName(int WXUNUSED(row), int col)
             switch(m_data->GetColDefs()[(m_ColInfo[col].DbCol)].SqlCtype)
             {
                 case SQL_C_CHAR:
+#ifdef SQL_C_WCHAR
+                case SQL_C_WCHAR:
+#endif
                     return wxGRID_VALUE_STRING;
+                case SQL_C_SHORT:
                 case SQL_C_SSHORT:
                     return wxGRID_VALUE_NUMBER;
                 case SQL_C_USHORT:
                     return wxGRID_VALUE_NUMBER;
+                case SQL_C_LONG:
                 case SQL_C_SLONG:
                     return wxGRID_VALUE_NUMBER;
                 case SQL_C_ULONG:
@@ -320,7 +319,7 @@ bool wxDbGridTableBase::CanGetValueAs(int row, int col, const wxString& typeName
         return true;
     }
 
-    if (m_data->IsColNull(m_ColInfo[col].DbCol))
+    if (m_data->IsColNull((UWORD)m_ColInfo[col].DbCol))
     {
         return false;
     }
@@ -443,7 +442,7 @@ long wxDbGridTableBase::GetValueAsLong(int row, int col)
         (sqltype == SQL_C_SLONG) ||
         (sqltype == SQL_C_ULONG))
     {
-        wxVariant val = m_data->GetCol(m_ColInfo[col].DbCol);
+        wxVariant val = m_data->GetColumn(m_ColInfo[col].DbCol);
         return val.GetLong();
     }
     wxFAIL_MSG (_T("unknown column, "));
@@ -468,7 +467,7 @@ double wxDbGridTableBase::GetValueAsDouble(int row, int col)
         (sqltype == SQL_C_FLOAT) ||
         (sqltype == SQL_C_DOUBLE))
     {
-        wxVariant val = m_data->GetCol(m_ColInfo[col].DbCol);
+        wxVariant val = m_data->GetColumn(m_ColInfo[col].DbCol);
         return val.GetDouble();
     }
     wxFAIL_MSG (_T("unknown column"));
@@ -491,7 +490,7 @@ bool wxDbGridTableBase::GetValueAsBool(int row, int col)
         (sqltype == SQL_C_SLONG) ||
         (sqltype == SQL_C_ULONG))
     {
-        wxVariant val = m_data->GetCol(m_ColInfo[col].DbCol);
+        wxVariant val = m_data->GetColumn(m_ColInfo[col].DbCol);
         return val.GetBool();
     }
     wxFAIL_MSG (_T("unknown column, "));
@@ -508,7 +507,7 @@ void* wxDbGridTableBase::GetValueAsCustom(int row, int col, const wxString& type
         wxFAIL_MSG (_T("You can not use GetValueAsCustom for virtual columns"));
         return NULL;
     }
-    if (m_data->IsColNull(m_ColInfo[col].DbCol))
+    if (m_data->IsColNull((UWORD)m_ColInfo[col].DbCol))
         return NULL;
 
     if (typeName == wxGRID_VALUE_DATETIME)
@@ -520,7 +519,7 @@ void* wxDbGridTableBase::GetValueAsCustom(int row, int col, const wxString& type
             (sqltype == SQL_C_TIME) ||
             (sqltype == SQL_C_TIMESTAMP))
         {
-            wxVariant val = m_data->GetCol(m_ColInfo[col].DbCol);
+            wxVariant val = m_data->GetColumn(m_ColInfo[col].DbCol);
             return new wxDateTime(val.GetDateTime());
         }
     }
@@ -557,7 +556,7 @@ void wxDbGridTableBase::SetValueAsCustom(int row, int col, const wxString& typeN
             }
             wxVariant val(date);
             m_rowmodified = true;
-            m_data->SetCol(m_ColInfo[col].DbCol,val);
+            m_data->SetColumn(m_ColInfo[col].DbCol,val);
         }
     }
     wxFAIL_MSG (_T("unknown column data type"));
@@ -580,7 +579,7 @@ bool wxDbGridTableBase::IsEmptyCell(int row, int col)
     wxLogDebug(wxT("IsEmtpyCell on %i,%i"),row,col);
 
     ValidateRow(row);
-    return m_data->IsColNull(m_ColInfo[col].DbCol);
+    return m_data->IsColNull((UWORD)m_ColInfo[col].DbCol);
 }
 
 
@@ -589,7 +588,7 @@ wxString wxDbGridTableBase::GetValue(int row, int col)
     wxLogDebug(wxT("GetValue() on %i,%i"),row,col);
 
     ValidateRow(row);
-    wxVariant val = m_data->GetCol(m_ColInfo[col].DbCol);
+    wxVariant val = m_data->GetColumn(m_ColInfo[col].DbCol);
     wxLogDebug(wxT("\tReturning \"%s\"\n"),val.GetString().c_str());
 
     return val.GetString();
@@ -604,7 +603,7 @@ void wxDbGridTableBase::SetValue(int row, int col,const wxString& value)
     wxVariant val(value);
 
     m_rowmodified = true;
-    m_data->SetCol(m_ColInfo[col].DbCol,val);
+    m_data->SetColumn(m_ColInfo[col].DbCol,val);
 }
 
 
@@ -616,7 +615,7 @@ void wxDbGridTableBase::SetValueAsLong(int row, int col, long value)
     wxVariant val(value);
 
     m_rowmodified = true;
-    m_data->SetCol(m_ColInfo[col].DbCol,val);
+    m_data->SetColumn(m_ColInfo[col].DbCol,val);
 }
 
 
@@ -628,7 +627,7 @@ void wxDbGridTableBase::SetValueAsDouble(int row, int col, double value)
     wxVariant val(value);
 
     m_rowmodified = true;
-    m_data->SetCol(m_ColInfo[col].DbCol,val);
+    m_data->SetColumn(m_ColInfo[col].DbCol,val);
 
 }
 
@@ -641,13 +640,14 @@ void wxDbGridTableBase::SetValueAsBool(int row, int col, bool value)
     wxVariant val(value);
 
     m_rowmodified = true;
-    m_data->SetCol(m_ColInfo[col].DbCol,val);
+    m_data->SetColumn(m_ColInfo[col].DbCol,val);
 }
 
 
 void wxDbGridTableBase::ValidateRow(int row)
 {
-    wxLogDebug(wxT("ValidateRow(%i) currently on row (%i). Array count = %i"),row,m_row,m_keys.GetCount());
+    wxLogDebug(wxT("ValidateRow(%i) currently on row (%i). Array count = %lu"),
+               row, m_row, (unsigned long)m_keys.GetCount());
 
     if (row == m_row)
          return;
@@ -722,8 +722,6 @@ bool wxDbGridTableBase::Writeback() const
 
 #include "wx/arrimpl.cpp"
 
-WX_DEFINE_EXPORTED_OBJARRAY(keyarray);
-
-#endif  // #if wxUSE_GRID
-#endif  // #if wxUSE_ODBC
+WX_DEFINE_EXPORTED_OBJARRAY(keyarray)
 
+#endif  // wxUSE_GRID && wxUSE_ODBC