]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/dbbrowse/dbgrid.cpp
Added DECLARE/IMLEMENT_CLASS for wxToolBarBase
[wxWidgets.git] / demos / dbbrowse / dbgrid.cpp
index 2834e102d31e2e5de54157dd5b209c407d3caa0a..f84b628f962f07612a7381586feaf5263d583d03 100644 (file)
 BEGIN_EVENT_TABLE(DBGrid, wxGrid)
  EVT_MOTION (DBGrid::OnMouseMove)
  // DBGrid
 BEGIN_EVENT_TABLE(DBGrid, wxGrid)
  EVT_MOTION (DBGrid::OnMouseMove)
  // DBGrid
- EVT_GRID_LABEL_LEFT_CLICK( DBGrid::OnLabelLeftClick )
- EVT_GRID_LABEL_RIGHT_CLICK( DBGrid::OnLabelRightClick )
- EVT_GRID_LABEL_LEFT_DCLICK( DBGrid::OnLabelLeftDClick )
- EVT_GRID_LABEL_RIGHT_DCLICK( DBGrid::OnLabelRightDClick )
+ // ------------
+ EVT_GRID_CELL_CHANGE( DBGrid::OnCellChange )
  EVT_GRID_CELL_LEFT_CLICK( DBGrid::OnCellLeftClick )
  EVT_GRID_CELL_LEFT_CLICK( DBGrid::OnCellLeftClick )
- EVT_GRID_CELL_RIGHT_CLICK( DBGrid::OnCellRightClick )
  EVT_GRID_CELL_LEFT_DCLICK( DBGrid::OnCellLeftDClick )
  EVT_GRID_CELL_LEFT_DCLICK( DBGrid::OnCellLeftDClick )
+ EVT_GRID_CELL_RIGHT_CLICK( DBGrid::OnCellRightClick )
  EVT_GRID_CELL_RIGHT_DCLICK( DBGrid::OnCellRightDClick )
  EVT_GRID_CELL_RIGHT_DCLICK( DBGrid::OnCellRightDClick )
- EVT_GRID_ROW_SIZE( DBGrid::OnRowSize )
  // EVT_GRID_COL_SIZE( DBGrid::OnColSize )
  // EVT_GRID_COL_SIZE( DBGrid::OnColSize )
+ // EVT_GRID_ROW_SIZE( DBGrid::OnRowSize )
+ EVT_GRID_EDITOR_SHOWN( DBGrid::OnEditorShown )
+ EVT_GRID_EDITOR_HIDDEN( DBGrid::OnEditorHidden )
+ EVT_GRID_LABEL_LEFT_CLICK( DBGrid::OnLabelLeftClick )
+ EVT_GRID_LABEL_LEFT_DCLICK( DBGrid::OnLabelLeftDClick )
+ EVT_GRID_LABEL_RIGHT_CLICK( DBGrid::OnLabelRightClick )
+ EVT_GRID_LABEL_RIGHT_DCLICK( DBGrid::OnLabelRightDClick )
  EVT_GRID_RANGE_SELECT( DBGrid::OnRangeSelected )
  EVT_GRID_RANGE_SELECT( DBGrid::OnRangeSelected )
- EVT_GRID_CELL_CHANGE( DBGrid::OnCellChange )
+ EVT_GRID_ROW_SIZE( DBGrid::OnRowSize )
+ EVT_GRID_SELECT_CELL( DBGrid::OnSelectCell )
  EVT_MENU(GRID_EDIT,DBGrid::OnModusEdit)
  EVT_MENU(GRID_BROWSE,DBGrid::OnModusBrowse)
 END_EVENT_TABLE()
  EVT_MENU(GRID_EDIT,DBGrid::OnModusEdit)
  EVT_MENU(GRID_BROWSE,DBGrid::OnModusBrowse)
 END_EVENT_TABLE()
