Also merge the m_overflow attribute
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20536 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -605,6 +605,13 @@ public:
|
|||||||
Merged
|
Merged
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum wxAttrOverflowMode
|
||||||
|
{
|
||||||
|
Unset = -1,
|
||||||
|
Overflow,
|
||||||
|
SingleCell
|
||||||
|
};
|
||||||
|
|
||||||
// ctors
|
// ctors
|
||||||
wxGridCellAttr(wxGridCellAttr *attrDefault = NULL)
|
wxGridCellAttr(wxGridCellAttr *attrDefault = NULL)
|
||||||
{
|
{
|
||||||
@@ -647,7 +654,8 @@ public:
|
|||||||
m_vAlign = vAlign;
|
m_vAlign = vAlign;
|
||||||
}
|
}
|
||||||
void SetSize(int num_rows, int num_cols);
|
void SetSize(int num_rows, int num_cols);
|
||||||
void SetOverflow( bool allow ) { m_overflow = allow; }
|
void SetOverflow(bool allow = TRUE)
|
||||||
|
{ m_overflow = allow ? Overflow : SingleCell; }
|
||||||
void SetReadOnly(bool isReadOnly = TRUE)
|
void SetReadOnly(bool isReadOnly = TRUE)
|
||||||
{ m_isReadOnly = isReadOnly ? ReadOnly : ReadWrite; }
|
{ m_isReadOnly = isReadOnly ? ReadOnly : ReadWrite; }
|
||||||
|
|
||||||
@@ -667,13 +675,15 @@ public:
|
|||||||
bool HasRenderer() const { return m_renderer != NULL; }
|
bool HasRenderer() const { return m_renderer != NULL; }
|
||||||
bool HasEditor() const { return m_editor != NULL; }
|
bool HasEditor() const { return m_editor != NULL; }
|
||||||
bool HasReadWriteMode() const { return m_isReadOnly != Unset; }
|
bool HasReadWriteMode() const { return m_isReadOnly != Unset; }
|
||||||
|
bool HasOverflowMode() const { return m_overflow != Unset; }
|
||||||
|
|
||||||
const wxColour& GetTextColour() const;
|
const wxColour& GetTextColour() const;
|
||||||
const wxColour& GetBackgroundColour() const;
|
const wxColour& GetBackgroundColour() const;
|
||||||
const wxFont& GetFont() const;
|
const wxFont& GetFont() const;
|
||||||
void GetAlignment(int *hAlign, int *vAlign) const;
|
void GetAlignment(int *hAlign, int *vAlign) const;
|
||||||
void GetSize(int *num_rows, int *num_cols) const;
|
void GetSize(int *num_rows, int *num_cols) const;
|
||||||
bool GetOverflow() const { return m_overflow; }
|
bool GetOverflow() const
|
||||||
|
{ return m_overflow != wxGridCellAttr::SingleCell; }
|
||||||
wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
|
wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
|
||||||
wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
|
wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
|
||||||
|
|
||||||
@@ -711,7 +721,8 @@ private:
|
|||||||
m_vAlign;
|
m_vAlign;
|
||||||
int m_sizeRows,
|
int m_sizeRows,
|
||||||
m_sizeCols;
|
m_sizeCols;
|
||||||
bool m_overflow;
|
|
||||||
|
wxAttrOverflowMode m_overflow;
|
||||||
|
|
||||||
wxGridCellRenderer* m_renderer;
|
wxGridCellRenderer* m_renderer;
|
||||||
wxGridCellEditor* m_editor;
|
wxGridCellEditor* m_editor;
|
||||||
|
@@ -458,7 +458,7 @@ void wxGridCellEditor::PaintBackground(const wxRect& rectCell,
|
|||||||
wxGridWindow* gridWindow = wxDynamicCast(m_control->GetParent(), wxGridWindow);
|
wxGridWindow* gridWindow = wxDynamicCast(m_control->GetParent(), wxGridWindow);
|
||||||
if (gridWindow)
|
if (gridWindow)
|
||||||
gridWindow->GetOwner()->PrepareDC(dc);
|
gridWindow->GetOwner()->PrepareDC(dc);
|
||||||
|
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
|
dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
|
||||||
dc.DrawRectangle(rectCell);
|
dc.DrawRectangle(rectCell);
|
||||||
@@ -2133,6 +2133,9 @@ void wxGridCellAttr::MergeWith(wxGridCellAttr *mergefrom)
|
|||||||
if ( !HasReadWriteMode() && mergefrom->HasReadWriteMode() )
|
if ( !HasReadWriteMode() && mergefrom->HasReadWriteMode() )
|
||||||
SetReadOnly(mergefrom->IsReadOnly());
|
SetReadOnly(mergefrom->IsReadOnly());
|
||||||
|
|
||||||
|
if (!HasOverflowMode() && mergefrom->HasOverflowMode() )
|
||||||
|
SetReadOnly(mergefrom->GetOverflow());
|
||||||
|
|
||||||
SetDefAttr(mergefrom->m_defGridAttr);
|
SetDefAttr(mergefrom->m_defGridAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4832,7 +4835,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
else if ( event.RightDown() )
|
else if ( event.RightDown() )
|
||||||
{
|
{
|
||||||
row = YToRow(y);
|
row = YToRow(y);
|
||||||
if ( row >=0 &&
|
if ( row >=0 &&
|
||||||
!SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, row, -1, event ) )
|
!SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, row, -1, event ) )
|
||||||
{
|
{
|
||||||
// no default action at the moment
|
// no default action at the moment
|
||||||
@@ -7103,10 +7106,10 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
|
|||||||
int textOrientation )
|
int textOrientation )
|
||||||
{
|
{
|
||||||
wxArrayString lines;
|
wxArrayString lines;
|
||||||
|
|
||||||
StringToLines( value, lines );
|
StringToLines( value, lines );
|
||||||
|
|
||||||
|
|
||||||
//Forward to new API.
|
//Forward to new API.
|
||||||
DrawTextRectangle( dc,
|
DrawTextRectangle( dc,
|
||||||
lines,
|
lines,
|
||||||
@@ -7114,7 +7117,7 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
|
|||||||
horizAlign,
|
horizAlign,
|
||||||
vertAlign,
|
vertAlign,
|
||||||
textOrientation );
|
textOrientation );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::DrawTextRectangle( wxDC& dc,
|
void wxGrid::DrawTextRectangle( wxDC& dc,
|
||||||
@@ -7127,20 +7130,20 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
|
|||||||
long textWidth, textHeight;
|
long textWidth, textHeight;
|
||||||
long lineWidth, lineHeight;
|
long lineWidth, lineHeight;
|
||||||
int nLines;
|
int nLines;
|
||||||
|
|
||||||
dc.SetClippingRegion( rect );
|
dc.SetClippingRegion( rect );
|
||||||
|
|
||||||
nLines = lines.GetCount();
|
nLines = lines.GetCount();
|
||||||
if( nLines > 0 )
|
if( nLines > 0 )
|
||||||
{
|
{
|
||||||
int l;
|
int l;
|
||||||
float x = 0.0, y = 0.0;
|
float x = 0.0, y = 0.0;
|
||||||
|
|
||||||
if( textOrientation == wxHORIZONTAL )
|
if( textOrientation == wxHORIZONTAL )
|
||||||
GetTextBoxSize(dc, lines, &textWidth, &textHeight);
|
GetTextBoxSize(dc, lines, &textWidth, &textHeight);
|
||||||
else
|
else
|
||||||
GetTextBoxSize( dc, lines, &textHeight, &textWidth );
|
GetTextBoxSize( dc, lines, &textHeight, &textWidth );
|
||||||
|
|
||||||
switch( vertAlign )
|
switch( vertAlign )
|
||||||
{
|
{
|
||||||
case wxALIGN_BOTTOM:
|
case wxALIGN_BOTTOM:
|
||||||
@@ -7149,14 +7152,14 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
|
|||||||
else
|
else
|
||||||
x = rect.x + rect.width - textWidth;
|
x = rect.x + rect.width - textWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxALIGN_CENTRE:
|
case wxALIGN_CENTRE:
|
||||||
if( textOrientation == wxHORIZONTAL )
|
if( textOrientation == wxHORIZONTAL )
|
||||||
y = rect.y + ((rect.height - textHeight)/2);
|
y = rect.y + ((rect.height - textHeight)/2);
|
||||||
else
|
else
|
||||||
x = rect.x + ((rect.width - textWidth)/2);
|
x = rect.x + ((rect.width - textWidth)/2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxALIGN_TOP:
|
case wxALIGN_TOP:
|
||||||
default:
|
default:
|
||||||
if( textOrientation == wxHORIZONTAL )
|
if( textOrientation == wxHORIZONTAL )
|
||||||
@@ -7165,12 +7168,12 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
|
|||||||
x = rect.x + 1;
|
x = rect.x + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Align each line of a multi-line label
|
// Align each line of a multi-line label
|
||||||
for( l = 0; l < nLines; l++ )
|
for( l = 0; l < nLines; l++ )
|
||||||
{
|
{
|
||||||
dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
|
dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
|
||||||
|
|
||||||
switch( horizAlign )
|
switch( horizAlign )
|
||||||
{
|
{
|
||||||
case wxALIGN_RIGHT:
|
case wxALIGN_RIGHT:
|
||||||
@@ -7179,14 +7182,14 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
|
|||||||
else
|
else
|
||||||
y = rect.y + lineWidth + 1;
|
y = rect.y + lineWidth + 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxALIGN_CENTRE:
|
case wxALIGN_CENTRE:
|
||||||
if( textOrientation == wxHORIZONTAL )
|
if( textOrientation == wxHORIZONTAL )
|
||||||
x = rect.x + ((rect.width - lineWidth)/2);
|
x = rect.x + ((rect.width - lineWidth)/2);
|
||||||
else
|
else
|
||||||
y = rect.y + rect.height - ((rect.height - lineWidth)/2);
|
y = rect.y + rect.height - ((rect.height - lineWidth)/2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxALIGN_LEFT:
|
case wxALIGN_LEFT:
|
||||||
default:
|
default:
|
||||||
if( textOrientation == wxHORIZONTAL )
|
if( textOrientation == wxHORIZONTAL )
|
||||||
@@ -7195,7 +7198,7 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
|
|||||||
y = rect.y + rect.height - 1;
|
y = rect.y + rect.height - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( textOrientation == wxHORIZONTAL )
|
if( textOrientation == wxHORIZONTAL )
|
||||||
{
|
{
|
||||||
dc.DrawText( lines[l], (int)x, (int)y );
|
dc.DrawText( lines[l], (int)x, (int)y );
|
||||||
@@ -7605,7 +7608,7 @@ static int CoordToRowOrCol(int coord, int defaultDist, int minDist,
|
|||||||
if (coord < 0)
|
if (coord < 0)
|
||||||
return clipToMinMax && (nMax > 0) ? 0 : -1;
|
return clipToMinMax && (nMax > 0) ? 0 : -1;
|
||||||
|
|
||||||
|
|
||||||
if (!defaultDist)
|
if (!defaultDist)
|
||||||
defaultDist = 1;
|
defaultDist = 1;
|
||||||
|
|
||||||
@@ -8009,10 +8012,10 @@ bool wxGrid::MovePageUp()
|
|||||||
|
|
||||||
int y = GetRowTop(row);
|
int y = GetRowTop(row);
|
||||||
int newRow = internalYToRow( y - ch + 1 );
|
int newRow = internalYToRow( y - ch + 1 );
|
||||||
|
|
||||||
if ( newRow == row )
|
if ( newRow == row )
|
||||||
{
|
{
|
||||||
//row > 0 , so newrow can never be less than 0 here.
|
//row > 0 , so newrow can never be less than 0 here.
|
||||||
newRow = row - 1;
|
newRow = row - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8039,7 +8042,7 @@ bool wxGrid::MovePageDown()
|
|||||||
int newRow = internalYToRow( y + ch );
|
int newRow = internalYToRow( y + ch );
|
||||||
if ( newRow == row )
|
if ( newRow == row )
|
||||||
{
|
{
|
||||||
// row < m_numRows , so newrow can't overflow here.
|
// row < m_numRows , so newrow can't overflow here.
|
||||||
newRow = row + 1;
|
newRow = row + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user