]> git.saurik.com Git - wxWidgets.git/commitdiff
* Apply patch #735595. Add miminumAcceptable{Height,Width}
authorRoger Gammans <rgammans@computer-surgery.co.uk>
Sun, 18 May 2003 19:49:43 +0000 (19:49 +0000)
committerRoger Gammans <rgammans@computer-surgery.co.uk>
Sun, 18 May 2003 19:49:43 +0000 (19:49 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20660 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/grid.tex
include/wx/generic/grid.h
src/generic/grid.cpp

index 02c787d4658b55acb42e8c7ca1e4c71dd05beb94..4dcd0089f58792c782f7cec8b9365528f7b707b8 100644 (file)
@@ -1071,6 +1071,26 @@ for this to have any effect.
 
 Sets the minimal width for the specified column. This should normally be called when creating the grid
 because it will not resize a column that is already narrower than the minimal width.
 
 Sets the minimal width for the specified column. This should normally be called when creating the grid
 because it will not resize a column that is already narrower than the minimal width.
+The width argument must be higher than the minimimal acceptable column width, see
+\helpref{wxGrid::GetColMinimalAcceptableWidth}{wxgridgetcolminimalacceptablewidth}.
+
+\membersection{wxGrid::SetColMinimalAcceptableWidth}\label{wxgridsetcolminimalacceptablewidth}
+
+\func{void}{SetColMinimalAcceptableWidth}{\param{int }{width}}
+
+This modifies the minimum column width that can be handled correctly. Specifying a low value here
+allows smaller grid cells to be dealt with correctly. Specifying a value here which is much smaller
+than the actual minimum size will incur a performance penalty in the functions which perform
+grid cell index lookup on the basis of screen coordinates.
+This should normally be called when creating the grid because it will not resize existing columns
+with sizes smaller than the value specified here. 
+
+\membersection{wxGrid::GetColMinimalAcceptableWidth}\label{wxgridgetcolminimalacceptablewidth}
+
+\func{int}{GetColMinimalAcceptableWidth}{}
+
+This returns the value of the lowest column width that can be handled correctly. See
+member \helpref{SetColMinimalAcceptableWidth}{wxgridsetcolminimalacceptablewidth} for details.
 
 \membersection{wxGrid::SetColSize}\label{wxgridsetcolsize}
 
 
 \membersection{wxGrid::SetColSize}\label{wxgridsetcolsize}
 
@@ -1214,10 +1234,30 @@ for this to have any effect.
 
 \membersection{wxGrid::SetRowMinimalHeight}\label{wxgridsetrowminimalheight}
 
 
 \membersection{wxGrid::SetRowMinimalHeight}\label{wxgridsetrowminimalheight}
 
-\func{void}{SetRowMinimalHeight}{\param{int }{row}, \param{int }{width}}
+\func{void}{SetRowMinimalHeight}{\param{int }{row}, \param{int }{height}}
 
 Sets the minimal height for the specified row. This should normally be called when creating the grid
 because it will not resize a row that is already shorter than the minimal height.
 
 Sets the minimal height for the specified row. This should normally be called when creating the grid
 because it will not resize a row that is already shorter than the minimal height.
+The height argument must be higher than the minimimal acceptable row height, see
+\helpref{wxGrid::GetRowMinimalAcceptableHeight}{wxgridgetrowminimalacceptableheight}.
+
+\membersection{wxGrid::SetRowMinimalAcceptableHeight}\label{wxgridsetrowminimalacceptableheight}
+
+\func{void}{SetRowMinimalAcceptableHeight}{\param{int }{height}}
+
+This modifies the minimum row width that can be handled correctly. Specifying a low value here
+allows smaller grid cells to be dealt with correctly. Specifying a value here which is much smaller
+than the actual minimum size will incur a performance penalty in the functions which perform
+grid cell index lookup on the basis of screen coordinates.
+This should normally be called when creating the grid because it will not resize existing rows
+with sizes smaller than the value specified here. 
+
+\membersection{wxGrid::GetRowMinimalAcceptableHeight}\label{wxgridgetrowminimalacceptableheight}
+
+\func{int}{GetRowMinimalAcceptableHeight}{}
+
+This returns the value of the lowest row width that can be handled correctly. See
+member \helpref{SetRowMinimalAcceptableHeight}{wxgridsetrowminimalacceptableheight} for details.
 
 \membersection{wxGrid::SetRowSize}\label{wxgridsetrowsize}
 
 
 \membersection{wxGrid::SetRowSize}\label{wxgridsetrowsize}
 
index 132921af938e837a97f156ffe0af2b1026d1f4b2..95cc40e0223d30772731376707b8ab2ed0c93dcb 100644 (file)
@@ -1351,6 +1351,18 @@ public:
     void     SetColMinimalWidth( int col, int width );
     void     SetRowMinimalHeight( int row, int width );
 
     void     SetColMinimalWidth( int col, int width );
     void     SetRowMinimalHeight( int row, int width );
 
+    /*  These members can be used to query and modify the minimal
+     *  acceptable size of grid rows and columns. Call this function in
+     *  your code which creates the grid if you want to display cells
+     *  with a size smaller than the default acceptable minimum size.
+     *  Like the members SetColMinimalWidth and SetRowMinimalWidth,
+     *  the existing rows or columns will not be checked/resized.
+     */
+    void     SetColMinimalAcceptableWidth( int width );
+    void     SetRowMinimalAcceptableHeight( int width );
+    int      GetColMinimalAcceptableWidth() const;
+    int      GetRowMinimalAcceptableHeight() const;
+
     void     SetDefaultCellBackgroundColour( const wxColour& );
     void     SetCellBackgroundColour( int row, int col, const wxColour& );
     void     SetDefaultCellTextColour( const wxColour& );
     void     SetDefaultCellBackgroundColour( const wxColour& );
     void     SetCellBackgroundColour( int row, int col, const wxColour& );
     void     SetDefaultCellTextColour( const wxColour& );
@@ -1686,6 +1698,7 @@ protected:
     void InitRowHeights();
 
     int        m_defaultRowHeight;
     void InitRowHeights();
 
     int        m_defaultRowHeight;
+    int        m_minAcceptableRowHeight;
     wxArrayInt m_rowHeights;
     wxArrayInt m_rowBottoms;
 
     wxArrayInt m_rowHeights;
     wxArrayInt m_rowBottoms;
 
@@ -1693,6 +1706,7 @@ protected:
     void InitColWidths();
 
     int        m_defaultColWidth;
     void InitColWidths();
 
     int        m_defaultColWidth;
+    int        m_minAcceptableColWidth;
     wxArrayInt m_colWidths;
     wxArrayInt m_colRights;
 
     wxArrayInt m_colWidths;
     wxArrayInt m_colRights;
 
@@ -1881,6 +1895,7 @@ protected:
     DECLARE_NO_COPY_CLASS(wxGrid)
 };
 
     DECLARE_NO_COPY_CLASS(wxGrid)
 };
 
