invert the color of wxCaret under linux(wxGTK)

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Post Reply
phonxe
Earned a small fee
Earned a small fee
Posts: 18
Joined: Fri May 06, 2005 12:37 pm

invert the color of wxCaret under linux(wxGTK)

Post by phonxe »

The original color of wxCaret is always BLACK.
The following codes(just 2 lines) can invert the color depends on the background color.

Code: Select all

// in ./wxWidgets/src/generic/caret.cpp

void wxCaret::DoDraw(wxDC *dc)
{
    /***  jsut commented out the original codes
    dc->SetPen( *wxBLACK_PEN );

    dc->SetBrush(*(m_hasFocus ? wxBLACK_BRUSH : wxTRANSPARENT_BRUSH));
    dc->SetPen(*wxBLACK_PEN);

    // VZ: unfortunately, the rectangle comes out a pixel smaller when this is
    //     done under wxGTK - no idea why
    //dc->SetLogicalFunction(wxINVERT);

    dc->DrawRectangle(m_x, m_y, m_width, m_height);
    ***/

    // add the 2 lines
    if(m_hasFocus)
      dc->Blit(m_x, m_y, m_width, m_height, dc, 0, 0, wxINVERT);
}
hope this helps.
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Re: invert the color of wxCaret under linux(wxGTK)

Post by Ryan Norton »

Interesting :).
[Mostly retired moderator, still check in to clean up some stuff]
Post Reply