]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/dbbrowse/dbgrid.cpp
Fixes to allow compilation with no wchar_t (djgpp probably has a real wchar_t
[wxWidgets.git] / demos / dbbrowse / dbgrid.cpp
index 3412640ac75fccd85282fb887af0e6b7f67139c9..8647a88c441afe98f89146863ac77a117c5ed935 100644 (file)
@@ -56,7 +56,7 @@ END_EVENT_TABLE()
 
 //----------------------------------------------------------------------------------------
 //           wxListCtrl(parent, id, pos, size, style)
-//           wxGrid(parent,-1,wxPoint( 0, 0 ), wxSize( 400, 300 ) );
+//           wxGrid(parent,wxID_ANY,wxPoint( 0, 0 ), wxSize( 400, 300 ) );
 //----------------------------------------------------------------------------------------
 // DBGrid
 //----------------------------------------------------------------------------------------
@@ -65,11 +65,11 @@ END_EVENT_TABLE()
 DBGrid::DBGrid(wxWindow *parent, const wxWindowID id,const wxPoint& pos,const wxSize& size, long style):
 wxGrid(parent, id, pos, size, style)
 {
-    b_EditModus = FALSE;
+    b_EditModus = false;
     //---------------------------------------------------------------------------------------
-    popupMenu1 = new wxMenu("");
+    popupMenu1 = new wxMenu;
     popupMenu1->Append(GRID_EDIT, _("Edit Modus"));
-    popupMenu2 = new wxMenu("");
+    popupMenu2 = new wxMenu;
     popupMenu2->Append(GRID_BROWSE, _("Browse Modus"));
 }
 
@@ -85,7 +85,7 @@ int  DBGrid::OnTableView(wxString Table)
 {
     wxStopWatch sw;
     //---------------------------------------------------------------------------------------
-    int  i=0,x,y,z, ValidTable=0;
+    int  x,y,z;
     wxString Temp0;
     wxBeginBusyCursor();
     SetDefaultCellFont(* pDoc->ft_Doc);
@@ -98,13 +98,13 @@ int  DBGrid::OnTableView(wxString Table)
         {
             if (!wxStrcmp((ct_BrowserDB->pTableInf+x)->tableName,Table))      // is this our Table ?
             {    // Yes, the Data of this Table shall be put into the Grid
-                ValidTable = x;                                                  // Save the Tablenumber
-                (db_Br+i_Which)->OnSelect(Table,FALSE);                          // Select * from "table"
+                int ValidTable = x;                                              // Save the Tablenumber
+                (db_Br+i_Which)->OnSelect(Table,false);                          // Select * from "table"
                 // Set the local Pointer to the Column Information we are going to use
                 (db_Br+i_Which)->cl_BrowserDB = (ct_BrowserDB->pTableInf+x)->pColInf;
                 if ((ct_BrowserDB->pTableInf+x)->pColInf)                        // Valid pointer (!= NULL) ?
                 {   // Pointer is Valid, Column Informationen sind Vorhanden
-                    i = (db_Br+i_Which)->i_Records;                                 // How many Records are there
+                    int i = (db_Br+i_Which)->i_Records;                             // How many Records are there
                     (db_Br+i_Which)->i_Which = ValidTable;                          // Still used ???? mj10777
                     if (i == 0)     // If the Table is empty, then show one empty row
                         i++;
@@ -119,21 +119,25 @@ int  DBGrid::OnTableView(wxString Table)
                     // The Grid has been created, now fill it
                     for (z=0;z<(db_Br+i_Which)->i_Records;z++)                      // Loop through the Records
                     {
-                        Temp0.Printf("%06d",z+1);  SetRowLabelValue(z,Temp0);          // Set Row Lable Value
-                        (db_Br+i_Which)->OnGetNext((ct_BrowserDB->pTableInf+ValidTable)->numCols,FALSE);
+                        Temp0.Printf(_T("%06d"),z+1);  SetRowLabelValue(z,Temp0);          // Set Row Lable Value
+                        (db_Br+i_Which)->OnGetNext((ct_BrowserDB->pTableInf+ValidTable)->numCols,false);
                         for (y=0;y<(ct_BrowserDB->pTableInf+ValidTable)->numCols;y++) // Loop through the Fields
                         { // BrowserDB::OnGetNext Formats the field Value into tablename
                             SetCellValue(z, y,((db_Br+i_Which)->cl_BrowserDB+y)->tableName);
                         }
+#if wxUSE_STATUSBAR
                         if (z % 50 == 0)
                         {
                             Temp0.Printf(_("-I-> DBGrid::OnTableView(%s) - Record %6d (from %d) has been read."),Table.c_str(),z,(db_Br+i_Which)->i_Records);
                             pDoc->p_MainFrame->SetStatusText(Temp0, 0);
                         }
+#endif // wxUSE_STATUSBAR
                     }  // for (z=0;z<(db_Br+i_Which)->i_Records;z++)
                     Temp0.Printf(_("-I-> DBGrid::OnTableView(%s) - %6d Records have been read. - Time needed : %ld ms"),Table.c_str(),z,sw.Time());
                     wxLogMessage(Temp0);
+#if wxUSE_STATUSBAR
                     pDoc->p_MainFrame->SetStatusText(Temp0, 0);
+#endif // wxUSE_STATUSBAR
                     // The Grid has been filled, now leave
                     goto Weiter;
                 }   // if ((ct_BrowserDB->pTableInf+x)->pColInf)
@@ -154,18 +158,18 @@ Weiter:
 }
 
 //----------------------------------------------------------------------------------------
-void DBGrid::OnModusEdit(wxCommandEvent& event)
+void DBGrid::OnModusEdit(wxCommandEvent& WXUNUSED(event))
 {
-    b_EditModus = TRUE;             // Needed by PopupMenu
+    b_EditModus = true;             // Needed by PopupMenu
     EnableEditing(b_EditModus);     // Activate in-place Editing
     UpdateDimensions();             // Redraw the Grid
     // wxLogMessage(_("-I-> DBGrid::OnModusEdit() - End"));
 }
 
 //----------------------------------------------------------------------------------------
-void DBGrid::OnModusBrowse(wxCommandEvent& event)
+void DBGrid::OnModusBrowse(wxCommandEvent& WXUNUSED(event))
 {
-    b_EditModus = FALSE;            // Needed by PopupMenu
+    b_EditModus = false;            // Needed by PopupMenu
     EnableEditing(b_EditModus);     // Deactivate in-place Editing
     UpdateDimensions();             // Redraw the Grid
     // wxLogMessage(_("-I-> DBGrid::OnModusBrowse() - End"));
@@ -188,10 +192,10 @@ void DBGrid::OnEditorHidden( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnSelectCell( wxGridEvent& ev )
 {
-    logBuf = "";
-    logBuf << "Selected cell at row " << ev.GetRow()
-        << " col " << ev.GetCol();
-    wxLogMessage( "%s", logBuf.c_str() );
+    logBuf = wxEmptyString;
+    logBuf << _T("Selected cell at row ") << ev.GetRow()
+        << _T(" col ") << ev.GetCol();
+    wxLogMessage( _T("%s"), logBuf.c_str() );
     // you must call Skip() if you want the default processing
     // to occur in wxGrid
     ev.Skip();
@@ -206,24 +210,24 @@ void DBGrid::OnMouseMove(wxMouseEvent &event)
 //----------------------------------------------------------------------------------------
 void DBGrid::OnLabelLeftClick( wxGridEvent& ev )
 {
-    logBuf = "DBGrid::OnLabelLeftClick : ";
+    logBuf = _T("DBGrid::OnLabelLeftClick : ");
     if ( ev.GetRow() != -1 )
     {
-        logBuf << "row label " << ev.GetRow();
+        logBuf << _T("row label ") << ev.GetRow();
     }
     else if ( ev.GetCol() != -1 )
     {
-        logBuf << "col label " << ev.GetCol();
+        logBuf << _T("col label ") << ev.GetCol();
     }
     else
     {
-        logBuf << "corner label";
+        logBuf << _T("corner label");
     }
     if ( ev.ShiftDown() )
-        logBuf << " (shift down)";
+        logBuf << _T(" (shift down)");
 
     // wxLogMessage( "%s", logBuf.c_str() );
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     ev.Skip();
 }
@@ -237,24 +241,24 @@ void DBGrid::OnLabelRightClick( wxGridEvent& ev )
     else
         PopupMenu(popupMenu1,MousePos.x,MousePos.y);
     //-------------------
-    logBuf = "DBGrid::OnLabelRightClick : ";
+    logBuf = _T("DBGrid::OnLabelRightClick : ");
     if ( ev.GetRow() != -1 )
     {
-        logBuf << "row label " << ev.GetRow();
+        logBuf << _T("row label ") << ev.GetRow();
     }
     else if ( ev.GetCol() != -1 )
     {
-        logBuf << "col label " << ev.GetCol();
+        logBuf << _T("col label ") << ev.GetCol();
     }
     else
     {
-        logBuf << "corner label";
+        logBuf << _T("corner label");
     }
     if ( ev.ShiftDown() )
-        logBuf << " (shift down)";
+        logBuf << _T(" (shift down)");
 
     // wxLogMessage( "%s", logBuf.c_str() );
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     ev.Skip();
 }
@@ -262,24 +266,24 @@ void DBGrid::OnLabelRightClick( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnLabelLeftDClick( wxGridEvent& ev )
 {
-    logBuf = "DBGrid::OnLabelLeftDClick : ";
+    logBuf = _T("DBGrid::OnLabelLeftDClick : ");
     if ( ev.GetRow() != -1 )
     {
-        logBuf << "row label " << ev.GetRow();
+        logBuf << _T("row label ") << ev.GetRow();
     }
     else if ( ev.GetCol() != -1 )
     {
-        logBuf << "col label " << ev.GetCol();
+        logBuf << _T("col label ") << ev.GetCol();
     }
     else
     {
-        logBuf << "corner label";
+        logBuf << _T("corner label");
     }
     if ( ev.ShiftDown() )
-        logBuf << " (shift down)";
+        logBuf << _T(" (shift down)");
 
-    // wxLogMessage( "%s", logBuf.c_str() );
-    logBuf += "\n";
+    // wxLogMessage( _T("%s"), logBuf.c_str() );
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     ev.Skip();
 }
@@ -287,23 +291,23 @@ void DBGrid::OnLabelLeftDClick( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnLabelRightDClick( wxGridEvent& ev )
 {
-    logBuf = "DBGrid::OnLabelRightDClick : ";
+    logBuf = _T("DBGrid::OnLabelRightDClick : ");
     if ( ev.GetRow() != -1 )
     {
-        logBuf << "row label " << ev.GetRow();
+        logBuf << _T("row label ") << ev.GetRow();
     }
     else if ( ev.GetCol() != -1 )
     {
-        logBuf << "col label " << ev.GetCol();
+        logBuf << _T("col label ") << ev.GetCol();
     }
     else
     {
-        logBuf << "corner label";
+        logBuf << _T("corner label");
     }
     if ( ev.ShiftDown() )
-        logBuf << " (shift down)";
+        logBuf << _T(" (shift down)");
     // wxLogMessage( "%s", logBuf.c_str() );
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     ev.Skip();
 }
@@ -311,12 +315,12 @@ void DBGrid::OnLabelRightDClick( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnCellLeftClick( wxGridEvent& ev )
 {
-    logBuf = "DBGrid::OnCellLeftClick : ";
-    logBuf << "Cell at row " << ev.GetRow()
-        << " col " << ev.GetCol();
+    logBuf = _T("DBGrid::OnCellLeftClick : ");
+    logBuf << _T("Cell at row ") << ev.GetRow()
+        << _T(" col ") << ev.GetCol();
     // wxLogMessage( "%s", logBuf.c_str() );
     // wxMessageBox(logBuf);
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     // you must call event skip if you want default grid processing
     // (cell highlighting etc.)
@@ -327,12 +331,12 @@ void DBGrid::OnCellLeftClick( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnCellRightClick( wxGridEvent& ev )
 {
-    logBuf = "DBGrid::OnCellRightClick : ";
-    logBuf << "Cell at row " << ev.GetRow()
-        << " col " << ev.GetCol();
+    logBuf = _T("DBGrid::OnCellRightClick : ");
+    logBuf << _T("Cell at row ") << ev.GetRow()
+        << _T(" col ") << ev.GetCol();
     // wxLogMessage( "%s", logBuf.c_str() );
     // wxMessageBox(logBuf);
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     // you must call event skip if you want default grid processing
     // (cell highlighting etc.)
@@ -343,12 +347,12 @@ void DBGrid::OnCellRightClick( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnCellLeftDClick( wxGridEvent& ev )
 {
-    logBuf = "DBGrid::OnCellLeftDClick : ";
-    logBuf << "Cell at row " << ev.GetRow()
-        << " col " << ev.GetCol();
+    logBuf = _T("DBGrid::OnCellLeftDClick : ");
+    logBuf << _T("Cell at row ") << ev.GetRow()
+        << _T(" col ") << ev.GetCol();
     // wxLogMessage( "%s", logBuf.c_str() );
     // wxMessageBox(logBuf);
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     // you must call event skip if you want default grid processing
     // (cell highlighting etc.)
@@ -359,12 +363,12 @@ void DBGrid::OnCellLeftDClick( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnCellRightDClick( wxGridEvent& ev )
 {
-    logBuf = "DBGrid::OnCellRightDClick : ";
-    logBuf << "Cell at row " << ev.GetRow()
-        << " col " << ev.GetCol();
+    logBuf = _T("DBGrid::OnCellRightDClick : ");
+    logBuf << _T("Cell at row ") << ev.GetRow()
+        << _T(" col ") << ev.GetCol();
     // wxLogMessage( "%s", logBuf.c_str() );
     // wxMessageBox(logBuf);
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     // you must call event skip if you want default grid processing
     // (cell highlighting etc.)
@@ -375,12 +379,12 @@ void DBGrid::OnCellRightDClick( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnCellChange( wxGridEvent& ev )
 {
-    logBuf = "DBGrid::OnCellChange : ";
-    logBuf << "Cell at row " << ev.GetRow()
-        << " col " << ev.GetCol();
+    logBuf = _T("DBGrid::OnCellChange : ");
+    logBuf << _T("Cell at row ") << ev.GetRow()
+        << _T(" col ") << ev.GetCol();
     // wxLogMessage( "%s", logBuf.c_str() );
     // wxMessageBox(logBuf);
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     // you must call event skip if you want default grid processing
     // (cell highlighting etc.)
@@ -391,10 +395,10 @@ void DBGrid::OnCellChange( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnRowSize( wxGridSizeEvent& ev )
 {
-    logBuf = "DBGrid::OnRowSize : ";
-    logBuf << "Resized row " << ev.GetRowOrCol();
+    logBuf = _T("DBGrid::OnRowSize : ");
+    logBuf << _T("Resized row ") << ev.GetRowOrCol();
     // wxLogMessage( "%s", logBuf.c_str() );
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     ev.Skip();
 }
@@ -402,10 +406,10 @@ void DBGrid::OnRowSize( wxGridSizeEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnColSize( wxGridSizeEvent& ev )
 {
-    logBuf = "DBGrid::OnColSize : ";
-    logBuf << "Resized col " << ev.GetRowOrCol();
+    logBuf = _T("DBGrid::OnColSize : ");
+    logBuf << _T("Resized col ") << ev.GetRowOrCol();
     // wxLogMessage( "%s", logBuf.c_str() );
-    logBuf += "\n";
+    logBuf += _T("\n");
     wxLogMessage(logBuf.c_str());
     ev.Skip();
 }
@@ -413,12 +417,12 @@ void DBGrid::OnColSize( wxGridSizeEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnRangeSelected( wxGridRangeSelectEvent& ev )
 {
-    logBuf = "DBGrid::OnRangeSelected : ";
-    logBuf  << "Selected cells from row " << ev.GetTopRow()
-        << " col " << ev.GetLeftCol()
-        << " to row " << ev.GetBottomRow()
-        << " col " << ev.GetRightCol();
-    logBuf += "\n";
+    logBuf = _T("DBGrid::OnRangeSelected : ");
+    logBuf  << _T("Selected cells from row ") << ev.GetTopRow()
+        << _T(" col ") << ev.GetLeftCol()
+        << _T(" to row ") << ev.GetBottomRow()
+        << _T(" col ") << ev.GetRightCol();
+    logBuf += _T("\n");
     // wxLogMessage( "%s", logBuf.c_str() );
     wxLogMessage(logBuf.c_str());
     ev.Skip();