+
 // ----------------------------------------------------------------------------
 // Grid event class and event types
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // Grid event class and event types
 // ----------------------------------------------------------------------------
index 1563e0b31d72d287dfe8bc7727098c730f2fefa1..68412476633e5c0f046e8743824dfc0a6bfc98c1 100644 (file)
@@ -3748,10 +3748,10 @@ static int CoordToRowOrCol(int coord, int defaultDist, int minDist,
                            bool clipToMinMax);
 
 #define internalXToCol(x) CoordToRowOrCol(x, m_defaultColWidth, \
                            bool clipToMinMax);
 
 #define internalXToCol(x) CoordToRowOrCol(x, m_defaultColWidth, \
-                                          WXGRID_MIN_COL_WIDTH, \
+                                          m_minAcceptableColWidth, \
                                           m_colRights, m_numCols, TRUE)
 #define internalYToRow(y) CoordToRowOrCol(y, m_defaultRowHeight, \
                                           m_colRights, m_numCols, TRUE)
 #define internalYToRow(y) CoordToRowOrCol(y, m_defaultRowHeight, \
-                                          WXGRID_MIN_ROW_HEIGHT, \
+                                          m_minAcceptableRowHeight, \
                                           m_rowBottoms, m_numRows, TRUE)
 /////////////////////////////////////////////////////////////////////
 
                                           m_rowBottoms, m_numRows, TRUE)
 /////////////////////////////////////////////////////////////////////
 
@@ -3978,6 +3978,9 @@ void wxGrid::Init()
     m_defaultColWidth  = WXGRID_DEFAULT_COL_WIDTH;
     m_defaultRowHeight = m_gridWin->GetCharHeight();
 
     m_defaultColWidth  = WXGRID_DEFAULT_COL_WIDTH;
     m_defaultRowHeight = m_gridWin->GetCharHeight();
 
+    m_minAcceptableColWidth  = WXGRID_MIN_COL_WIDTH;
+    m_minAcceptableRowHeight = WXGRID_MIN_ROW_HEIGHT;
+
 #if defined(__WXMOTIF__) || defined(__WXGTK__)  // see also text ctrl sizing in ShowCellEditControl()
     m_defaultRowHeight += 8;
 #else
 #if defined(__WXMOTIF__) || defined(__WXGTK__)  // see also text ctrl sizing in ShowCellEditControl()
     m_defaultRowHeight += 8;
 #else