@@ -59,7 +64,7 @@ END_EVENT_TABLE()
 DBGrid::DBGrid(wxWindow *parent, const wxWindowID id,const wxPoint& pos,const wxSize& size, long style):
   wxGrid(parent, id, pos, size, style)
 {
 DBGrid::DBGrid(wxWindow *parent, const wxWindowID id,const wxPoint& pos,const wxSize& size, long style):
   wxGrid(parent, id, pos, size, style)
 {
- b_EditModus = TRUE;
+ b_EditModus = FALSE;
  //---------------------------------------------------------------------------------------
  popupMenu1 = new wxMenu("");
  popupMenu1->Append(GRID_EDIT, _("Edit Modus"));
  //---------------------------------------------------------------------------------------
  popupMenu1 = new wxMenu("");
  popupMenu1->Append(GRID_EDIT, _("Edit Modus"));
@@ -69,18 +74,18 @@ DBGrid::DBGrid(wxWindow *parent, const wxWindowID id,const wxPoint& pos,const wx
 //----------------------------------------------------------------------------------------
 DBGrid::~DBGrid()
 {
 //----------------------------------------------------------------------------------------
 DBGrid::~DBGrid()
 {
+ delete popupMenu1;
+ delete popupMenu2;
 }
 //----------------------------------------------------------------------------------------
 int  DBGrid::OnTableView(wxString Table)
 {
 }
 //----------------------------------------------------------------------------------------
 int  DBGrid::OnTableView(wxString Table)
 {
+ wxStopWatch sw;
  //---------------------------------------------------------------------------------------
  int  i=0,x,y,z, ValidTable=0;
  wxString Temp0;
  wxBeginBusyCursor();
  //---------------------------------------------------------------------------------------
  int  i=0,x,y,z, ValidTable=0;
  wxString Temp0;
  wxBeginBusyCursor();
- SetFont(* pDoc->ft_Doc);
- // wxFont *ft_Temp;
- // ft_Temp = new wxFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT));
- // SetFont(*ft_Temp);
+ SetDefaultCellFont(* pDoc->ft_Doc);
  //---------------------------------------------------------------------------------------
  ct_BrowserDB = (db_Br+i_Which)->ct_BrowserDB;                       // Get the DSN Pointer
  //---------------------------------------------------------------------------------------
  //---------------------------------------------------------------------------------------
  ct_BrowserDB = (db_Br+i_Which)->ct_BrowserDB;                       // Get the DSN Pointer
  //---------------------------------------------------------------------------------------
@@ -100,7 +105,7 @@ int  DBGrid::OnTableView(wxString Table)
      (db_Br+i_Which)->i_Which = ValidTable;                          // Still used ???? mj10777
      if (i == 0)     // If the Table is empty, then show one empty row
       i++;
      (db_Br+i_Which)->i_Which = ValidTable;                          // Still used ???? mj10777
      if (i == 0)     // If the Table is empty, then show one empty row
       i++;
-     // wxLogMessage(_("\n-I-> DBGrid::OnTableView():: Vor CreateGrid"));
+     // wxLogMessage(_("\n-I-> DBGrid::OnTableView() : Vor CreateGrid"));
      CreateGrid(i,(ct_BrowserDB->pTableInf+x)->numCols);             // Records , Columns
      for (y=0;y<(ct_BrowserDB->pTableInf+x)->numCols;y++)            // Loop through the Fields
      {  // The Field / Column name is used here as Row Titel
      CreateGrid(i,(ct_BrowserDB->pTableInf+x)->numCols);             // Records , Columns
      for (y=0;y<(ct_BrowserDB->pTableInf+x)->numCols;y++)            // Loop through the Fields
      {  // The Field / Column name is used here as Row Titel
@@ -119,44 +124,68 @@ int  DBGrid::OnTableView(wxString Table)
       }
       if (z % 50 == 0)
       {
       }
       if (z % 50 == 0)
       {
-       Temp0.Printf(_("-I-> DBGrid::OnTableView(%s) - Record %6d has been read."),Table.c_str(),z);
+       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);
       }
      }  // for (z=0;z<(db_Br+i_Which)->i_Records;z++)
        pDoc->p_MainFrame->SetStatusText(Temp0, 0);
       }
      }  // for (z=0;z<(db_Br+i_Which)->i_Records;z++)
-     Temp0.Printf(_("-I-> DBGrid::OnTableView(%s) - %6d Records have been read."),Table.c_str(),z);
+     Temp0.Printf(_("-I-> DBGrid::OnTableView(%s) - %6d Records have been read. - Time needed : %ld ms"),Table.c_str(),z,sw.Time());
+     wxLogMessage(Temp0);
      pDoc->p_MainFrame->SetStatusText(Temp0, 0);
      // The Grid has been filled, now leave
      goto Weiter;
     }   // if ((ct_BrowserDB->pTableInf+x)->pColInf)
     else
      pDoc->p_MainFrame->SetStatusText(Temp0, 0);
      // The Grid has been filled, now leave
      goto Weiter;
     }   // if ((ct_BrowserDB->pTableInf+x)->pColInf)
     else
