]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
reversed some parts of wxGetKeyState for linkage reasons...
[wxWidgets.git] / src / generic / grid.cpp
index cfea196c38546f0cdf0f6e2d6a104e0309139b6e..140e6333cd0782541f53fc1ca1a23b2f9ef00d0b 100644 (file)
@@ -69,7 +69,7 @@
 // array classes
 // ----------------------------------------------------------------------------
 
 // array classes
 // ----------------------------------------------------------------------------
 
-WX_DEFINE_ARRAY_WITH_DECL_NO_PTR(wxGridCellAttr *, wxArrayAttrs,
+WX_DEFINE_ARRAY_WITH_DECL_PTR(wxGridCellAttr *, wxArrayAttrs,
                                  class WXDLLIMPEXP_ADV);
 
 struct wxGridCellWithAttr
                                  class WXDLLIMPEXP_ADV);
 
 struct wxGridCellWithAttr
@@ -334,7 +334,7 @@ struct wxGridDataTypeInfo
 };
 
 
 };
 
 
-WX_DEFINE_ARRAY_WITH_DECL_NO_PTR(wxGridDataTypeInfo*, wxGridDataTypeInfoArray,
+WX_DEFINE_ARRAY_WITH_DECL_PTR(wxGridDataTypeInfo*, wxGridDataTypeInfoArray,
                                  class WXDLLIMPEXP_ADV);
 
 
                                  class WXDLLIMPEXP_ADV);
 
 
@@ -1364,6 +1364,11 @@ wxString wxGridCellBoolEditor::GetValue() const
 // wxGridCellChoiceEditor
 // ----------------------------------------------------------------------------
 
 // wxGridCellChoiceEditor
 // ----------------------------------------------------------------------------
 
+wxGridCellChoiceEditor::wxGridCellChoiceEditor(const wxArrayString& choices,
+                                               bool allowOthers)
+    : m_choices(choices),
+      m_allowOthers(allowOthers) { }
+
 wxGridCellChoiceEditor::wxGridCellChoiceEditor(size_t count,
                                                const wxString choices[],
                                                bool allowOthers)
 wxGridCellChoiceEditor::wxGridCellChoiceEditor(size_t count,
                                                const wxString choices[],
                                                bool allowOthers)