@@ -5604,7 +5607,7 @@ void wxGrid::DoEndDragResizeRow()
 
         int rowTop = GetRowTop(m_dragRowOrCol);
         SetRowSize( m_dragRowOrCol,
 
         int rowTop = GetRowTop(m_dragRowOrCol);
         SetRowSize( m_dragRowOrCol,
-                    wxMax( m_dragLastPos - rowTop, WXGRID_MIN_ROW_HEIGHT ) );
+                    wxMax( m_dragLastPos - rowTop, m_minAcceptableRowHeight ) );
 
         if ( !GetBatchCount() )
         {
 
         if ( !GetBatchCount() )
         {
@@ -7661,14 +7664,14 @@ static int CoordToRowOrCol(int coord, int defaultDist, int minDist,
 int wxGrid::YToRow( int y )
 {
     return CoordToRowOrCol(y, m_defaultRowHeight,
 int wxGrid::YToRow( int y )
 {
     return CoordToRowOrCol(y, m_defaultRowHeight,
-                           WXGRID_MIN_ROW_HEIGHT, m_rowBottoms, m_numRows, FALSE);
+                           m_minAcceptableRowHeight, m_rowBottoms, m_numRows, FALSE);
 }
 
 
 int wxGrid::XToCol( int x )
 {
     return CoordToRowOrCol(x, m_defaultColWidth,
 }
 
 
 int wxGrid::XToCol( int x )
 {
     return CoordToRowOrCol(x, m_defaultColWidth,
-                           WXGRID_MIN_COL_WIDTH, m_colRights, m_numCols, FALSE);
+                           m_minAcceptableColWidth, m_colRights, m_numCols, FALSE);
 }
 
 
 }
 
 
@@ -9247,7 +9250,7 @@ void wxGrid::EnableDragGridSize( bool enable )
 
 void wxGrid::SetDefaultRowSize( int height, bool resizeExistingRows )
 {
 
 void wxGrid::SetDefaultRowSize( int height, bool resizeExistingRows )
 {
-    m_defaultRowHeight = wxMax( height, WXGRID_MIN_ROW_HEIGHT );
+    m_defaultRowHeight = wxMax( height, m_minAcceptableRowHeight );
 
     if ( resizeExistingRows )
     {
 
     if ( resizeExistingRows )
     {
@@ -9266,6 +9269,7 @@ void wxGrid::SetRowSize( int row, int height )
 {
     wxCHECK_RET( row >= 0 && row < m_numRows, _T("invalid row index") );
 
 {
     wxCHECK_RET( row >= 0 && row < m_numRows, _T("invalid row index") );
 
+
     if ( m_rowHeights.IsEmpty() )
     {
         // need to really create the array
     if ( m_rowHeights.IsEmpty() )
     {
         // need to really create the array
@@ -9287,7 +9291,7 @@ void wxGrid::SetRowSize( int row, int height )
 
 void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
 {
 
 void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
 {
-    m_defaultColWidth = wxMax( width, WXGRID_MIN_COL_WIDTH );
+    m_defaultColWidth = wxMax( width, m_minAcceptableColWidth );
 
     if ( resizeExistingCols )
     {
 
     if ( resizeExistingCols )
     {
@@ -9341,24 +9345,52 @@ void wxGrid::SetColSize( int col, int width )
 
 void wxGrid::SetColMinimalWidth( int col, int width )
 {
 
 void wxGrid::SetColMinimalWidth( int col, int width )
 {
-    m_colMinWidths.Put(col, width);
+    if (width > GetColMinimalAcceptableWidth()) {
+        m_colMinWidths.Put(col, width);
+    }
 }
 
 void wxGrid::SetRowMinimalHeight( int row, int width )
 {
 }
 
 void wxGrid::SetRowMinimalHeight( int row, int width )
 {
-    m_rowMinHeights.Put(row, width);
+    if (width > GetRowMinimalAcceptableHeight()) {
+       m_rowMinHeights.Put(row, width);
+    }
 }
 
 int wxGrid::GetColMinimalWidth(int col) const
 {
     long value = m_colMinWidths.Get(col);
 }
 
 int wxGrid::GetColMinimalWidth(int col) const
 {
     long value = m_colMinWidths.Get(col);
-    return value != wxNOT_FOUND ? (int)value : WXGRID_MIN_COL_WIDTH;
+    return value != wxNOT_FOUND ? (int)value : m_minAcceptableColWidth;
 }
 
 int wxGrid::GetRowMinimalHeight(int row) const
 {
     long value = m_rowMinHeights.Get(row);
 }
 
 int wxGrid::GetRowMinimalHeight(int row) const
 {
     long value = m_rowMinHeights.Get(row);
-    return value != wxNOT_FOUND ? (int)value : WXGRID_MIN_ROW_HEIGHT;
+    return value != wxNOT_FOUND ? (int)value : m_minAcceptableRowHeight;
+}
+
+void wxGrid::SetColMinimalAcceptableWidth( int width )
+{
+    if ( width<1 )
+        return;
+    m_minAcceptableColWidth = width;
+}
+
+void wxGrid::SetRowMinimalAcceptableHeight( int height )
+{
+    if ( height<1 )
+        return;
+    m_minAcceptableRowHeight = height;
+};
+
+int  wxGrid::GetColMinimalAcceptableWidth() const
+{
+    return m_minAcceptableColWidth;
+}
+
+int  wxGrid::GetRowMinimalAcceptableHeight() const
+{
+    return m_minAcceptableRowHeight;
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -9958,8 +9990,6 @@ wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords &topLeft,
     return rect;
 }
 
     return rect;
 }
 
-
-
 //
 // ------ Grid event classes
 //
 //
 // ------ Grid event classes
 //