]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
moved DLL import/export declarations from wx/defs.h to (new) wx/dlimpexp.h for GSocke...
[wxWidgets.git] / src / generic / grid.cpp
index 03bae1969d81f6db8f7eb5af7119d34fddf8f955..d23afe3b2bb0afed82c0a588a265ceb46e2618f2 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);
 
 
@@ -573,8 +573,7 @@ void wxGridCellTextEditor::Create(wxWindow* parent,
     m_control = new wxTextCtrl(parent, id, wxEmptyString,
                                wxDefaultPosition, wxDefaultSize
 #if defined(__WXMSW__)
     m_control = new wxTextCtrl(parent, id, wxEmptyString,
                                wxDefaultPosition, wxDefaultSize
 #if defined(__WXMSW__)
-                               , wxTE_PROCESS_TAB | wxTE_MULTILINE |
-                                 wxTE_NO_VSCROLL | wxTE_AUTO_SCROLL
+                               , wxTE_PROCESS_TAB | wxTE_AUTO_SCROLL
 #endif
                               );
 
 #endif
                               );
 
@@ -1365,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)
@@ -3138,23 +3142,25 @@ int wxGridStringTable::GetNumberCols()
 
 wxString wxGridStringTable::GetValue( int row, int col )
 {
 
 wxString wxGridStringTable::GetValue( int row, int col )
 {
-    wxASSERT_MSG( (row < GetNumberRows()) && (col < GetNumberCols()),
-                  _T("invalid row or column index in wxGridStringTable") );
+    wxCHECK_MSG( (row < GetNumberRows()) && (col < GetNumberCols()),
+                 wxEmptyString,
+                 _T("invalid row or column index in wxGridStringTable") );
 
     return m_data[row][col];
 }
 
 void wxGridStringTable::SetValue( int row, int col, const wxString& value )
 {
 
     return m_data[row][col];
 }
 
 void wxGridStringTable::SetValue( int row, int col, const wxString& value )
 {
-    wxASSERT_MSG( (row < GetNumberRows()) && (col < GetNumberCols()),
-                  _T("invalid row or column index in wxGridStringTable") );
+    wxCHECK_RET( (row < GetNumberRows()) && (col < GetNumberCols()),
+                 _T("invalid row or column index in wxGridStringTable") );
 
     m_data[row][col] = value;
 }
 
 bool wxGridStringTable::IsEmptyCell( int row, int col )
 {
 
     m_data[row][col] = value;
 }
 
 bool wxGridStringTable::IsEmptyCell( int row, int col )
 {
-    wxASSERT_MSG( (row < GetNumberRows()) && (col < GetNumberCols()),
+    wxCHECK_MSG( (row < GetNumberRows()) && (col < GetNumberCols()),
+                 true,
                   _T("invalid row or column index in wxGridStringTable") );
 
     return (m_data[row][col] == wxEmptyString);
                   _T("invalid row or column index in wxGridStringTable") );
 
     return (m_data[row][col] == wxEmptyString);
@@ -3758,7 +3764,57 @@ static int CoordToRowOrCol(int coord, int defaultDist, int minDist,
                                           m_rowBottoms, m_numRows, TRUE)
 /////////////////////////////////////////////////////////////////////
 
                                           m_rowBottoms, m_numRows, TRUE)
 /////////////////////////////////////////////////////////////////////
 
+#if wxUSE_EXTENDED_RTTI
+WX_DEFINE_FLAGS( wxGridStyle )
+
+wxBEGIN_FLAGS( wxGridStyle )
+    // new style border flags, we put them first to
+    // use them for streaming out
+    wxFLAGS_MEMBER(wxBORDER_SIMPLE)
+    wxFLAGS_MEMBER(wxBORDER_SUNKEN)
+    wxFLAGS_MEMBER(wxBORDER_DOUBLE)
+    wxFLAGS_MEMBER(wxBORDER_RAISED)
+    wxFLAGS_MEMBER(wxBORDER_STATIC)
+    wxFLAGS_MEMBER(wxBORDER_NONE)
+    
+    // old style border flags
+    wxFLAGS_MEMBER(wxSIMPLE_BORDER)
+    wxFLAGS_MEMBER(wxSUNKEN_BORDER)
+    wxFLAGS_MEMBER(wxDOUBLE_BORDER)
+    wxFLAGS_MEMBER(wxRAISED_BORDER)
+    wxFLAGS_MEMBER(wxSTATIC_BORDER)
+    wxFLAGS_MEMBER(wxBORDER)
+
+    // standard window styles
+    wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
+    wxFLAGS_MEMBER(wxCLIP_CHILDREN)
+    wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
+    wxFLAGS_MEMBER(wxWANTS_CHARS)
+    wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
+    wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
+    wxFLAGS_MEMBER(wxVSCROLL)
+    wxFLAGS_MEMBER(wxHSCROLL)
+
+wxEND_FLAGS( wxGridStyle )
+
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxGrid, wxScrolledWindow,"wx/grid.h")
+
+wxBEGIN_PROPERTIES_TABLE(wxGrid)
+    wxHIDE_PROPERTY( Children )
+    wxPROPERTY_FLAGS( WindowStyle , wxGridStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+wxEND_PROPERTIES_TABLE()
+
+wxBEGIN_HANDLERS_TABLE(wxGrid)
+wxEND_HANDLERS_TABLE()
+
+wxCONSTRUCTOR_5( wxGrid , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) 
+
+/*
+ TODO : Expose more information of a list's layout etc. via appropriate objects (à la NotebookPageInfo)
+*/
+#else
 IMPLEMENT_DYNAMIC_CLASS( wxGrid, wxScrolledWindow )
 IMPLEMENT_DYNAMIC_CLASS( wxGrid, wxScrolledWindow )
+#endif
 
 BEGIN_EVENT_TABLE( wxGrid, wxScrolledWindow )
     EVT_PAINT( wxGrid::OnPaint )
 
 BEGIN_EVENT_TABLE( wxGrid, wxScrolledWindow )
     EVT_PAINT( wxGrid::OnPaint )
@@ -3768,6 +3824,16 @@ BEGIN_EVENT_TABLE( wxGrid, wxScrolledWindow )
     EVT_ERASE_BACKGROUND( wxGrid::OnEraseBackground )
 END_EVENT_TABLE()
 
     EVT_ERASE_BACKGROUND( wxGrid::OnEraseBackground )
 END_EVENT_TABLE()
 
+wxGrid::wxGrid()
+{
+    // in order to make sure that a size event is not
+    // trigerred in a unfinished state
+    m_cornerLabelWin = NULL ;
+    m_rowLabelWin = NULL ;
+    m_colLabelWin = NULL ;
+    m_gridWin = NULL ;
+}
+
 wxGrid::wxGrid( wxWindow *parent,
                  wxWindowID id,
                  const wxPoint& pos,
 wxGrid::wxGrid( wxWindow *parent,
                  wxWindowID id,
                  const wxPoint& pos,
@@ -3781,6 +3847,23 @@ wxGrid::wxGrid( wxWindow *parent,
     Create();
 }
 
     Create();
 }
 
+bool wxGrid::Create(wxWindow *parent, wxWindowID id,
+                          const wxPoint& pos, const wxSize& size,
+                          long style, const wxString& name)
+{
+    if (!wxScrolledWindow::Create(parent, id, pos, size,
+                                  style | wxWANTS_CHARS , name))
+        return FALSE;
+
+    m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE) ;
+    m_rowMinHeights = wxLongToLongHashMap(GRID_HASH_SIZE) ;
+
+    Create() ;
+
+
+    return TRUE;
+}
+
 
 wxGrid::~wxGrid()
 {
 
 wxGrid::~wxGrid()
 {
@@ -3916,21 +3999,21 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
 {
     if ( m_created )
     {
 {
     if ( m_created )
     {
-        // stop all processing 
-        m_created = FALSE; 
+        // stop all processing
+        m_created = FALSE;
 
         if (m_ownTable)
         {
             wxGridTableBase *t=m_table;
             m_table=0;
 
         if (m_ownTable)
         {
             wxGridTableBase *t=m_table;
             m_table=0;
-            delete t; 
+            delete t;
         }
         }
-        delete m_selection; 
-        m_table=0; 
-        m_selection=0; 
-        m_numRows=0; 
-        m_numCols=0; 
+        delete m_selection;
+
+        m_table=0;
+        m_selection=0;
+        m_numRows=0;
+        m_numCols=0;
     }
     if (table)
     {
     }
     if (table)
     {
@@ -4190,6 +4273,11 @@ void wxGrid::CalcDimensions()
 
 void wxGrid::CalcWindowSizes()
 {
 
 void wxGrid::CalcWindowSizes()
 {
+    // escape if the window is has not been fully created yet
+
+    if ( m_cornerLabelWin == NULL )
+        return ;
+
     int cw, ch;
     GetClientSize( &cw, &ch );
 
     int cw, ch;
     GetClientSize( &cw, &ch );
 
@@ -9339,13 +9427,13 @@ void wxGrid::SetColSize( int col, int width )
     // should we check that it's bigger than GetColMinimalWidth(col) here?
     //                                                                 (VZ)
     // No, because it is reasonable to assume the library user know's
     // should we check that it's bigger than GetColMinimalWidth(col) here?
     //                                                                 (VZ)
     // No, because it is reasonable to assume the library user know's
-    // what he is doing. However whe should test against the weaker 
+    // what he is doing. However whe should test against the weaker
     // constariant of minimalAcceptableWidth, as this breaks rendering
     // constariant of minimalAcceptableWidth, as this breaks rendering
-    // 
+    //
     // This test then fixes sf.net bug #645734
     // This test then fixes sf.net bug #645734
-    
+
     if ( width < GetColMinimalAcceptableWidth()) { return; }
     if ( width < GetColMinimalAcceptableWidth()) { return; }
-    
+
     if ( m_colWidths.IsEmpty() )
     {
         // need to really create the array
     if ( m_colWidths.IsEmpty() )
     {
         // need to really create the array