示例#1
0
    void OnInsertColumn(unsigned col, unsigned numColumns)
    {
        wxASSERT_MSG( col, "Shouldn't be called for the first column" );

        // Nothing to do if we don't have any text.
        if ( !m_columnsTexts )
            return;

        wxScopedArray<wxString> oldTexts(m_columnsTexts);
        m_columnsTexts = new wxString[numColumns - 1];

        // In the loop below n is the index in the new column texts array and m
        // is the index in the old one.
        for ( unsigned n = 1, m = 1; n < numColumns - 1; n++, m++ )
        {
            if ( n == col )
            {
                // Leave the new array text initially empty and just adjust the
                // index (to compensate for "m++" done by the loop anyhow).
                m--;
            }
            else // Not the newly inserted column.
            {
                // Copy the old text value.
                m_columnsTexts[n - 1] = oldTexts[m - 1];
            }
        }
    }
示例#2
0
    void OnDeleteColumn(unsigned col, unsigned numColumns)
    {
        wxASSERT_MSG( col, "Shouldn't be called for the first column" );

        if ( !m_columnsTexts )
            return;

        wxScopedArray<wxString> oldTexts(m_columnsTexts);
        m_columnsTexts = new wxString[numColumns - 2];

        // As above, n is the index in the new column texts array and m is the
        // index in the old one.
        for ( unsigned n = 1, m = 1; n < numColumns - 1; n++, m++ )
        {
            if ( m == col )
            {
                // Skip copying the deleted column and keep the new index the
                // same (so compensate for "n++" done in the loop).
                n--;
            }
            else // Not the deleted column.
            {
                m_columnsTexts[n - 1] = oldTexts[m - 1];
            }
        }
    }
示例#3
0
    void OnDeleteColumn(unsigned col, unsigned numColumns)
    {
        wxASSERT_MSG( col, "Shouldn't be called for the first column" );

        if ( !m_columnsTexts )
            return;

        wxScopedArray<wxString> oldTexts(m_columnsTexts);
        m_columnsTexts = new wxString[numColumns - 2];
        for ( unsigned n = 1, m = 1; n < numColumns - 1; n++, m++ )
        {
            if ( n == col )
            {
                n--;
            }
            else // Not the deleted column.
            {
                m_columnsTexts[n - 1] = oldTexts[m - 1];
            }
        }
    }