@@ -1956,10 +1961,9 @@ wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid,
     if ( !ms_sizeCheckMark.x )
     {
         // get checkbox size
     if ( !ms_sizeCheckMark.x )
     {
         // get checkbox size
-        wxCoord checkSize = 0;
         wxCheckBox *checkbox = new wxCheckBox(&grid, -1, wxEmptyString);
         wxSize size = checkbox->GetBestSize();
         wxCheckBox *checkbox = new wxCheckBox(&grid, -1, wxEmptyString);
         wxSize size = checkbox->GetBestSize();
-        checkSize = size.y + 2*wxGRID_CHECKMARK_MARGIN;
+        wxCoord checkSize = size.y + 2*wxGRID_CHECKMARK_MARGIN;
 
         // FIXME wxGTK::wxCheckBox::GetBestSize() gives "wrong" result
 #if defined(__WXGTK__) || defined(__WXMOTIF__)
 
         // FIXME wxGTK::wxCheckBox::GetBestSize() gives "wrong" result
 #if defined(__WXGTK__) || defined(__WXMOTIF__)
@@ -2579,13 +2583,9 @@ wxGridCellAttr *wxGridCellAttrProvider::GetAttr(int row, int col,
                 {
                     //Basicaly implement old version.
                     //Also check merge cache, so we don't have to re-merge every time..
                 {
                     //Basicaly implement old version.
                     //Also check merge cache, so we don't have to re-merge every time..
-                    wxGridCellAttr *attrcell = (wxGridCellAttr *)NULL,
-                                   *attrrow = (wxGridCellAttr *)NULL,
-                                   *attrcol = (wxGridCellAttr *)NULL;
-
-                    attrcell = m_data->m_cellAttrs.GetAttr(row, col);
-                    attrcol = m_data->m_colAttrs.GetAttr(col);
-                    attrrow = m_data->m_rowAttrs.GetAttr(row);
+                    wxGridCellAttr *attrcell = m_data->m_cellAttrs.GetAttr(row, col);
+                    wxGridCellAttr *attrrow = m_data->m_rowAttrs.GetAttr(row);
+                    wxGridCellAttr *attrcol = m_data->m_colAttrs.GetAttr(col);
 
                     if((attrcell != attrrow) && (attrrow !=attrcol) && (attrcell != attrcol)){
                         // Two or move are non NULL
 
                     if((attrcell != attrrow) && (attrrow !=attrcol) && (attrcell != attrcol)){
                         // Two or move are non NULL
@@ -3778,14 +3778,14 @@ wxBEGIN_FLAGS( wxGridStyle )
     wxFLAGS_MEMBER(wxDOUBLE_BORDER)
     wxFLAGS_MEMBER(wxRAISED_BORDER)
     wxFLAGS_MEMBER(wxSTATIC_BORDER)
     wxFLAGS_MEMBER(wxDOUBLE_BORDER)
     wxFLAGS_MEMBER(wxRAISED_BORDER)
     wxFLAGS_MEMBER(wxSTATIC_BORDER)
-    wxFLAGS_MEMBER(wxNO_BORDER)
+    wxFLAGS_MEMBER(wxBORDER)
 
     // standard window styles
     wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
     wxFLAGS_MEMBER(wxCLIP_CHILDREN)
     wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
     wxFLAGS_MEMBER(wxWANTS_CHARS)
 
     // standard window styles
     wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
     wxFLAGS_MEMBER(wxCLIP_CHILDREN)
     wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
     wxFLAGS_MEMBER(wxWANTS_CHARS)
-    wxFLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE)
+    wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
     wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
     wxFLAGS_MEMBER(wxVSCROLL)
     wxFLAGS_MEMBER(wxHSCROLL)
     wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
     wxFLAGS_MEMBER(wxVSCROLL)
     wxFLAGS_MEMBER(wxHSCROLL)
@@ -5997,7 +5997,7 @@ int wxGrid::SendEvent( const wxEventType type,
                         wxMouseEvent& mouseEv )
 {
    bool claimed;
                         wxMouseEvent& mouseEv )
 {
    bool claimed;
-   bool vetoed= FALSE;
+   bool vetoed;
 
    if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
    {
 
    if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
    {
@@ -6064,7 +6064,7 @@ int wxGrid::SendEvent( const wxEventType type,
                         int row, int col )
 {
    bool claimed;
                         int row, int col )
 {
    bool claimed;
-   bool vetoed= FALSE;
+   bool vetoed;
 
     if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
     {
 
     if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
     {
@@ -7478,7 +7478,9 @@ bool wxGrid::IsCurrentCellReadOnly() const
 
 bool wxGrid::CanEnableCellControl() const
 {
 
 bool wxGrid::CanEnableCellControl() const
 {
-    return m_editable && !IsCurrentCellReadOnly();
+    return m_editable && (m_currentCellCoords != wxGridNoCellCoords) &&
+        !IsCurrentCellReadOnly();
+        
 }
 
 bool wxGrid::IsCellEditControlEnabled() const
 }
 
 bool wxGrid::IsCellEditControlEnabled() const
@@ -7741,7 +7743,10 @@ static int CoordToRowOrCol(int coord, int defaultDist, int minDist,
         if ( coord >= BorderArray[i_max])
         {
             i_min = i_max;
         if ( coord >= BorderArray[i_max])
         {
             i_min = i_max;
-            i_max = coord / minDist;
+            if (minDist)
+                i_max = coord / minDist;
+            else
+                i_max =  BorderArray.GetCount() - 1;
         }
         if ( i_max >= BorderArray.GetCount())
             i_max = BorderArray.GetCount() - 1;
         }
         if ( i_max >= BorderArray.GetCount())
             i_max = BorderArray.GetCount() - 1;
@@ -9087,9 +9092,7 @@ void wxGrid::SetColFormatFloat(int col, int width, int precision)
 
 void wxGrid::SetColFormatCustom(int col, const wxString& typeName)
 {
 
 void wxGrid::SetColFormatCustom(int col, const wxString& typeName)
 {
-    wxGridCellAttr *attr = (wxGridCellAttr *)NULL;
-
-    attr = m_table->GetAttr(-1, col, wxGridCellAttr::Col );
+    wxGridCellAttr *attr = m_table->GetAttr(-1, col, wxGridCellAttr::Col );
     if(!attr)
         attr = new wxGridCellAttr;
     wxGridCellRenderer *renderer = GetDefaultRendererForType(typeName);
     if(!attr)
         attr = new wxGridCellAttr;
     wxGridCellRenderer *renderer = GetDefaultRendererForType(typeName);
@@ -9488,14 +9491,18 @@ int wxGrid::GetRowMinimalHeight(int row) const
 
 void wxGrid::SetColMinimalAcceptableWidth( int width )
 {
 
 void wxGrid::SetColMinimalAcceptableWidth( int width )
 {
-    if ( width<1 )
+    // We do allow a width of 0 since this gives us
+    // an easy way to temporarily hidding columns.
+    if ( width<0 )
         return;
     m_minAcceptableColWidth = width;
 }
 
 void wxGrid::SetRowMinimalAcceptableHeight( int height )
 {
         return;
     m_minAcceptableColWidth = width;
 }
 
 void wxGrid::SetRowMinimalAcceptableHeight( int height )
 {
-    if ( height<1 )
+    // We do allow a height of 0 since this gives us
+    // an easy way to temporarily hidding rows.
+    if ( height<0 )
         return;
     m_minAcceptableRowHeight = height;
 };
         return;
     m_minAcceptableRowHeight = height;
 };