clip column image (and not only the text) to the column width (patch 1664588) [backport from HEAD]
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44651 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -98,6 +98,9 @@ static const int WIDTH_COL_DEFAULT = 80;
|
||||
// the space between the image and the text in the report mode
|
||||
static const int IMAGE_MARGIN_IN_REPORT_MODE = 5;
|
||||
|
||||
// the space between the image and the text in the report mode in header
|
||||
static const int HEADER_IMAGE_MARGIN_IN_REPORT_MODE = 2;
|
||||
|
||||
// ============================================================================
|
||||
// private classes
|
||||
// ============================================================================
|
||||
@@ -1846,7 +1849,6 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
wLabel += 2 * EXTRA_WIDTH;
|
||||
|
||||
// and the width of the icon, if any
|
||||
static const int MARGIN_BETWEEN_TEXT_AND_ICON = 2;
|
||||
int ix = 0, iy = 0; // init them just to suppress the compiler warnings
|
||||
const int image = item.m_image;
|
||||
wxImageList *imageList;
|
||||
@@ -1856,7 +1858,7 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
if ( imageList )
|
||||
{
|
||||
imageList->GetSize(image, ix, iy);
|
||||
wLabel += ix + MARGIN_BETWEEN_TEXT_AND_ICON;
|
||||
wLabel += ix + HEADER_IMAGE_MARGIN_IN_REPORT_MODE;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1885,6 +1887,10 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
break;
|
||||
}
|
||||
|
||||
// draw the text and image clipping them so that they
|
||||
// don't overwrite the column boundary
|
||||
wxDCClipper clipper(dc, x, HEADER_OFFSET_Y, cw, h - 4 );
|
||||
|
||||
// if we have an image, draw it on the right of the label
|
||||
if ( imageList )
|
||||
{
|
||||
@@ -1892,18 +1898,12 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
(
|
||||
image,
|
||||
dc,
|
||||
xAligned + wLabel - ix - MARGIN_BETWEEN_TEXT_AND_ICON,
|
||||
xAligned + wLabel - ix - HEADER_IMAGE_MARGIN_IN_REPORT_MODE,
|
||||
HEADER_OFFSET_Y + (h - 4 - iy)/2,
|
||||
wxIMAGELIST_DRAW_TRANSPARENT
|
||||
);
|
||||
|
||||
cw -= ix + MARGIN_BETWEEN_TEXT_AND_ICON;
|
||||
}
|
||||
|
||||
// draw the text clipping it so that it doesn't overwrite the column
|
||||
// boundary
|
||||
wxDCClipper clipper(dc, x, HEADER_OFFSET_Y, cw, h - 4 );
|
||||
|
||||
dc.DrawText( item.GetText(),
|
||||
xAligned + EXTRA_WIDTH, h / 2 - hLabel / 2 ); //HEADER_OFFSET_Y + EXTRA_HEIGHT );
|
||||
|
||||
|
Reference in New Issue
Block a user