Fixed lots of painting, clipping and alignment issues.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28068 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
2be125e6fc
commit
f84fa75af9
@ -3252,13 +3252,7 @@ void wxTreeListMainWindow::PaintItem(wxTreeListItem *item, wxDC& dc)
|
|||||||
colText = GetForegroundColour();
|
colText = GetForegroundColour();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen *pen =
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
#ifndef __WXMAC__
|
|
||||||
// don't draw rect outline if we already have the
|
|
||||||
// background color under Mac
|
|
||||||
(item->IsSelected() && m_hasFocus) ? wxBLACK_PEN :
|
|
||||||
#endif // !__WXMAC__
|
|
||||||
wxTRANSPARENT_PEN;
|
|
||||||
|
|
||||||
long text_w = 0, text_h = 0;
|
long text_w = 0, text_h = 0;
|
||||||
|
|
||||||
@ -3266,22 +3260,24 @@ void wxTreeListMainWindow::PaintItem(wxTreeListItem *item, wxDC& dc)
|
|||||||
|
|
||||||
int total_h = GetLineHeight(item);
|
int total_h = GetLineHeight(item);
|
||||||
|
|
||||||
if (item->IsSelected() && HasFlag (wxTR_FULL_ROW_HIGHLIGHT)) {
|
if (item->IsSelected() && HasFlag(wxTR_FULL_ROW_HIGHLIGHT)) {
|
||||||
dc.SetBrush(*(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush));
|
dc.SetBrush(*(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush));
|
||||||
int offset = HasFlag(wxTR_ROW_LINES) ? 1 : 0;
|
dc.SetPen(*wxBLACK_PEN);
|
||||||
dc.DrawRectangle (0, item->GetY() + offset,
|
colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
||||||
m_owner->GetHeaderWindow()->GetWidth(), total_h-offset);
|
} else {
|
||||||
colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
|
||||||
}else{
|
|
||||||
wxColour colBg;
|
wxColour colBg;
|
||||||
if (attr && attr->HasBackgroundColour()) {
|
if (attr && attr->HasBackgroundColour()) {
|
||||||
colBg = attr->GetBackgroundColour();
|
colBg = attr->GetBackgroundColour();
|
||||||
}else{
|
} else {
|
||||||
colBg = m_backgroundColour;
|
colBg = GetBackgroundColour();
|
||||||
}
|
}
|
||||||
dc.SetBrush(wxBrush(colBg, wxTRANSPARENT));
|
dc.SetBrush(wxBrush(colBg, wxSOLID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int offset = HasFlag(wxTR_ROW_LINES) ? 1 : 0;
|
||||||
|
dc.DrawRectangle(0, item->GetY() + offset,
|
||||||
|
m_owner->GetHeaderWindow()->GetWidth(), total_h-offset);
|
||||||
|
|
||||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||||
int text_extraH = (total_h > text_h) ? (total_h - text_h)/2 : 0;
|
int text_extraH = (total_h > text_h) ? (total_h - text_h)/2 : 0;
|
||||||
int img_extraH = (total_h > m_imgHeight)? (total_h-m_imgHeight)/2: 0;
|
int img_extraH = (total_h > m_imgHeight)? (total_h-m_imgHeight)/2: 0;
|
||||||
@ -3292,9 +3288,9 @@ void wxTreeListMainWindow::PaintItem(wxTreeListItem *item, wxDC& dc)
|
|||||||
int image;
|
int image;
|
||||||
int image_x = 0;
|
int image_x = 0;
|
||||||
int image_w = 0;
|
int image_w = 0;
|
||||||
if(i == GetMainColumn()) {
|
if (i == GetMainColumn()) {
|
||||||
image = item->GetCurrentImage();
|
image = item->GetCurrentImage();
|
||||||
if (HasButtons()) {
|
if (item->HasPlus()) {
|
||||||
image_x = item->GetX() + (m_btnWidth-m_btnWidth2) + LINEATROOT;
|
image_x = item->GetX() + (m_btnWidth-m_btnWidth2) + LINEATROOT;
|
||||||
}else{
|
}else{
|
||||||
image_x = item->GetX() - m_imgWidth2;
|
image_x = item->GetX() - m_imgWidth2;
|
||||||
@ -3325,19 +3321,19 @@ void wxTreeListMainWindow::PaintItem(wxTreeListItem *item, wxDC& dc)
|
|||||||
}
|
}
|
||||||
int text_x = image_x + image_w;
|
int text_x = image_x + image_w;
|
||||||
|
|
||||||
if (item->IsSelected() && (i==GetMainColumn()) && !HasFlag (wxTR_FULL_ROW_HIGHLIGHT))
|
if (item->IsSelected() && (i==GetMainColumn()) && !HasFlag(wxTR_FULL_ROW_HIGHLIGHT))
|
||||||
{
|
{
|
||||||
|
dc.SetPen(*wxBLACK_PEN);
|
||||||
dc.SetBrush(*(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush));
|
dc.SetBrush(*(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush));
|
||||||
int offset = HasFlag (wxTR_ROW_LINES) ? 1 : 0;
|
int offset = HasFlag (wxTR_ROW_LINES) ? 1 : 0;
|
||||||
dc.DrawRectangle (text_x, item->GetY() + offset, text_w, total_h-offset);
|
int width = wxMin(text_w+2, colwidth - text_x - x_colstart);
|
||||||
|
dc.DrawRectangle(text_x-1, item->GetY() + offset, width, total_h-offset);
|
||||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||||
dc.SetTextForeground(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
|
dc.SetTextForeground(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
|
||||||
}else{
|
}else{
|
||||||
dc.SetTextForeground(colText);
|
dc.SetTextForeground(colText);
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.SetPen(*pen);
|
|
||||||
|
|
||||||
wxDCClipper clipper (dc, x_colstart, item->GetY(), colwidth, total_h);
|
wxDCClipper clipper (dc, x_colstart, item->GetY(), colwidth, total_h);
|
||||||
if (image != NO_IMAGE)
|
if (image != NO_IMAGE)
|
||||||
{
|
{
|
||||||
@ -3399,6 +3395,9 @@ void wxTreeListMainWindow::PaintLevel (wxTreeListItem *item, wxDC &dc,
|
|||||||
|
|
||||||
if (IsExposed(exposed_x, exposed_y, 10000, h)) // 10000 = very much
|
if (IsExposed(exposed_x, exposed_y, 10000, h)) // 10000 = very much
|
||||||
{
|
{
|
||||||
|
// draw item
|
||||||
|
PaintItem(item, dc);
|
||||||
|
|
||||||
if (HasFlag(wxTR_ROW_LINES))
|
if (HasFlag(wxTR_ROW_LINES))
|
||||||
{
|
{
|
||||||
//dc.DestroyClippingRegion();
|
//dc.DestroyClippingRegion();
|
||||||
@ -3429,6 +3428,16 @@ void wxTreeListMainWindow::PaintLevel (wxTreeListItem *item, wxDC &dc,
|
|||||||
// clip to the column width
|
// clip to the column width
|
||||||
wxDCClipper clipper(dc, x_colstart, y_top, clip_width, 10000);
|
wxDCClipper clipper(dc, x_colstart, y_top, clip_width, 10000);
|
||||||
|
|
||||||
|
if (!HasFlag(wxTR_NO_LINES))
|
||||||
|
{
|
||||||
|
if (x > m_indent)
|
||||||
|
dc.DrawLine(x - m_indent, y_mid, x - m_btnWidth2, y_mid);
|
||||||
|
else if (HasFlag(wxTR_LINES_AT_ROOT))
|
||||||
|
dc.DrawLine(m_btnWidth2-2, y_mid,
|
||||||
|
x - m_btnWidth2, y_mid);
|
||||||
|
dc.DrawLine(x + m_btnWidth2, y_mid, x /*+ m_spacing*/, y_mid);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_imageListButtons != NULL)
|
if (m_imageListButtons != NULL)
|
||||||
{
|
{
|
||||||
// draw the image button here
|
// draw the image button here
|
||||||
@ -3506,18 +3515,14 @@ void wxTreeListMainWindow::PaintLevel (wxTreeListItem *item, wxDC &dc,
|
|||||||
|
|
||||||
// draw the horizontal line here
|
// draw the horizontal line here
|
||||||
if (!(level == 0) && !((level == 1) && HasFlag(wxTR_HIDE_ROOT))) {
|
if (!(level == 0) && !((level == 1) && HasFlag(wxTR_HIDE_ROOT))) {
|
||||||
int x2 = x;
|
int x2 = x - m_indent;
|
||||||
if (!HasButtons()) x2 = x - m_indent;
|
|
||||||
if (m_imgWidth > 0) {
|
if (m_imgWidth > 0) {
|
||||||
dc.DrawLine(x2, y_mid, x2+m_indent-m_imgWidth2, y_mid);
|
dc.DrawLine(x2, y_mid, x2+m_indent-m_imgWidth2, y_mid);
|
||||||
}else{
|
}else{
|
||||||
dc.DrawLine(x2, y_mid, x2+m_btnWidth2+LINEATROOT-MARGIN, y_mid);
|
dc.DrawLine(x2, y_mid, x2+m_btnWidth2+LINEATROOT+MARGIN, y_mid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw item
|
|
||||||
PaintItem(item, dc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore DC objects
|
// restore DC objects
|
||||||
@ -3528,47 +3533,69 @@ void wxTreeListMainWindow::PaintLevel (wxTreeListItem *item, wxDC &dc,
|
|||||||
if (item->IsExpanded())
|
if (item->IsExpanded())
|
||||||
{
|
{
|
||||||
wxArrayTreeListItems& children = item->GetChildren();
|
wxArrayTreeListItems& children = item->GetChildren();
|
||||||
|
int count = children.Count();
|
||||||
|
int n, oldY;
|
||||||
|
|
||||||
// clip to the column width
|
// paint sublevel items first
|
||||||
size_t clip_width = m_owner->GetHeaderWindow()->
|
for (n=0; n<count; ++n) {
|
||||||
GetColumn(m_main_column).GetWidth();
|
oldY = y;
|
||||||
wxDCClipper clipper(dc, x_colstart, y_top, clip_width, 10000);
|
PaintLevel(children[n], dc, level+1, y, x_colstart);
|
||||||
|
|
||||||
// process lower levels
|
|
||||||
int oldY;
|
|
||||||
if (m_imgWidth > 0) {
|
|
||||||
oldY = y_mid + m_imgHeight2;
|
|
||||||
}else{
|
|
||||||
oldY = y_mid + h/2;
|
|
||||||
}
|
}
|
||||||
int y2;
|
|
||||||
int n;
|
|
||||||
for (n = 0; n < (int)children.Count(); ++n) {
|
|
||||||
|
|
||||||
if (!HasFlag(wxTR_NO_LINES))
|
// then draw the connecting lines
|
||||||
{
|
if (!HasFlag(wxTR_NO_LINES) && count > 0)
|
||||||
// draw line down to last child
|
{
|
||||||
if (children[n]->HasPlus() && HasButtons()) {
|
// clip to the column width
|
||||||
y2 = y + h/2 - m_btnHeight2;
|
size_t clip_width = m_owner->GetHeaderWindow()->GetColumn(m_main_column).GetWidth();
|
||||||
if (HasButtons()) {
|
wxDCClipper clipper(dc, x_colstart, y_top, clip_width, 10000);
|
||||||
dc.DrawLine(x+m_indent, oldY, x+m_indent, y2);
|
|
||||||
}else{
|
|
||||||
dc.DrawLine(x, oldY, x, y2);
|
|
||||||
}
|
|
||||||
oldY = y2 + m_btnHeight;
|
|
||||||
}else{
|
|
||||||
y2 = y + h/2;
|
|
||||||
if (HasButtons()) {
|
|
||||||
dc.DrawLine(x+m_indent, oldY, x+m_indent, y2);
|
|
||||||
}else{
|
|
||||||
dc.DrawLine(x, oldY, x, y2);
|
|
||||||
}
|
|
||||||
oldY = y2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PaintLevel (children[n], dc, level+1, y, x_colstart);
|
// draw line down to last child
|
||||||
|
oldY += GetLineHeight(children[n-1]) >> 1;
|
||||||
|
if (HasButtons()) y_mid += 5;
|
||||||
|
dc.DrawLine(x, y_mid, x, oldY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// // clip to the column width
|
||||||
|
// size_t clip_width = m_owner->GetHeaderWindow()->
|
||||||
|
// GetColumn(m_main_column).GetWidth();
|
||||||
|
// wxDCClipper clipper(dc, x_colstart, y_top, clip_width, 10000);
|
||||||
|
|
||||||
|
// // process lower levels
|
||||||
|
// int oldY;
|
||||||
|
// if (m_imgWidth > 0) {
|
||||||
|
// oldY = y_mid + m_imgHeight2;
|
||||||
|
// }else{
|
||||||
|
// oldY = y_mid + h/2;
|
||||||
|
// }
|
||||||
|
// int y2;
|
||||||
|
// int n;
|
||||||
|
// for (n = 0; n < (int)children.Count(); ++n) {
|
||||||
|
|
||||||
|
// if (!HasFlag(wxTR_NO_LINES))
|
||||||
|
// {
|
||||||
|
// // draw line down to last child
|
||||||
|
// if (children[n]->HasPlus() && HasButtons()) {
|
||||||
|
// y2 = y + h/2 - m_btnHeight2;
|
||||||
|
// if (HasButtons()) {
|
||||||
|
// dc.DrawLine(x+m_indent, oldY, x+m_indent, y2);
|
||||||
|
// }else{
|
||||||
|
// dc.DrawLine(x, oldY, x, y2);
|
||||||
|
// }
|
||||||
|
// oldY = y2 + m_btnHeight;
|
||||||
|
// }else{
|
||||||
|
// y2 = y + h/2;
|
||||||
|
// if (HasButtons()) {
|
||||||
|
// dc.DrawLine(x+m_indent, oldY, x+m_indent, y2);
|
||||||
|
// }else{
|
||||||
|
// dc.DrawLine(x, oldY, x, y2);
|
||||||
|
// }
|
||||||
|
// oldY = y2;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// PaintLevel (children[n], dc, level+1, y, x_colstart);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user