-     wxLogMessage(_("\n-E-> DBGrid::OnTableView():: Invalid Column Pointer : Failed"));
+     wxLogMessage(_("\n-E-> DBGrid::OnTableView() : Invalid Column Pointer : Failed"));
    }    // if ((ct_BrowserDB->pTableInf+x)->tableType == "TABLE")
   }     // for (x=0;x<ct_BrowserDB->numTables;x++)
  }      // if (ct_BrowserDB)
  else
    }    // if ((ct_BrowserDB->pTableInf+x)->tableType == "TABLE")
   }     // for (x=0;x<ct_BrowserDB->numTables;x++)
  }      // if (ct_BrowserDB)
  else
-  wxLogMessage(_("\n-E-> DBGrid::OnTableView():: Invalid DSN Pointer : Failed"));
+  wxLogMessage(_("\n-E-> DBGrid::OnTableView() : Invalid DSN Pointer : Failed"));
  //---------------------------------------------------------------------------------------
  Weiter:
  //---------------------------------------------------------------------------------------
  Weiter:
- SetEditInPlace(b_EditModus);   // Activate in-place Editing (FALSE)
+ EnableEditing(b_EditModus);     // Deactivate in-place Editing
  wxEndBusyCursor();
  //---------------------------------------------------------------------------------------
  wxLogMessage(_("-I-> DBGrid::OnTableView() - End"));
  return 0;
 }
 //----------------------------------------------------------------------------------------
  wxEndBusyCursor();
  //---------------------------------------------------------------------------------------
  wxLogMessage(_("-I-> DBGrid::OnTableView() - End"));
  return 0;
 }
 //----------------------------------------------------------------------------------------
-void DBGrid::OnModusEdit(wxMenu& menu, wxCommandEvent& event)
+void DBGrid::OnModusEdit(wxCommandEvent& event)
 {
  b_EditModus = TRUE;             // Needed by PopupMenu
 {
  b_EditModus = TRUE;             // Needed by PopupMenu
- SetEditable(FALSE);             // Do not Edit with Text Edit Control
- SetEditInPlace(b_EditModus);    // Deactivate in-place Editing
+ EnableEditing(b_EditModus);     // Activate in-place Editing
  UpdateDimensions();             // Redraw the Grid
  UpdateDimensions();             // Redraw the Grid
+ // wxLogMessage(_("-I-> DBGrid::OnModusEdit() - End"));
 }
 //----------------------------------------------------------------------------------------
 }
 //----------------------------------------------------------------------------------------
-void DBGrid::OnModusBrowse(wxMenu& menu, wxCommandEvent& event)
+void DBGrid::OnModusBrowse(wxCommandEvent& event)
 {
  b_EditModus = FALSE;            // Needed by PopupMenu
 {
  b_EditModus = FALSE;            // Needed by PopupMenu
SetEditInPlace(b_EditModus);    // Deactivate in-place Editing
EnableEditing(b_EditModus);     // Deactivate in-place Editing
  UpdateDimensions();             // Redraw the Grid
  UpdateDimensions();             // Redraw the Grid
+ // wxLogMessage(_("-I-> DBGrid::OnModusBrowse() - End"));
+}
+//----------------------------------------------------------------------------------------
+void DBGrid::OnEditorShown( wxGridEvent& ev )
+{
+ // wxLogMessage(_("-I-> DBGrid::OnEditorShown() - End"));
+ ev.Skip();
+}
+//----------------------------------------------------------------------------------------
+void DBGrid::OnEditorHidden( wxGridEvent& ev )
+{
+ // wxLogMessage(_("-I-> DBGrid::OnEditorHidden() - End"));
+ ev.Skip();
+}
+void DBGrid::OnSelectCell( wxGridEvent& ev )
+{
+ logBuf = "";
+ logBuf << "Selected cell at row " << ev.GetRow()
+        << " col " << ev.GetCol();
+ wxLogMessage( "%s", logBuf.c_str() );
+ // you must call Skip() if you want the default processing
+ // to occur in wxGrid
+ ev.Skip();
 }
 //----------------------------------------------------------------------------------------
 void DBGrid::OnMouseMove(wxMouseEvent &event)
 }
 //----------------------------------------------------------------------------------------
 void DBGrid::OnMouseMove(wxMouseEvent &event)
@@ -189,7 +218,7 @@ void DBGrid::OnLabelLeftClick( wxGridEvent& ev )
 //----------------------------------------------------------------------------------------
 void DBGrid::OnLabelRightClick( wxGridEvent& ev )
 {
 //----------------------------------------------------------------------------------------
 void DBGrid::OnLabelRightClick( wxGridEvent& ev )
 {
- //-------------------
+ //-------------------------------------------------------
  if (b_EditModus)
   PopupMenu(popupMenu2,MousePos.x,MousePos.y);
  else
  if (b_EditModus)
   PopupMenu(popupMenu2,MousePos.x,MousePos.y);
  else