void ClueListBox::OnDrawItem(wxDC & dc, const wxRect & rect, size_t n) const { wxRect numRect(rect); numRect.SetWidth(m_numWidth); wxRect textRect(rect); textRect.SetX(numRect.GetRight() + GetMargins().x); textRect.SetWidth(rect.width - GetMargins().x); // Get fonts and colors dc.SetFont(GetFont()); if (IsSelected(n)) dc.SetTextForeground(GetSelectionForeground()); else dc.SetTextForeground(GetForegroundColour()); XPuzzle::Clue clue = GetItem(n); dc.DrawLabel(wxString::Format(_T("%d."), clue.Number()), numRect, wxALIGN_RIGHT|wxALIGN_TOP); wxASSERT(! m_cachedClues.at(n).empty()); dc.DrawLabel(m_cachedClues.at(n), textRect); //dc.DrawLine(textRect.x, textRect.y, textRect.x + textRect.width, textRect.y + textRect.height); }
void wxStaticBox::PaintForeground(wxDC& dc, const RECT& WXUNUSED(rc)) { MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(dc), 0); // when using XP themes, neither setting the text colour nor transparent // background mode doesn't change anything: the static box def window proc // still draws the label in its own colours, so we need to redraw the text // ourselves if we have a non default fg colour if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() ) { // draw over the text in default colour in our colour dc.SetFont(GetFont()); HDC hdc = GetHdcOf(dc); ::SetTextColor(hdc, GetForegroundColour().GetPixel()); // FIXME: value of x is hardcoded as this is what it is on my system, // no idea if it's true everywhere const int y = dc.GetCharHeight(); const int x = 9; // TODO: RTL? RECT rc = { x, 0, GetSize().x - x, y }; const wxString label = GetLabel(); ::DrawText(hdc, label, label.length(), &rc, DT_SINGLELINE | DT_VCENTER); } }
void pxStaticText::paintEvent(wxPaintEvent &evt) { wxPaintDC dc(this); const int dcWidth = dc.GetSize().GetWidth(); const int dcHeight = dc.GetSize().GetHeight(); if (dcWidth < 1) return; dc.SetFont(GetFontOk()); if (IsEnabled()) dc.SetTextForeground(GetForegroundColour()); else dc.SetTextForeground(*wxLIGHT_GREY); pxWindowTextWriter writer(dc); writer.Align(m_align); const wxString &label(m_autowrap ? m_wrappedLabel : m_label); if (m_autowrap) _updateWrapping(false); int tWidth, tHeight; dc.GetMultiLineTextExtent(label, &tWidth, &tHeight); writer.Align(m_align); if (m_align & wxALIGN_CENTER_VERTICAL) writer.SetY((dcHeight - tHeight) / 2); else writer.SetY((int)(dcHeight * m_paddingPct_vert) + m_paddingPix_vert); writer.WriteLn(label); // without formatting please. //dc.SetBrush( *wxTRANSPARENT_BRUSH ); //dc.DrawRectangle(wxPoint(), dc.GetSize()); }
void StripMenuButton::doPaint(wxDC* dc) { wxFont font = GetFont(); if (m_bBold) font.SetWeight(wxFONTWEIGHT_BOLD); dc->SetFont(font); dc->SetTextBackground(GetBackgroundColour()); dc->SetTextForeground(GetForegroundColour()); if (!m_imgBg.getImg() || !m_imgBg->IsOk()) { wxBrush bg = dc->GetBackground(); dc->SetBackground(wxBrush(this->GetBackgroundColour())); dc->Clear(); dc->SetBackground(bg); } else { paintBGImage(dc); } paintLabel(dc); }
WXHBRUSH wxTextCtrl::OnCtlColor( WXHDC hWxDC, WXHWND WXUNUSED(hWnd), WXUINT WXUNUSED(uCtlColor), WXUINT WXUNUSED(uMessage), WXWPARAM WXUNUSED(wParam), WXLPARAM WXUNUSED(lParam) ) { HPS hPS = (HPS)hWxDC; wxColour vColBack = GetBackgroundColour(); wxColour vColFore = GetForegroundColour(); wxBrush* pBackgroundBrush = wxTheBrushList->FindOrCreateBrush( vColBack, wxSOLID ); if (m_bUseCtl3D) { HBRUSH hBrush = NULLHANDLE; return hBrush; } if (GetParent()->GetTransparentBackground()) ::GpiSetBackMix(hPS, BM_LEAVEALONE); else ::GpiSetBackMix(hPS, BM_OVERPAINT); if (!IsEnabled() && (GetWindowStyle() & wxTE_MULTILINE) == 0) vColBack = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); ::GpiSetBackColor(hPS, vColBack.GetPixel()); ::GpiSetColor(hPS, vColFore.GetPixel()); return (WXHBRUSH)pBackgroundBrush->GetResourceHandle(); } // end of wxTextCtrl::OnCtlColor
void gcHyperlinkCtrl::onPaint(wxPaintEvent& WXUNUSED(event)) { wxRect rect = GetLabelRect(); rect.Offset(1,0); wxPaintDC dc(this); wxFont font = GetFont(); font.SetUnderlined(m_bUnderlined); dc.SetFont(font); dc.SetTextForeground(GetForegroundColour()); dc.SetTextBackground(GetBackgroundColour()); dc.DrawText(GetLabel(), rect.GetTopLeft()); if (HasFocus()) { wxColor rectColor(GetGCThemeManager()->getColor("checkbox", "focus-fg")); wxRect rect = GetRect(); rect.SetPosition(wxPoint(0,0)); dc.SetBrush(wxBrush(*wxRED, wxTRANSPARENT)); dc.SetPen(wxPen(rectColor)); dc.DrawRectangle(rect); } }
//------------------------------------------------------------------------------ void CelestialBodyPanel::Create() { // use a clone here theCelestialBody = (CelestialBody*) (origCelestialBody->Clone()); try { cbNotebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxGROW); cbNotebook->SetBackgroundColour(GetBackgroundColour()); cbNotebook->SetForegroundColour(GetForegroundColour()); // create properties, orbit, orientation, and visualization panels properties = new CelestialBodyPropertiesPanel(this, cbNotebook, theCelestialBody); orbit = new CelestialBodyOrbitPanel(this, cbNotebook, theCelestialBody); orientation = new CelestialBodyOrientationPanel(this, cbNotebook, theCelestialBody); visualization = new CelestialBodyVisualizationPanel(this, cbNotebook, theCelestialBody); // add panels to notebook cbNotebook->AddPage(properties, wxT("Properties")); cbNotebook->AddPage(orbit, wxT("Orbit")); cbNotebook->AddPage(orientation, wxT("Orientation")); cbNotebook->AddPage(visualization, wxT("Visualization")); theMiddleSizer->Add(cbNotebook, 1, wxGROW, 1); // 3? } catch (BaseException &be) { MessageInterface::ShowMessage("Error creating the CelestialBodyPanel: %s\n", (be.GetFullMessage()).c_str()); } }
void wxRichTextFontPreviewCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); wxSize size = GetSize(); wxFont font = GetFont(); if ((GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) || (GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT)) { double size = static_cast<double>(font.GetPointSize()) / wxSCRIPT_MUL_FACTOR; font.SetPointSize( static_cast<int>(size) ); } if ( font.IsOk() ) { dc.SetFont(font); // Calculate vertical and horizontal centre wxCoord w = 0, h = 0; wxString text(_("ABCDEFGabcdefg12345")); if (GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS) text.MakeUpper(); dc.GetTextExtent( text, &w, &h); int cx = wxMax(2, (size.x/2) - (w/2)); int cy = wxMax(2, (size.y/2) - (h/2)); if ( GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT ) cy -= h/2; if ( GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT ) cy += h/2; dc.SetTextForeground(GetForegroundColour()); dc.SetClippingRegion(2, 2, size.x-4, size.y-4); dc.DrawText(text, cx, cy); if (GetTextEffects() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH) { dc.SetPen(wxPen(GetForegroundColour(), 1)); dc.DrawLine(cx, (int) (cy + h/2 + 0.5), cx + w, (int) (cy + h/2 + 0.5)); } dc.DestroyClippingRegion(); } }
void wxHyperlinkCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); dc.SetFont(GetFont()); dc.SetTextForeground(GetForegroundColour()); dc.SetTextBackground(GetBackgroundColour()); dc.DrawText(GetLabel(), GetLabelRect().GetTopLeft()); }
bool CTransparentStaticLine::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { bool bRetVal = wxPanel::Create(parent, id, pos, size, style|wxTRANSPARENT_WINDOW, name); SetBackgroundColour(parent->GetBackgroundColour()); SetForegroundColour(parent->GetForegroundColour()); SetLineColor(GetForegroundColour()); return bRetVal; }
bool wxTextCtrl::SetFont( const wxFont& font ) { if ( !wxTextCtrlBase::SetFont( font ) ) return false ; GetPeer()->SetFont( font , GetForegroundColour() , GetWindowStyle(), false /* dont ignore black */ ) ; return true ; }
wxSearchTextCtrl(wxSearchCtrl *search, const wxString& value, int style) : wxTextCtrl(search, wxID_ANY, value, wxDefaultPosition, wxDefaultSize, style | wxNO_BORDER) { m_search = search; m_defaultFG = GetForegroundColour(); // remove the default minsize, the searchctrl will have one instead SetSizeHints(wxDefaultCoord,wxDefaultCoord); }
void wxGenericHyperlinkCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); dc.SetFont(GetFont()); dc.SetTextForeground(GetForegroundColour()); dc.SetTextBackground(GetBackgroundColour()); dc.DrawText(GetLabel(), GetLabelRect().GetTopLeft()); if (HasFocus()) { wxRendererNative::Get().DrawFocusRect(this, dc, GetClientRect(), wxCONTROL_SELECTED); } }
gcToggleButton::gcToggleButton( wxWindow* parent, wxWindowID id, const wxString& text, const wxPoint& pos, const wxSize& size, long style ) : gcButton( parent, id, text, pos, size, style ) { m_szToggleOn = ("#button_toggle_up"); m_szToggleOff = ("#button_toggle_down"); m_bToggled = false; Bind(wxEVT_LEFT_DOWN, &gcToggleButton::onMouseDown, this); m_TextColor = GetForegroundColour(); refreshImage(); }
//============================================================================= // Event Handlers //============================================================================= void wxGlossyButton::OnPaint( wxPaintEvent &event ) { wxBufferedPaintDC dc( this ); wxColour background = m_topEnd; wxColour foreground = GetForegroundColour(); wxRect clientRect = GetClientRect(); wxRect gradientRect = clientRect; bool captured = ( GetCapture() == this ); if( !captured ) { // Update defaults also when changing the current theme at runtime m_topEnd = wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVECAPTION ); foreground = wxGD::Draw::IsDark( m_topEnd ) ? *wxWHITE : *wxBLACK; SetBackgroundColour( m_topEnd ); SetForegroundColour( foreground ); } else { gradientRect.SetHeight( gradientRect.GetHeight() + 1 ); #if wxVERSION_NUMBER < 2900 int r = m_topEnd.Red() * 0.75; int g = m_topEnd.Green() * 0.75; int b = m_topEnd.Blue() * 0.75; m_topEnd.Set( r, g, b ); #else m_topEnd = m_topEnd.ChangeLightness( 75 ); #endif } wxGD::Draw::GlossyGradient( dc, gradientRect, m_topStart, m_bottomStart, m_bottomEnd, m_topEnd, m_hover ); dc.SetPen( wxPen( background ) ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.DrawRectangle( 0, 0, clientRect.GetWidth(), clientRect.GetHeight() ); dc.SetFont( GetFont() ); dc.SetTextForeground( foreground ); if( GetCapture() == this ) clientRect.Offset( 1,1 ); wxGD::Draw::Bitmap( dc, m_bitmap, clientRect, m_label ); dc.DrawLabel( m_label, clientRect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL ); }
void DispLoading::onPaint( wxPaintEvent& event ) { wxPaintDC dc(this); dc.SetFont(GetFont()); dc.SetTextForeground(GetForegroundColour()); //dc.SetTextBackground(GetBackgroundColour()); wxSize size = GetSize(); long x=22; long y=(size.GetHeight() - dc.GetTextExtent(GetLabel()).GetHeight())/2;; dc.DrawText(this->GetLabel(), x, y); }
tpanelnotebook::tpanelnotebook(mainframe *owner_, wxWindow *parent) : wxAuiNotebook(parent, NOTEBOOK_ID, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_CLOSE_ON_ALL_TABS | wxAUI_NB_WINDOWLIST_BUTTON), owner(owner_) { wxColour foreground = GetForegroundColour(); wxColour background = GetBackgroundColour(); unsigned int forecount = foreground.Red() + foreground.Blue() + foreground.Green(); unsigned int backcount = background.Red() + background.Blue() + background.Green(); bool isreverse = forecount > backcount; SetArtProvider(new customTabArt(foreground, background, isreverse)); }
void HtmlText::Parse(const wxString & label, int pointSize, const wxString & faceName) { // I can't seem to identify exactly *what* is causing this, but every // time I lay out the window with font size 70, I get back a height of // 15 px. if (pointSize == 70) pointSize = 69; // Set fonts m_parser->SetStandardFonts(pointSize, faceName); // Set colors m_parser->SetActualColor(GetForegroundColour()); // Parse the cell delete m_cell; m_cell = (wxHtmlCell *)m_parser->Parse(label); }
WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) { HDC hdc = (HDC)pDC; WXHBRUSH hbr = 0; if ( !colBg.IsOk() ) { if ( wxWindow *win = wxFindWinFromHandle(hWnd) ) hbr = win->MSWGetBgBrush(pDC); // if the control doesn't have any bg colour, foreground colour will be // ignored as the return value would be 0 -- so forcefully give it a // non default background brush in this case if ( !hbr && m_hasFgCol ) colBg = GetBackgroundColour(); } // use the background colour override if a valid colour is given: this is // used when the control is disabled to grey it out and also if colBg was // set just above if ( colBg.IsOk() ) { wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg); hbr = (WXHBRUSH)brush->GetResourceHandle(); } // always set the foreground colour if we changed the background, whether // m_hasFgCol is true or not: if it true, we must do it, of course, but // even if it isn't, we must set the default foreground explicitly as by // default just the simple black is used if ( hbr ) { ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour())); } // finally also set the background colour for text drawing: without this, // the text in an edit control is drawn using the default background even // if we return a valid brush if ( colBg.IsOk() || m_hasBgCol ) { if ( !colBg.IsOk() ) colBg = GetBackgroundColour(); ::SetBkColor(hdc, wxColourToRGB(colBg)); } return hbr; }
void wxGradientButton::OnPaint( wxPaintEvent& event ) { // Before editing this code, remove the block markers. wxBufferedPaintDC dc(this); wxRect clientRect = GetClientRect(); wxRect gradientRect = clientRect; gradientRect.SetHeight(gradientRect.GetHeight()/2 + ((GetCapture() == this) ? 1 : 0)); if(GetCapture() != this) { dc.GradientFillLinear(gradientRect, m_GradientTopStartColour, m_GradientTopEndColour, wxSOUTH); } else { dc.SetPen(wxPen(m_PressedColourTop)); dc.SetBrush(wxBrush(m_PressedColourTop)); dc.DrawRectangle(gradientRect); } gradientRect.Offset(0, gradientRect.GetHeight()); if(GetCapture() != this) { dc.GradientFillLinear(gradientRect, m_GradientBottomStartColour, m_GradientBottomEndColour, wxSOUTH); } else { dc.SetPen(wxPen(m_PressedColourBottom)); dc.SetBrush(wxBrush(m_PressedColourBottom)); dc.DrawRectangle(gradientRect); } dc.SetPen(wxPen(GetBackgroundColour())); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(0, 0, clientRect.GetWidth(), clientRect.GetHeight()); dc.SetFont(GetFont()); dc.SetTextForeground(GetForegroundColour()); if(GetCapture() == this) { clientRect.Offset(1, 1); } dc.DrawLabel(m_Label, clientRect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL); }
void wxStatusBarUniv::DoDraw(wxControlRenderer *renderer) { // get the fields rect wxCoord borderBetweenFields; wxRect rect = GetTotalFieldRect(&borderBetweenFields); // prepare the DC wxDC& dc = renderer->GetDC(); dc.SetFont(GetFont()); dc.SetTextForeground(GetForegroundColour()); // do draw the fields int flags = IsEnabled() ? 0 : (int)wxCONTROL_DISABLED; for ( int n = 0; n < m_nFields; n++ ) { rect.width = m_widthsAbs[n]; if ( IsExposed(rect) ) { wxTopLevelWindow *parentTLW = wxDynamicCast(GetParent(), wxTopLevelWindow); // the size grip may be drawn only on the last field and only if we // have the corresponding style and even then only if we really can // resize this frame if ( n == m_nFields - 1 && HasFlag(wxST_SIZEGRIP) && GetParent()->HasFlag(wxRESIZE_BORDER) && parentTLW && !parentTLW->IsMaximized() ) { flags |= wxCONTROL_SIZEGRIP; } int style; if (m_statusStyles) style = m_statusStyles[n]; else style = wxSB_NORMAL; m_renderer->DrawStatusField(dc, rect, m_statusText[n], flags, style); } rect.x += rect.width + borderBetweenFields; } }
void wxStaticText::OnDraw( wxDC &dc ) { if (m_width <= 0 || m_height <= 0) return; /* dc.Clear() ; wxRect rect(0,0,m_width,m_height) ; dc.SetFont(*wxSMALL_FONT) ; dc.DrawRectangle(rect) ; */ if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) && ( GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) || GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) ) { dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; } else { dc.SetTextForeground( GetForegroundColour() ) ; } wxString paragraph; size_t i = 0 ; wxString text = m_label; int y = 0 ; while (i < text.Length()) { if (text[i] == 13 || text[i] == 10) { DrawParagraph(dc, paragraph,y); paragraph = wxEmptyString ; } else { paragraph += text[i]; } ++i; } if (paragraph.Length() > 0) DrawParagraph(dc, paragraph,y); }
void CSourcesListBox::Update() { //----------------------------------------------------------------------------------// //--- note that the sources box control is now virtual, so we don't ---// //--- add items directly to it. Instead, we have the object pItems a ---// //--- *wxArrayString, that the virtual listctrl then references via callbacks ---// //----------------------------------------------------------------------------------// m_Light = wxListItemAttr( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ), wxNullFont ); // m_LightBold = wxListItemAttr( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ), g_fntListBold ); m_LightBold = wxListItemAttr( GetForegroundColour(), GetBackgroundColour(), g_fntListBold ); m_Dark = wxListItemAttr( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT), StringToColour( wxGetApp().Prefs.sSourcesStripeColour ), wxNullFont ); m_DarkBold = wxListItemAttr( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT), StringToColour( wxGetApp().Prefs.sSourcesStripeColour ), g_fntListBold ); SetItemCount( m_SourcesList.GetCount() ); RescaleColumns(); Refresh(); }
void mmMultiButton::RedrawLabel(wxDC& dc) // Redraw label { int w,h; GetClientSize(&w,&h); int offset = 0; if (mStyle & mmMB_AUTODRAW) if (((mHasFocus && mIsSelected) || mIsToggleDown || mIsWholeDropToggleDown) && !mIsDropToggleDown) offset = 1; int lw=0,lh=0,ext=0; GetTextExtent(mLabelStr,&lw,&lh,&ext); lh += ext; int bmdown_off = 0; /* if (mStyle & mmMB_DROPDOWN) bmdown_off = gDownBM.GetWidth(); */ int x_off = lw + bmdown_off; int y_off = lh + mMarginSize; int x = offset + wxMax(int((w-x_off)/2),int((lw-x_off)/2)) - 1; int y = offset + wxMax(h-y_off,0); dc.SetFont(GetFont()); if (IsEnabled()) { dc.SetTextForeground(GetForegroundColour()); dc.DrawText(mLabelStr, x,y); } else { dc.SetTextForeground(*wxWHITE); dc.DrawText(mLabelStr, x+1,y+1); dc.SetTextForeground(mmDARK_GREY); dc.DrawText(mLabelStr, x,y); dc.SetTextForeground(*wxBLACK); } } // RedrawLabel
WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) { HDC hdc = (HDC)pDC; if ( m_hasFgCol ) { ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour())); } WXHBRUSH hbr = 0; if ( !colBg.Ok() ) { hbr = MSWGetBgBrush(pDC, hWnd); // if the control doesn't have any bg colour, foreground colour will be // ignored as the return value would be 0 -- so forcefully give it a // non default background brush in this case if ( !hbr && m_hasFgCol ) colBg = GetBackgroundColour(); } // use the background colour override if a valid colour is given if ( colBg.Ok() ) { ::SetBkColor(hdc, wxColourToRGB(colBg)); // draw children with the same colour as the parent wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg, wxSOLID); hbr = (WXHBRUSH)brush->GetResourceHandle(); // if we use custom background, we should set foreground ourselves too if ( !m_hasFgCol ) { ::SetTextColor(hdc, ::GetSysColor(COLOR_WINDOWTEXT)); } //else: already set above } return hbr; }
void wxSkinFrame::OnPaint(wxPaintEvent& event) { wxBufferedPaintDC dc(this); /*if( m_sizeMode == 0) {*/ dc.DrawBitmap(m_bmpSkin, 0, 0, true); dc.SetTextForeground(GetForegroundColour()); wxString title = wxTopLevelWindow::GetTitle(); wxCoord w,h; dc.GetTextExtent(title,&w,&h); //dc.DrawRectangle(rect_title); int x,y; y = (rect_title.GetHeight()-h)/2; switch(m_titlePlacement) { case wxTITLE_LEFT: x = rect_title.GetX()+1; break; case wxTITLE_MIDDLE: x = rect_title.GetLeft() + rect_title.GetWidth()/2 - w/2; break; case wxTITLE_RIGHT: x = rect_title.GetRight()-w; } dc.DrawText(title,x,y); /*} else { dc.Clear(); dc.DrawRectangle(GetClientRect()); }*/ }
void TTLabel::OnPaint(wxPaintEvent &event) { wxPaintDC dc(this); #ifdef __WXGTK__ #endif dc.SetBackground(GetBackgroundColour()); dc.Clear(); dc.SetFont(GetFont()); dc.SetTextForeground(GetForegroundColour()); int w, h, tw, th; GetClientSize(&w, &h); dc.GetTextExtent(value, &tw, &th); dc.DrawText(value, w - tw - 2, h / 2 - th / 2); dc.GetTextExtent(unit, &tw, &th); dc.DrawText(unit, 2, h / 2 - th / 2); }
WXHBRUSH wxControl::OnCtlColor(WXHDC hWxDC, WXHWND WXUNUSED(hWnd), WXUINT WXUNUSED(uCtlColor), WXUINT WXUNUSED(uMessage), WXWPARAM WXUNUSED(wParam), WXLPARAM WXUNUSED(lParam)) { HPS hPS = (HPS)hWxDC; // pass in a PS handle in OS/2 wxColour vColFore = GetForegroundColour(); wxColour vColBack = GetBackgroundColour(); if (GetParent()->GetTransparentBackground()) ::GpiSetBackMix(hPS, BM_LEAVEALONE); else ::GpiSetBackMix(hPS, BM_OVERPAINT); ::GpiSetBackColor(hPS, vColBack.GetPixel()); ::GpiSetColor(hPS, vColFore.GetPixel()); wxBrush* pBrush = wxTheBrushList->FindOrCreateBrush( vColBack ,wxSOLID ); return (WXHBRUSH)pBrush->GetResourceHandle(); } // end of wxControl::OnCtlColor
void wxCustomButton::Paint( wxDC &dc ) { #if (wxMINOR_VERSION<8) dc.BeginDrawing(); #endif int w, h; GetSize(&w,&h); wxColour foreColour = GetForegroundColour(); wxColour backColour = GetBackgroundColour(); if (m_focused) { backColour.Set( wxMin(backColour.Red() + 20, 255), wxMin(backColour.Green() + 20, 255), wxMin(backColour.Blue() + 20, 255) ); } wxBitmap bitmap; if (IsEnabled()) { if (GetValue() && m_bmpSelected.Ok()) bitmap = m_bmpSelected; else if (m_focused && m_bmpFocus.Ok()) bitmap = m_bmpFocus; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; } else { // try to create disabled if it doesn't exist if (!m_bmpDisabled.Ok() && m_bmpLabel.Ok()) m_bmpDisabled = CreateBitmapDisabled(m_bmpLabel); if (m_bmpDisabled.Ok()) bitmap = m_bmpDisabled; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; foreColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); } wxBrush brush(backColour, wxSOLID); dc.SetBackground(brush); dc.SetBrush(brush); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(0, 0, w, h); if (bitmap.Ok()) dc.DrawBitmap(bitmap, m_bitmapPos.x, m_bitmapPos.y, TRUE ); if (!GetLabel().IsEmpty()) { dc.SetFont(GetFont()); dc.SetTextBackground(backColour); dc.SetTextForeground(foreColour); dc.DrawText(GetLabel(), m_labelPos.x, m_labelPos.y); } if (GetValue()) // draw sunken border { dc.SetPen(*wxGREY_PEN); dc.DrawLine(0,h-1,0,0); dc.DrawLine(0,0,w,0); dc.SetPen(*wxWHITE_PEN); dc.DrawLine(w-1,1,w-1,h-1); dc.DrawLine(w-1,h-1,0,h-1); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(1,h-2,1,1); dc.DrawLine(1,1,w-1,1); } else if (((m_button_style & wxCUSTBUT_FLAT) == 0) || m_focused) // draw raised border { dc.SetPen(*wxWHITE_PEN); dc.DrawLine(0,h-2,0,0); dc.DrawLine(0,0,w-1,0); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(w-1,0,w-1,h-1); dc.DrawLine(w-1,h-1,-1,h-1); dc.SetPen(*wxGREY_PEN); dc.DrawLine(2,h-2,w-2,h-2); dc.DrawLine(w-2,h-2,w-2,1); } dc.SetBackground(wxNullBrush); dc.SetBrush(wxNullBrush); dc.SetPen(wxNullPen); #if (wxMINOR_VERSION<8) dc.EndDrawing(); #endif }
void wxCustomButton::Paint( wxDC &dc ) { int w, h; GetSize(&w,&h); wxColour foreColour = GetForegroundColour(); wxColour backColour = GetBackgroundColour(); if (m_focused) { backColour.Set( wxMin(backColour.Red() + 20, 255), wxMin(backColour.Green() + 20, 255), wxMin(backColour.Blue() + 20, 255) ); } wxBitmap bitmap; if (IsEnabled()) { if (GetValue() && m_bmpSelected.Ok()) bitmap = m_bmpSelected; else if (m_focused && m_bmpFocus.Ok()) bitmap = m_bmpFocus; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; } else { // try to create disabled if it doesn't exist if (!m_bmpDisabled.Ok() && m_bmpLabel.Ok()) m_bmpDisabled = CreateBitmapDisabled(m_bmpLabel); if (m_bmpDisabled.Ok()) bitmap = m_bmpDisabled; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; foreColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); } #if wxCHECK_VERSION(2, 8, 0) // wxCONTROL_DISABLED //flags may have the wxCONTROL_PRESSED, wxCONTROL_CURRENT or wxCONTROL_ISDEFAULT int ren_flags = 0; if (GetValue()) ren_flags |= wxCONTROL_PRESSED; if (m_focused) ren_flags |= wxCONTROL_CURRENT; if (!IsEnabled()) ren_flags |= wxCONTROL_DISABLED; wxRendererNative::Get().DrawPushButton(this, dc, wxRect(0, 0, w, h), ren_flags); #else wxBrush brush(backColour, wxSOLID); dc.SetBackground(brush); dc.SetBrush(brush); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(0, 0, w, h); #endif // !wxCHECK_VERSION(2, 8, 0) if (bitmap.Ok()) dc.DrawBitmap(bitmap, m_bitmapPos.x, m_bitmapPos.y, true ); if (!GetLabel().IsEmpty()) { dc.SetFont(GetFont()); dc.SetTextBackground(backColour); dc.SetTextForeground(foreColour); dc.DrawText(GetLabel(), m_labelPos.x, m_labelPos.y); } #if !wxCHECK_VERSION(2, 8, 0) if (GetValue()) // draw sunken border { dc.SetPen(*wxGREY_PEN); dc.DrawLine(0,h-1,0,0); dc.DrawLine(0,0,w,0); dc.SetPen(*wxWHITE_PEN); dc.DrawLine(w-1,1,w-1,h-1); dc.DrawLine(w-1,h-1,0,h-1); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(1,h-2,1,1); dc.DrawLine(1,1,w-1,1); } else if (((m_button_style & wxCUSTBUT_FLAT) == 0) || m_focused) // draw raised border { dc.SetPen(*wxWHITE_PEN); dc.DrawLine(0,h-2,0,0); dc.DrawLine(0,0,w-1,0); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(w-1,0,w-1,h-1); dc.DrawLine(w-1,h-1,-1,h-1); dc.SetPen(*wxGREY_PEN); dc.DrawLine(2,h-2,w-2,h-2); dc.DrawLine(w-2,h-2,w-2,1); } #endif // !wxCHECK_VERSION(2, 8, 0) dc.SetBackground(wxNullBrush); dc.SetBrush(wxNullBrush); dc.SetPen(wxNullPen); }