Page 1 of 1

invert the color of wxCaret under linux(wxGTK)

Posted: Fri May 06, 2005 12:59 pm
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.

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

Posted: Sun Jun 26, 2005 11:29 pm
by Ryan Norton
Interesting :).