WXHBRUSH wxControl::MSWControlColor(WXHDC pDC, WXHWND hWnd) { if ( HasTransparentBackground() ) ::SetBkMode((HDC)pDC, TRANSPARENT); // don't pass any background colour to DoMSWControlColor(), our own // background colour will be used by it only if it is set, otherwise the // defaults will be used return DoMSWControlColor(pDC, wxColour(), hWnd); }
WXHBRUSH wxControl::MSWControlColor(WXHDC pDC, WXHWND hWnd) { wxColour colBg; if ( HasTransparentBackground() ) ::SetBkMode((HDC)pDC, TRANSPARENT); else // if the control is opaque it shouldn't use the parents background colBg = GetBackgroundColour(); return DoMSWControlColor(pDC, colBg, hWnd); }
bool wxWindow::DoDrawBackground(wxDC& dc) { wxRect rect; wxSize size = GetSize(); // Why not GetClientSize() ? rect.x = 0; rect.y = 0; rect.width = size.x; rect.height = size.y; wxWindow * const parent = GetParent(); if ( HasTransparentBackground() && !UseBgCol() && parent ) { // DirectFB paints the parent first, then its child windows, so by // the time this code is called, parent's background was already // drawn and there's no point in (imperfectly!) duplicating the work // here: #ifndef __WXDFB__ wxASSERT( !IsTopLevel() ); wxPoint pos = GetPosition(); AdjustForParentClientOrigin( pos.x, pos.y, 0 ); // Adjust DC logical origin wxCoord org_x, org_y, x, y; dc.GetLogicalOrigin( &org_x, &org_y ); x = org_x + pos.x; y = org_y + pos.y; dc.SetLogicalOrigin( x, y ); // Adjust draw rect rect.x = pos.x; rect.y = pos.y; // Let parent draw the background parent->EraseBackground( dc, rect ); // Restore DC logical origin dc.SetLogicalOrigin( org_x, org_y ); #endif // !__WXDFB__ } else { // Draw background ourselves EraseBackground( dc, rect ); } return true; }
bool wxWindow::DoDrawBackground(wxDC& dc) { wxRect rect; wxSize size = GetSize(); // Why not GetClientSize() ? rect.x = 0; rect.y = 0; rect.width = size.x; rect.height = size.y; wxWindow * const parent = GetParent(); if ( HasTransparentBackground() && parent ) { wxASSERT( !IsTopLevel() ); wxPoint pos = GetPosition(); AdjustForParentClientOrigin( pos.x, pos.y, 0 ); // Adjust DC logical origin wxCoord org_x, org_y, x, y; dc.GetLogicalOrigin( &org_x, &org_y ); x = org_x + pos.x; y = org_y + pos.y; dc.SetLogicalOrigin( x, y ); // Adjust draw rect rect.x = pos.x; rect.y = pos.y; // Let parent draw the background parent->EraseBackground( dc, rect ); // Restore DC logical origin dc.SetLogicalOrigin( org_x, org_y ); } else { // Draw background ourselves EraseBackground( dc, rect ); } return true; }
void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) { // Determine wxDC to use based on need to double-buffer or // use system-generated transparent background portions wxDC* dcPtr; if ( HasTransparentBackground() ) dcPtr = new wxPaintDC(this); else dcPtr = new wxAutoBufferedPaintDC(this); wxDC& dc = *dcPtr; wxSize sz = GetClientSize(); const wxRect& butRect = m_btnArea; wxRect tcRect = m_tcArea; wxRect fullRect(0, 0, sz.x, sz.y); // artificial simple border if ( m_widthCustomBorder ) { int customBorder = m_widthCustomBorder; // Set border colour #ifdef __WXMAC__ wxPen pen1( wxColour(133,133,133), customBorder, wxSOLID ); #else wxPen pen1( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT), customBorder, wxPENSTYLE_SOLID); #endif dc.SetPen( pen1 ); // area around both controls wxRect rect2(fullRect); if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE ) { rect2 = tcRect; if ( customBorder == 1 ) { rect2.Inflate(1); } else { #ifdef __WXGTK__ rect2.x -= 1; rect2.y -= 1; #else rect2.x -= customBorder; rect2.y -= customBorder; #endif rect2.width += 1 + customBorder; rect2.height += 1 + customBorder; } } dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.DrawRectangle(rect2); } // Clear the main background if the system doesn't do it by itself if ( !HasTransparentBackground() && (tcRect.x > 0 || tcRect.y > 0) ) { wxColour winCol = GetParent()->GetBackgroundColour(); dc.SetBrush(winCol); dc.SetPen(winCol); dc.DrawRectangle(fullRect); } if ( !m_btn ) { // Standard button rendering DrawButton(dc, butRect); } // paint required portion on the control if ( !m_text || m_widthCustomPaint ) { wxASSERT( m_widthCustomPaint >= 0 ); // Clear the text-control area background wxColour tcCol = GetBackgroundColour(); dc.SetBrush(tcCol); dc.SetPen(tcCol); dc.DrawRectangle(tcRect); // this is intentionally here to allow drawed rectangle's // right edge to be hidden if ( m_text ) tcRect.width = m_widthCustomPaint; dc.SetFont( GetFont() ); dc.SetClippingRegion(tcRect); if ( m_popupInterface ) m_popupInterface->PaintComboControl(dc, tcRect); else wxComboPopup::DefaultPaintComboControl(this, dc, tcRect); } delete dcPtr; }
bool wxGenericComboCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { // // Note that technically we only support 'default' border and wxNO_BORDER. long border = style & wxBORDER_MASK; int tcBorder = wxNO_BORDER; #if defined(__WXUNIVERSAL__) if ( !border ) border = wxBORDER_SIMPLE; #elif defined(__WXMSW__) if ( !border ) // For XP, have 1-width custom border, for older version use sunken /*if ( wxUxThemeEngine::GetIfActive() ) { border = wxBORDER_NONE; m_widthCustomBorder = 1; } else*/ border = wxBORDER_SUNKEN; #else // // Generic version is optimized for wxGTK // #define UNRELIABLE_TEXTCTRL_BORDER if ( !border ) { if ( style & wxCB_READONLY ) { m_widthCustomBorder = 1; } else { m_widthCustomBorder = 0; tcBorder = 0; } } else { // Have textctrl instead use the border given. tcBorder = border; } // Because we are going to have button outside the border, // let's use wxBORDER_NONE for the whole control. border = wxBORDER_NONE; Customize( wxCC_BUTTON_OUTSIDE_BORDER | wxCC_NO_TEXT_AUTO_SELECT | wxCC_BUTTON_STAYS_DOWN ); #endif style = (style & ~(wxBORDER_MASK)) | border; if ( style & wxCC_STD_BUTTON ) m_iFlags |= wxCC_POPUP_ON_MOUSE_UP; // create main window if ( !wxComboCtrlBase::Create(parent, id, value, pos, size, style | wxFULL_REPAINT_ON_RESIZE, validator, name) ) return false; // Create textctrl, if necessary CreateTextCtrl( tcBorder ); // Add keyboard input handlers for main control and textctrl InstallInputHandlers(); // Set background style for double-buffering, when needed // (cannot use when system draws background automatically) if ( !HasTransparentBackground() ) SetBackgroundStyle( wxBG_STYLE_PAINT ); // SetInitialSize should be called last SetInitialSize(size); return true; }