From: Amit on
Hi,

I want to customize the look of wxListCtrl. For this I capture
wxEVT_PAINT event and make a wxPaintDc object.
Using this object I do the desired drawing.

However this causes a side effect, i.e. wxListCtrl now fails to draw
it's own items. I guess this is happening because it's event handler is
not being called.
I also tried calling event.Skip(), both before and after my code but no
success.

then I tried calling wxListCtrl::OnPaint() function both before and
after my code. Now listctrl item's are drawn but my drawing is no more.


Is there a way using which I can draw over the default wxListCtrl
drawing.

OS : WinXP, wxWidgets 2.6.3

void ListCtrlPane::OnPaint(wxPaintEvent& event)
{
event.Skip();

wxRect itemRect;
wxPaintDC dc(this);

dc.SetPen(*wxRED_PEN);

int itemCount = GetItemCount();
long top = GetTopItem();
wxListItem ListItem;
ListItem.SetMask(wxLIST_MASK_TEXT);

int xBeg = 0, nWidth = 0;
for (int col = 0; col < GetColumnCount(); col++)
{
GetColumn(col, ListItem);
if(ListItem.GetText() == kStatus)
{
nWidth = GetColumnWidth(col);
break;
}

int colWidth = GetColumnWidth(col);
xBeg += colWidth ;
}

for (int i = top; i < top + GetCountPerPage() + 1; i++)
{
if (GetItemRect(i, itemRect))
{
itemRect.SetX(xBeg);
itemRect.SetWidth(nWidth);
dc.DrawRectangle(xBeg, itemRect.GetY(), nWidth,
itemRect.GetHeight());
}
}

wxListCtrl::OnPaint(event);
}

The idea is to draw a rectangle around a particular column.

Thanks in Advance

Regards
- Amit Gupta

From: Vadim Zeitlin on
On 30 Nov 2006 03:18:47 -0800 Amit <amitgupta.it(a)gmail.com> wrote:

A> I want to customize the look of wxListCtrl.

This is not supported (beyond what you can with the items attributes). For
instance, what you do is not going to work at all under wxMac. If you
really need to have a custom wxListCtrl, you should use the (possibly
modified) generic version.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

 | 
Pages: 1
Prev: wxPython and Mplayer
Next: wxDynamicLibrary help!