void TimeRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) { wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); wxGridTableBase *table = grid.GetTable(); TimeEditor *te = (TimeEditor *) grid.GetCellEditor(row, col); wxString tstr; if (te) { double value; table->GetValue(row, col).ToDouble(&value); NumericTextCtrl tt(NumericConverter::TIME, &grid, wxID_ANY, te->GetFormat(), value, te->GetRate(), wxPoint(10000, 10000), // create offscreen wxDefaultSize, true); tstr = tt.GetString(); te->DecRef(); } dc.SetBackgroundMode(wxTRANSPARENT); if (grid.IsEnabled()) { if (isSelected) { dc.SetTextBackground(grid.GetSelectionBackground()); dc.SetTextForeground(grid.GetSelectionForeground()); } else { dc.SetTextBackground(attr.GetBackgroundColour()); dc.SetTextForeground(attr.GetTextColour()); } } else { dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } dc.SetFont(attr.GetFont()); int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); grid.DrawTextRectangle(dc, tstr, rect, hAlign, vAlign); }
void wxRibbonMetroArtProvider::DrawPanelBackground( wxDC& dc, wxRibbonPanel* wnd, const wxRect& rect) { DrawPartialPageBackground(dc, wnd, rect, false); wxRect true_rect(rect); RemovePanelPadding(&true_rect); bool has_ext_button = wnd->HasExtButton(); // draw panel label { // int label_height; dc.SetFont(m_panel_label_font); dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetTextForeground(m_panel_label_colour); wxRect label_rect(true_rect); wxString label = wnd->GetLabel(); bool clip_label = false; wxSize label_size(dc.GetTextExtent(label)); label_rect.SetX(label_rect.GetX() + 1); label_rect.SetWidth(label_rect.GetWidth() - 2); label_rect.SetHeight(label_size.GetHeight() + 2); label_rect.SetY(true_rect.GetBottom() - label_rect.GetHeight()); // label_height = label_rect.GetHeight(); wxRect label_bg_rect = label_rect; if(has_ext_button) label_rect.SetWidth(label_rect.GetWidth() - 13); if(label_size.GetWidth() > label_rect.GetWidth()) { // Test if there is enough length for 3 letters and ... wxString new_label = label.Mid(0, 3) + wxT("..."); label_size = dc.GetTextExtent(new_label); if(label_size.GetWidth() > label_rect.GetWidth()) { // Not enough room for three characters and ... // Display the entire label and just crop it clip_label = true; } else { // Room for some characters and ... // Display as many characters as possible and append ... for(size_t len = label.Len() - 1; len >= 3; --len) { new_label = label.Mid(0, len) + wxT("..."); label_size = dc.GetTextExtent(new_label); if(label_size.GetWidth() <= label_rect.GetWidth()) { label = new_label; break; } } } } dc.DrawRectangle(label_bg_rect); if(clip_label) { wxDCClipper clip(dc, label_rect); dc.DrawText(label, label_rect.x, label_rect.y + (label_rect.GetHeight() - label_size.GetHeight()) / 2); } else { dc.DrawText(label, label_rect.x + (label_rect.GetWidth() - label_size.GetWidth()) / 2, label_rect.y + (label_rect.GetHeight() - label_size.GetHeight()) / 2); } if(has_ext_button) { if(wnd->IsExtButtonHovered()) { dc.SetPen(m_panel_hover_button_border_pen); dc.SetBrush(m_panel_hover_button_background_brush); dc.DrawRectangle(label_rect.GetRight(), label_rect.GetBottom() - 14, 14, 14); dc.DrawBitmap(m_panel_extension_bitmap[1], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true); } else dc.DrawBitmap(m_panel_extension_bitmap[0], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true); } } if (wnd->GetParent()->IsKindOf(CLASSINFO(wxFrame))) // expanded panels are in their own wxFrame otherwise normal panel { wxRect shadow(rect); shadow.x +=4; shadow.y +=4; dc.SetPen(*wxRED); dc.DrawLine(shadow.GetBottomLeft(), shadow.GetBottomRight()); dc.DrawLine(shadow.GetTopRight(), shadow.GetBottomRight()); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetPen(m_panel_border_pen); dc.DrawRoundedRectangle(rect, 1.0); } else DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen); }
void wxToolBar::DrawTool( wxDC& rDc, wxToolBarToolBase* pToolBase ) { wxToolBarTool* pTool = (wxToolBarTool *)pToolBase; wxColour gray85( 85,85,85 ); wxPen vDarkGreyPen( gray85, 1, wxSOLID ); wxBitmap vBitmap = pTool->GetNormalBitmap(); bool bUseMask = false; wxMask* pMask = NULL; PrepareDC(rDc); if (!vBitmap.Ok()) return; if ((pMask = vBitmap.GetMask()) != NULL) if (pMask->GetMaskBitmap() != NULLHANDLE) bUseMask = true; if (!pTool->IsToggled()) { LowerTool(pTool, FALSE); if (!pTool->IsEnabled()) { wxColour vColor(wxT("GREY")); rDc.SetTextForeground(vColor); if (!pTool->GetDisabledBitmap().Ok()) pTool->SetDisabledBitmap(wxDisableBitmap( vBitmap ,(long)GetBackgroundColour().GetPixel() )); rDc.DrawBitmap( pTool->GetDisabledBitmap() ,pTool->m_vX ,pTool->m_vY ,bUseMask ); } else { rDc.SetTextForeground(*wxBLACK); rDc.DrawBitmap( vBitmap ,pTool->m_vX ,pTool->m_vY ,bUseMask ); } if (m_windowStyle & wxTB_3DBUTTONS) { RaiseTool(pTool); } if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull()) { wxCoord vX; wxCoord vY; wxCoord vLeft = pTool->m_vX - (int)(pTool->GetWidth()/2); rDc.SetFont(GetFont()); rDc.GetTextExtent( pTool->GetLabel() ,&vX ,&vY ); if (pTool->GetWidth() > vX) // large tools { vLeft = pTool->m_vX + (pTool->GetWidth() - vX); GetSize(&vX, &vY); rDc.DrawText( pTool->GetLabel() ,vLeft ,vY - m_vTextY - 1 ); } else // normal tools { vLeft += (wxCoord)((m_vTextX - vX)/2); rDc.DrawText( pTool->GetLabel() ,vLeft ,pTool->m_vY + m_vTextY - 1 // a bit of margin ); } } } else { wxColour vColor(wxT("GREY")); LowerTool(pTool); rDc.SetTextForeground(vColor); if (!pTool->GetDisabledBitmap().Ok()) pTool->SetDisabledBitmap(wxDisableBitmap( vBitmap ,(long)GetBackgroundColour().GetPixel() )); rDc.DrawBitmap( pTool->GetDisabledBitmap() ,pTool->m_vX ,pTool->m_vY ,bUseMask ); if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull()) { wxCoord vX; wxCoord vY; wxCoord vLeft = pTool->m_vX - (int)(pTool->GetWidth()/2); rDc.SetFont(GetFont()); rDc.GetTextExtent( pTool->GetLabel() ,&vX ,&vY ); vLeft += (wxCoord)((m_vTextX - vX)/2); rDc.DrawText( pTool->GetLabel() ,vLeft ,pTool->m_vY + m_vTextY - 1 // a bit of margin ); } } } // end of wxToolBar::DrawTool
void wxSpeedButton::Paint( wxDC &dc ) { int n; int w,h; wxColour cf; // foreground color wxColour cb; // background color wxColour cg; // gray text wxColour cy; // yellow wxBrush bb; // background brush wxPen pp; // line-drawing pen wxBitmap bmp; wxString s; wxRect rr; // get size and layout if (! mCalcBusy) CalcLayout(false); w = mCurrentSize.GetWidth(); h = mCurrentSize.GetHeight(); // get colors cf = GetForegroundColour(); cb = GetBackgroundColour(); cg = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT ); cy = wxTheColourDatabase->Find(_("YELLOW")); // use wxWidgets to draw the basic button rr.SetX(0); rr.SetY(0); rr.SetWidth(w); rr.SetHeight(h); n = 0; if (mMouseDown || mButtonDown) n = n | wxCONTROL_PRESSED; if (mButtonFocused) n = n | wxCONTROL_ISDEFAULT; wxRendererNative::Get().DrawPushButton(this, dc, rr, n); // track mouse movements with mMouseOver using a dotted yellow line pp = *wxBLACK_PEN; pp.SetColour(cy); // pp.SetStyle(wxDOT); dc.SetPen(pp); if (mMouseOver) { n = 2; dc.DrawLine( n, n, w-n, n); dc.DrawLine(w-n, n, w-n, h-n); dc.DrawLine(w-n, h-n, n, h-n); dc.DrawLine( n, h-n, n, n); }; // select the bitmap to draw if (! IsEnabled()) bmp = mGlyphDisabled; else if (mMouseDown || mButtonDown) bmp = mGlyphDown; else bmp = mGlyphUp; if (bmp.IsOk()) dc.DrawBitmap(bmp, mGlyphPos.x, mGlyphPos.y, true ); // the text label s = GetLabelText(); if (! s.IsEmpty()) { dc.SetFont(GetFont()); dc.SetBackgroundMode(wxTRANSPARENT); if (! IsEnabled()) dc.SetTextForeground(cg); else dc.SetTextForeground(cf); dc.DrawText(s, mLabelPos.x, mLabelPos.y); }; }
void CompDateAxis::DrawSpan(wxDC &dc, wxRect rcAxis, int spanNum, wxString spanLabel, double start, double end) { double winMin, winMax; GetWindowBounds(winMin, winMax); if (end <= winMin || start >= winMax) { return ; // span is not visible } wxCoord spanExtent = GetSpanExtent(dc); wxRect rcSpan; wxCoord minCoord, axisSize; if (IsVertical()) { minCoord = rcAxis.y; axisSize = rcAxis.height; } else { minCoord = rcAxis.x; axisSize = rcAxis.width; } wxCoord gStart, gEnd, gCenter; if (start <= winMin) { gStart = minCoord; } else { gStart = Axis::ToGraphics(dc, minCoord, axisSize, start); } if (end >= winMax) { gEnd = minCoord + axisSize; } else { gEnd = Axis::ToGraphics(dc, minCoord, axisSize, end); } gCenter = Axis::ToGraphics(dc, minCoord, axisSize, (start + end) / 2); if (IsVertical()) { rcSpan.x = rcAxis.x + spanNum * spanExtent; rcSpan.y = gStart; rcSpan.width = spanExtent; rcSpan.height = gEnd - gStart; } else { rcSpan.x = gStart; rcSpan.y = rcAxis.y + spanNum * spanExtent; rcSpan.width = gEnd - gStart; rcSpan.height = spanExtent; } wxDCClipper clipper(dc, rcSpan); m_spanDraw->Draw(dc, rcSpan); int labelCount; wxCoord xIncr, yIncr; wxCoord size; wxCoord labelGap; wxCoord x, y; dc.SetFont(m_labelFont); dc.SetTextForeground(m_labelColour); wxSize textExtent = dc.GetTextExtent(spanLabel); if (IsVertical()) { size = rcSpan.height; labelCount = 1;//size / (textExtent.x + 2 * m_minLabelGap); labelGap = 3 * m_minLabelGap + size / labelCount - textExtent.x; xIncr = 0; yIncr = labelGap; x = rcSpan.x + m_labelMargin; y = rcSpan.y + rcSpan.height - labelGap; } else { size = rcSpan.width; labelCount = 1;//size / (textExtent.x + 2 * m_minLabelGap); labelGap = 3 * m_minLabelGap + size / labelCount - textExtent.x; xIncr = labelGap; yIncr = 0; x = rcSpan.x; y = rcSpan.y + m_labelMargin; } // draw span labels for (int n = 0; n < labelCount; n++) { if (IsVertical()) { dc.DrawRotatedText(spanLabel, x, y, 90); } else { dc.DrawText(spanLabel, x, y); } x += xIncr; y += yIncr; } }
void wxRibbonAUIArtProvider::DrawTab(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRibbonPageTabInfo& tab) { if(tab.rect.height <= 1) return; dc.SetFont(m_tab_label_font); dc.SetPen(*wxTRANSPARENT_PEN); if(tab.active || tab.hovered) { if(tab.active) { dc.SetFont(m_tab_active_label_font); dc.SetBrush(m_background_brush); dc.DrawRectangle(tab.rect.x, tab.rect.y + tab.rect.height - 1, tab.rect.width - 1, 1); } wxRect grad_rect(tab.rect); grad_rect.height -= 4; grad_rect.width -= 1; grad_rect.height /= 2; grad_rect.y = grad_rect.y + tab.rect.height - grad_rect.height - 1; dc.SetBrush(m_tab_active_top_background_brush); dc.DrawRectangle(tab.rect.x, tab.rect.y + 3, tab.rect.width - 1, grad_rect.y - tab.rect.y - 3); dc.GradientFillLinear(grad_rect, m_tab_active_background_colour, m_tab_active_background_gradient_colour, wxSOUTH); } else { wxRect btm_rect(tab.rect); btm_rect.height -= 4; btm_rect.width -= 1; btm_rect.height /= 2; btm_rect.y = btm_rect.y + tab.rect.height - btm_rect.height - 1; dc.SetBrush(m_tab_hover_background_brush); dc.DrawRectangle(btm_rect.x, btm_rect.y, btm_rect.width, btm_rect.height); wxRect grad_rect(tab.rect); grad_rect.width -= 1; grad_rect.y += 3; grad_rect.height = btm_rect.y - grad_rect.y; dc.GradientFillLinear(grad_rect, m_tab_hover_background_top_colour, m_tab_hover_background_top_gradient_colour, wxSOUTH); } wxPoint border_points[5]; border_points[0] = wxPoint(0, 3); border_points[1] = wxPoint(1, 2); border_points[2] = wxPoint(tab.rect.width - 3, 2); border_points[3] = wxPoint(tab.rect.width - 1, 4); border_points[4] = wxPoint(tab.rect.width - 1, tab.rect.height - 1); dc.SetPen(m_tab_border_pen); dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y); wxRect old_clip; dc.GetClippingBox(old_clip); bool is_first_tab = false; wxRibbonBar* bar = wxDynamicCast(tab.page->GetParent(), wxRibbonBar); if(bar && bar->GetPage(0) == tab.page) is_first_tab = true; wxBitmap icon; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) { icon = tab.page->GetIcon(); if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) { if(icon.IsOk()) { int x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - icon.GetHeight()) / 2, true); } } } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) { wxString label = tab.page->GetLabel(); if(!label.IsEmpty()) { dc.SetTextForeground(m_tab_label_colour); dc.SetBackgroundMode(wxTRANSPARENT); int offset = 0; if(icon.IsOk()) offset += icon.GetWidth() + 2; int text_height; int text_width; dc.GetTextExtent(label, &text_width, &text_height); int x = (tab.rect.width - 2 - text_width - offset) / 2; if(x > 8) x = 8; else if(x < 1) x = 1; int width = tab.rect.width - x - 2; x += tab.rect.x + offset; int y = tab.rect.y + (tab.rect.height - text_height) / 2; if(icon.IsOk()) { dc.DrawBitmap(icon, x - offset, tab.rect.y + (tab.rect.height - icon.GetHeight()) / 2, true); } dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height); dc.DrawText(label, x, y); } } // Draw the left hand edge of the tab only for the first tab (subsequent // tabs use the right edge of the prior tab as their left edge). As this is // outside the rectangle for the tab, only draw it if the leftmost part of // the tab is within the clip rectangle (the clip region has to be cleared // to draw outside the tab). if(is_first_tab && old_clip.x <= tab.rect.x && tab.rect.x < old_clip.x + old_clip.width) { dc.DestroyClippingRegion(); dc.DrawLine(tab.rect.x - 1, tab.rect.y + 4, tab.rect.x - 1, tab.rect.y + tab.rect.height - 1); } }
void wxRibbonAUIArtProvider::DrawPartialPanelBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_background_brush); dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); wxPoint offset(wnd->GetPosition()); wxWindow* parent = wnd->GetParent(); wxRibbonPanel* panel = NULL; for(; parent; parent = parent->GetParent()) { panel = wxDynamicCast(parent, wxRibbonPanel); if(panel != NULL) { if(!panel->IsHovered()) return; break; } offset += parent->GetPosition(); } if(panel == NULL) return; wxRect background(panel->GetSize()); RemovePanelPadding(&background); background.x++; background.width -= 2; dc.SetFont(m_panel_label_font); int caption_height = dc.GetTextExtent(panel->GetLabel()).GetHeight() + 7; background.y += caption_height - 1; background.height -= caption_height; wxRect paint_rect(rect); paint_rect.x += offset.x; paint_rect.y += offset.y; wxColour bg_clr, bg_grad_clr; #ifdef __WXMAC__ bg_grad_clr = m_page_hover_background_colour; bg_clr = m_page_hover_background_gradient_colour; #else bg_clr = m_page_hover_background_colour; bg_grad_clr = m_page_hover_background_gradient_colour; #endif paint_rect.Intersect(background); if(!paint_rect.IsEmpty()) { wxColour starting_colour(wxRibbonInterpolateColour(bg_clr, bg_grad_clr, paint_rect.y, background.y, background.y + background.height)); wxColour ending_colour(wxRibbonInterpolateColour(bg_clr, bg_grad_clr, paint_rect.y + paint_rect.height, background.y, background.y + background.height)); paint_rect.x -= offset.x; paint_rect.y -= offset.y; dc.GradientFillLinear(paint_rect, starting_colour, ending_colour , wxSOUTH); } }
void CtrlRegisterList::render(wxDC& dc) { #ifdef WIN32 wxFont font = wxFont(wxSize(charWidth,rowHeight-2),wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console"); #else wxFont font = wxFont(8,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console"); font.SetPixelSize(wxSize(charWidth,rowHeight-2)); #endif dc.SetFont(font); // clear background wxColor white = wxColor(0xFFFFFFFF); dc.SetBrush(wxBrush(white)); dc.SetPen(wxPen(white)); wxSize size = GetSize(); dc.DrawRectangle(0,0,size.x,size.y); refreshChangedRegs(); wxColor colorChanged = wxColor(0xFF0000FF); wxColor colorUnchanged = wxColor(0xFF004000); wxColor colorNormal = wxColor(0xFF600000); // draw categories int piece = size.x/cpu->getRegisterCategoryCount(); for (int i = 0; i < cpu->getRegisterCategoryCount(); i++) { const char* name = cpu->getRegisterCategoryName(i); int x = i*piece; if (i == category) { dc.SetBrush(wxBrush(wxColor(0xFF70FF70))); dc.SetPen(wxPen(wxColor(0xFF000000))); } else { dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8))); dc.SetPen(wxPen(wxColor(0xFF000000))); } dc.DrawRectangle(x-1,-1,piece+1,rowHeight+1); // center text x += (piece-strlen(name)*charWidth)/2; dc.DrawText(wxString(name,wxConvUTF8),x,1); } int nameStart = 17; int valueStart = startPositions[category]; ChangedReg* changedRegs = changedCategories[category]; int registerBits = cpu->getRegisterSize(category); DebugInterface::RegisterType type = cpu->getRegisterType(category); for (int i = 0; i < cpu->getRegisterCount(category); i++) { int x = valueStart; int y = rowHeight*(i+1); if (currentRows[category] == i) { dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8))); dc.SetPen(wxPen(wxColor(0xFFFFEFE8))); dc.DrawRectangle(0,y,size.x,rowHeight); } const char* name = cpu->getRegisterName(category,i); dc.SetTextForeground(colorNormal); dc.DrawText(wxString(name,wxConvUTF8),nameStart,y+2); u128 value = cpu->getRegister(category,i); ChangedReg& changed = changedRegs[i]; switch (type) { case DebugInterface::NORMAL: // display them in 32 bit parts switch (registerBits) { case 128: { int startIndex = std::min<int>(3,maxBits/32-1); int actualX = size.x-4-(startIndex+1)*(8*charWidth+2); x = std::max<int>(actualX,x); if (startIndex != 3) { bool c = false; for (int i = 3; i > startIndex; i--) c = c || changed.changed[i]; if (c) { dc.SetTextForeground(colorChanged); dc.DrawText(L"+",x-charWidth,y+2); } } for (int i = startIndex; i >= 0; i--) { if (changed.changed[i]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[i],x,y+2); x += charWidth*8+2; } break; } case 64: { if (maxBits < 64 && changed.changed[1]) { dc.SetTextForeground(colorChanged); dc.DrawText(L"+",x-charWidth,y+2); } for (int i = 1; i >= 0; i--) { if (changed.changed[i]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[i],x,y+2); x += charWidth*8+2; } break; } case 32: { if (changed.changed[0]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[0],x,y+2); break; } } break; case DebugInterface::SPECIAL: // let debug interface format them and just display them { if (changed.changed[0] || changed.changed[1] || changed.changed[2] || changed.changed[3]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); dc.DrawText(cpu->getRegisterString(category,i),x,y+2); break; } } } }
void ChipPackage::DrawPins(wxDC& dc, const wxPoint& pt, unsigned int PackageLen, unsigned int FirstPin, unsigned int LastPin, int flags, wxDirection dir) { wxASSERT_MSG(LastPin>FirstPin, "invalid pin indexes"); // NOTE: inside this function context // pin number == the index of the pin (e.g. "1", "2", etc) // pin name == pin label == the name of the pin signal (e.g. "VCC", "GND" etc) // pin == pin rectangle // some drawing constants: const unsigned int PinCount = LastPin - FirstPin; // pin height is calculated imposing that // 1) PinCount*PinH + (PinCount+1)*PinSpacing = PackageLen // 2) PinSpacing = PinH/2 // solving for PinH yields: unsigned int PinH = (unsigned int)floor(2*PackageLen/(3.0*PinCount+1)); unsigned int PinW = (unsigned int)1.5*PinH; const unsigned int PinSpacing = (const unsigned int)floor(PinH/2.0); // the error which force us to have a "pin y offset" is caused by rounding // in the calculation of PinH: const int PinOffset = (PackageLen - (PinCount*PinH + (PinCount+1)*PinSpacing))/2; wxASSERT(PinOffset>=0); if (int(PinH*0.8) == 0) return; // this happens for very small package sizes; // the check avoids an assertion failure from wxFont ctor // select a font suitable for the PinH we have computed above: int fSize = int(PinH*0.8); if(fSize>12)fSize=12; wxFont fnt(wxSize(0,fSize), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); dc.SetFont(fnt); const unsigned int PinNumberW = 2*dc.GetCharWidth(); const unsigned int PinNumberH = dc.GetCharHeight(); bool invertOrder = (flags & DRAWPIN_INVERTED_ORDER) != 0; unsigned int start = invertOrder ? LastPin-1 : FirstPin; unsigned int end = invertOrder ? FirstPin-1 : LastPin; int inc = invertOrder ? -1 : +1; if (dir == wxLEFT || dir == wxRIGHT) { unsigned int PinX = (dir == wxLEFT) ? pt.x-PinW+1 : pt.x-1; unsigned int PinY = pt.y + PinOffset + PinSpacing; unsigned int PinNumberX = (dir == wxLEFT) ? pt.x+PinSpacing : pt.x-PinNumberW-PinSpacing; if (flags & DRAWPIN_NUMBERS_INSIDE_PINS) PinNumberX = PinX + (PinW-PinNumberW)/2; // draw the pins organizing them in a vertical column for (unsigned int i=start; i != end; i+=inc) { unsigned int PinNumberY = PinY + (PinH-PinNumberH)/2; unsigned int pinLabelX = (dir == wxLEFT) ? PinX-PinSpacing-dc.GetTextExtent(PinNames[i]).GetWidth() : PinX+PinW+PinSpacing; unsigned int pinLabelY = PinNumberY; // draw the pin rect dc.DrawRectangle(PinX, PinY, PinW, PinH); // print the pin number dc.SetTextForeground(IsICSPPin(i) ? *wxRED : *wxBLACK); dc.DrawText(wxString::Format(("%d"), i+1), PinNumberX, PinNumberY); // print the pin name dc.DrawText(PinNames[i], pinLabelX, pinLabelY); PinY += PinH+PinSpacing; } } else if (dir == wxTOP || dir == wxBOTTOM) { SWAP(PinH, PinW, unsigned int); // in this case the PackageLen is the number of horizontal pixels available // for drawing the pin strip; thus we want to compute PinW and set PinH // VERY IMPORTANT: the code below is the dual of the code for wxLEFT|wxRIGHT case! // If you change something here, you may want to change it also // above, with the appropriate differences // NOTE: remember however that the text is drawn rotated by 90 degrees unsigned int PinX = pt.x + PinOffset + PinSpacing; unsigned int PinY = (dir == wxTOP) ? pt.y-PinH+1 : pt.y-1; unsigned int PinNumberY = (dir == wxTOP) ? pt.y+PinSpacing : pt.y-PinNumberH-PinSpacing; if (flags & DRAWPIN_NUMBERS_INSIDE_PINS) PinNumberY = PinY + (PinH-PinNumberW)/2; // draw the pins organizing them in a horizontal column for (unsigned int i=start; i != end; i+=inc) { unsigned int PinNumberX = PinX + PinNumberH + (PinW-PinNumberH)/2; unsigned int pinLabelX = PinNumberX; unsigned int pinLabelY = (dir == wxTOP) ? PinY-PinSpacing-dc.GetTextExtent(PinNames[i]).GetWidth() : PinY+PinH+PinSpacing; // draw the pin rect dc.DrawRectangle(PinX, PinY, PinW, PinH); // print the pin number dc.SetTextForeground(IsICSPPin(i) ? *wxRED : *wxBLACK); dc.DrawRotatedText(wxString::Format(("%d"), i+1), PinNumberX, PinNumberY, -90); // print the pin name dc.DrawRotatedText(PinNames[i], pinLabelX, pinLabelY, -90); PinX += PinW+PinSpacing; } } else wxLogWarning(_("Invalid direction")); }
void SeqDNA::show ( wxDC& dc ) { if ( useDirectRoutines() ) { show_direct ( dc ) ; return ; } dc.SetFont(*can->font); wxColour tbg = dc.GetTextBackground () ; wxColour tfg = dc.GetTextForeground () ; int bm = dc.GetBackgroundMode () ; int a , b , cnt = offset+1 ; wxString t ; char u[100] , valid[256] ; for ( a = 0 ; a < 256 ; a++ ) valid[a] = 0 ; valid['A'] = valid['C'] = valid['T'] = valid['G'] = valid[' '] = 1 ; // dc.SetTextBackground ( *wxWHITE ) ; dc.SetTextForeground ( fontColor ) ; // dc.SetBackgroundMode ( wxSOLID ) ; dc.SetBackgroundMode ( wxTRANSPARENT ) ; int xa , ya , yb ; dc.GetDeviceOrigin ( &xa , &ya ) ; ya = -ya ; can->MyGetClientSize ( &xa , &yb ) ; yb += ya ; for ( a = 0 ; a < pos.p.GetCount() ; a++ ) { if ( can->hardstop > -1 && a > can->hardstop ) break ; b = pos.p[a] ; int tx = pos.r[a].x , ty = pos.r[a].y ; int tz = ty + can->charheight ; bool insight = true ; // Meaning "is this part visible" if ( tz < ya ) insight = false ; if ( ty > yb ) insight = false ; if ( can->getDrawAll() ) insight = true ; if ( !insight && ty > yb ) a = pos.p.GetCount() ; if ( b > 0 && !insight ) cnt++ ; if ( b > 0 && insight ) // Character { t = s.GetChar(b-1) ; int pm = getMark ( a ) ; if ( pm == 1 ) // Marked (light gray background) { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxLIGHT_GREY ) ; dc.SetTextForeground ( *wxBLACK ) ; } else if ( pm == 2 && can->doOverwrite() ) // Overwrite cursor { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxBLACK ) ; } if ( pm == 2 && can->doOverwrite() ) dc.SetTextForeground ( *wxWHITE ) ; else dc.SetTextForeground ( getBaseColor ( t.GetChar(0) ) ) ; if ( can->isPrinting() && pm == 1 ) { dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ; dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle ( tx , ty , can->charwidth , can->charheight ) ; } if ( can->isPrinting() && !can->getPrintToColor() ) { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( *wxBLACK ) ; } dc.DrawText ( t , tx , ty ) ; if ( pm == 2 && !can->doOverwrite() ) // Insert cursor { dc.SetPen(*wxBLACK_PEN); dc.DrawLine ( tx-1 , ty , tx-1 , tz ) ; dc.DrawLine ( tx-3 , ty , tx+2 , ty ) ; dc.DrawLine ( tx-3 , tz , tx+2 , tz ) ; } if ( pm > 0 ) // Reverting cursor settings { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( fontColor ) ; } cnt++ ; } else if ( insight ) // Front number { if ( showNumbers ) { //sprintf ( u , "%d" , cnt ) ; //t = u ; t = wxString::Format ( _T("%d") , cnt ) ; while ( t.length() < endnumberlength ) t = _T("0") + t ; } else t = alternateName ; dc.SetTextForeground ( *wxBLACK ) ; dc.DrawText ( t , pos.r[a].x, pos.r[a].y ) ; } } dc.SetBackgroundMode ( bm ) ; dc.SetTextBackground ( tbg ) ; dc.SetTextForeground ( tfg ) ; }
void SeqDNA::show_direct ( wxDC& dc ) { myass ( itemsperline , "DNA:show_direct_ipl" ) ; if ( !itemsperline ) return ; myass ( can , "SeqDNA::show_direct1" ) ; can->SetFont(*can->font); dc.SetFont(*can->font); int a , b , w , h , n , bo = can->border ; int csgc = can->NumberOfLines() , cbs = can->blocksize ; int cih = can->isHorizontal() ; int xa , xb , ya , yb ; for ( n = 0 ; n < can->seq.GetCount() && can->seq[n] != this ; n++ ) ; if ( n == can->seq.GetCount() ) return ; // Setting basic values int cw = can->charwidth , ch = can->charheight ; int ox = bo + cw + cw * endnumberlength ; int oy = n*ch+bo ; bool isPrimer = false ; if ( whatsthis().StartsWith ( _T("PRIMER") ) ) isPrimer = true ; can->MyGetClientSize ( &w , &h ) ; xb = w ; yb = h ; wxColour tbg = dc.GetTextBackground () ; wxColour tfg = dc.GetTextForeground () ; int bm = dc.GetBackgroundMode () ; dc.SetTextForeground ( fontColor ) ; dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.GetDeviceOrigin ( &xa , &ya ) ; xa = -xa ; xb += xa ; ya = -ya ; yb += ya ; myass ( ch , "SeqDNA::show_direct2a" ) ; myass ( csgc , "SeqDNA::show_direct2b" ) ; b = ( ya - ch - oy ) / ( ch * csgc ) * itemsperline ; for ( a = 0 ; a < b && a < s.length() ; a += itemsperline ) ; myass ( itemsperline , "SeqDNA::show_direct3" ) ; myass ( cbs , "SeqDNA::show_direct4" ) ; for ( a = 0 ; a < s.length() ; a++ ) { int px = a % itemsperline , py = a / itemsperline ; bool showNumber = ( px == 0 ) ; px = px * cw + ( px / cbs ) * ( cw - 1 ) + ox ; py = py * ch * csgc + oy ; if ( !can->getDrawAll() ) { if ( py + ch < ya ) continue ; if ( py > yb ) break ; if ( cih ) { if ( px + cw < xa ) continue ; if ( px > xb ) continue ; } } int pm = getMark ( a ) ; char ac = s.GetChar(a) ; if ( pm == 0 && !showNumber && ac == ' ' ) continue ; if ( pm == 1 ) // Marked (light gray background) { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxLIGHT_GREY ) ; dc.SetTextForeground ( *wxBLACK ) ; } else if ( pm == 2 && can->doOverwrite() ) // Overwrite cursor { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxBLACK ) ; dc.SetTextForeground ( *wxWHITE ) ; } else dc.SetTextForeground ( getHighlightColor ( a , getBaseColor ( ac ) ) ) ; if ( isPrimer ) { if ( s.GetChar(a) == vec->getSequenceChar(a) ) dc.SetTextForeground ( *wxBLUE ) ; else dc.SetTextForeground ( *wxRED ) ; } if ( can->isPrinting() && pm == 1 ) { dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ; dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle ( px , py , cw , ch ) ; } if ( can->isPrinting() && !can->getPrintToColor() ) { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( *wxBLACK ) ; } dc.DrawText ( wxString ( (wxChar) ac ) , px , py ) ; int pz = py + ch ; if ( pm == 2 && !can->doOverwrite() ) // Insert cursor { dc.SetPen(*wxBLACK_PEN); dc.DrawLine ( px-1 , py , px-1 , pz ) ; dc.DrawLine ( px-3 , py , px+2 , py ) ; dc.DrawLine ( px-3 , pz , px+2 , pz ) ; } if ( pm > 0 ) // Reverting cursor settings { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( fontColor ) ; } // Methylation if ( !invers && alternateName.IsEmpty() && wxNOT_FOUND != vec->getMethylationSiteIndex ( a ) ) { dc.SetPen(*wxRED_PEN); dc.DrawLine ( px , py + ch - 2 , px + cw , py + ch - 2 ) ; dc.SetPen(*wxTRANSPARENT_PEN); } if ( showNumber ) { dc.SetTextBackground ( tbg ) ; dc.SetTextForeground ( tfg ) ; mylog ( "SeqDNA::show_direct" , "A" ) ; wxString t ; if ( showNumbers ) { mylog ( "SeqDNA::show_direct" , "B" ) ; t = wxString::Format ( _T("%d") , a + 1 ) ; int padd = endnumberlength - t.length() ; mylog ( "SeqDNA::show_direct" , wxString::Format ( "C: %d, %d" , endnumberlength , padd ) ) ; if ( padd > 0 && padd < 20 ) t.Pad ( padd , '0' , false ) ; mylog ( "SeqDNA::show_direct" , "D" ) ; } else { mylog ( "SeqDNA::show_direct" , "B2" ) ; if ( isPrimer ) dc.SetTextForeground ( *wxBLUE ) ; else dc.SetTextForeground ( *wxBLACK ) ; mylog ( "SeqDNA::show_direct" , "C2" ) ; t = alternateName ; mylog ( "SeqDNA::show_direct" , "D2" ) ; } dc.DrawText ( t , bo , py ) ; mylog ( "SeqDNA::show_direct" , "E" ) ; } } dc.SetBackgroundMode ( bm ) ; dc.SetTextBackground ( tbg ) ; dc.SetTextForeground ( tfg ) ; }
// Define the repainting behaviour void MyCanvas::OnDraw(wxDC& dc) { // vars to use ... #if wxUSE_STATUSBAR wxString s; #endif // wxUSE_STATUSBAR wxPen wP; wxBrush wB; wxPoint points[6]; wxColour wC; wxFont wF; dc.SetFont(*wxSWISS_FONT); dc.SetPen(*wxGREEN_PEN); switch (m_index) { default: case 0: // draw lines to make a cross dc.DrawLine(0, 0, 200, 200); dc.DrawLine(200, 0, 0, 200); // draw point colored line and spline wP = *wxCYAN_PEN; wP.SetWidth(3); dc.SetPen(wP); dc.DrawPoint (25,15); dc.DrawLine(50, 30, 200, 30); dc.DrawSpline(50, 200, 50, 100, 200, 10); #if wxUSE_STATUSBAR s = wxT("Green Cross, Cyan Line and spline"); #endif // wxUSE_STATUSBAR break; case 1: // draw standard shapes dc.SetBrush(*wxCYAN_BRUSH); dc.SetPen(*wxRED_PEN); dc.DrawRectangle(10, 10, 100, 70); wB = wxBrush (wxT("DARK ORCHID"), wxBRUSHSTYLE_TRANSPARENT); dc.SetBrush (wB); dc.DrawRoundedRectangle(50, 50, 100, 70, 20); dc.SetBrush (wxBrush(wxT("GOLDENROD")) ); dc.DrawEllipse(100, 100, 100, 50); points[0].x = 100; points[0].y = 200; points[1].x = 70; points[1].y = 260; points[2].x = 160; points[2].y = 230; points[3].x = 40; points[3].y = 230; points[4].x = 130; points[4].y = 260; points[5].x = 100; points[5].y = 200; dc.DrawPolygon(5, points); dc.DrawLines (6, points, 160); #if wxUSE_STATUSBAR s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars"); #endif // wxUSE_STATUSBAR break; case 2: // draw text in Arial or similar font dc.DrawLine(50,25,50,35); dc.DrawLine(45,30,55,30); dc.DrawText(wxT("This is a Swiss-style string"), 50, 30); wC = dc.GetTextForeground(); dc.SetTextForeground (wxT("FIREBRICK")); // no effect in msw ?? dc.SetTextBackground (wxT("WHEAT")); dc.DrawText(wxT("This is a Red string"), 50, 200); dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45); dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90); wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman")); dc.SetFont(wF); dc.SetTextForeground (wC); dc.DrawText(wxT("This is a Times-style string"), 50, 60); #if wxUSE_STATUSBAR s = wxT("Swiss, Times text; red text, rotated and colored orange"); #endif // wxUSE_STATUSBAR break; case 3 : // four arcs start and end points, center dc.SetBrush(*wxGREEN_BRUSH); dc.DrawArc ( 200,300, 370,230, 300,300 ); dc.SetBrush(*wxBLUE_BRUSH); dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 ); dc.SetDeviceOrigin(-10,-10); dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 ); dc.SetDeviceOrigin(0,0); wP.SetColour (wxT("CADET BLUE")); dc.SetPen(wP); dc.DrawArc ( 75,125, 110, 40, 75, 75 ); wP.SetColour (wxT("SALMON")); dc.SetPen(wP); dc.SetBrush(*wxRED_BRUSH); //top left corner, width and height, start and end angle // 315 same center and x-radius as last pie-arc, half Y radius dc.DrawEllipticArc(25,50,100,50,180.0,45.0); wP = *wxCYAN_PEN; wP.SetWidth(3); dc.SetPen(wP); //wxTRANSPARENT)); dc.SetBrush (wxBrush (wxT("SALMON"))); dc.DrawEllipticArc(300, 0,200,100, 0.0,145.0); //same end point dc.DrawEllipticArc(300, 50,200,100,90.0,145.0); dc.DrawEllipticArc(300,100,200,100,90.0,345.0); #if wxUSE_STATUSBAR s = wxT("This is an arc test page"); #endif // wxUSE_STATUSBAR break; case 4: dc.DrawCheckMark ( 30,30,25,25); dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT)); dc.DrawCheckMark ( 80,50,75,75); dc.DrawRectangle ( 80,50,75,75); #if wxUSE_STATUSBAR s = wxT("Two check marks"); #endif // wxUSE_STATUSBAR break; case 5: wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman")); dc.SetFont(wF); dc.DrawLine(0, 0, 200, 200); dc.DrawLine(200, 0, 0, 200); dc.DrawText(wxT("This is an 18pt string"), 50, 60); // rescale and draw in blue wP = *wxCYAN_PEN; dc.SetPen(wP); dc.SetUserScale (2.0,0.5); dc.SetDeviceOrigin(200,0); dc.DrawLine(0, 0, 200, 200); dc.DrawLine(200, 0, 0, 200); dc.DrawText(wxT("This is an 18pt string 2 x 0.5 UserScaled"), 50, 60); dc.SetUserScale (2.0,2.0); dc.SetDeviceOrigin(200,200); dc.DrawText(wxT("This is an 18pt string 2 x 2 UserScaled"), 50, 60); wP = *wxRED_PEN; dc.SetPen(wP); dc.SetUserScale (1.0,1.0); dc.SetDeviceOrigin(0,10); dc.SetMapMode (wxMM_METRIC); //svg ignores this dc.DrawLine(0, 0, 200, 200); dc.DrawLine(200, 0, 0, 200); dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60); #if wxUSE_STATUSBAR s = wxT("Scaling test page"); #endif // wxUSE_STATUSBAR break; case 6: dc.DrawIcon( wxICON(sample), 10, 10 ); dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15); #if wxUSE_STATUSBAR s = wxT("Icon and Bitmap "); #endif // wxUSE_STATUSBAR break; case 7: dc.SetTextForeground(wxT("RED")); dc.DrawText(wxT("Red = Clipping Off"), 30, 5); dc.SetTextForeground(wxT("GREEN")); dc.DrawText(wxT("Green = Clipping On"), 30, 25); dc.SetTextForeground(wxT("BLACK")); dc.SetPen(*wxRED_PEN); dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT)); dc.DrawCheckMark ( 80,50,75,75); dc.DrawRectangle ( 80,50,75,75); dc.SetPen(*wxGREEN_PEN); // Clipped checkmarks dc.DrawRectangle(180,50,75,75); dc.SetClippingRegion(180,50,75,75); // x,y,width,height version dc.DrawCheckMark ( 180,50,75,75); dc.DestroyClippingRegion(); dc.DrawRectangle(wxRect(80,150,75,75)); dc.SetClippingRegion(wxPoint(80,150),wxSize(75,75)); // pt,size version dc.DrawCheckMark ( 80,150,75,75); dc.DestroyClippingRegion(); dc.DrawRectangle(wxRect(180,150,75,75)); dc.SetClippingRegion(wxRect(180,150,75,75)); // rect version dc.DrawCheckMark ( 180,150,75,75); dc.DestroyClippingRegion(); dc.DrawRectangle(wxRect( 80,250,50,65)); dc.DrawRectangle(wxRect(105,260,50,65)); dc.SetClippingRegion(wxRect( 80,250,50,65)); // second call to SetClippingRegion dc.SetClippingRegion(wxRect(105,260,50,65)); // forms intersection with previous dc.DrawCheckMark(80,250,75,75); dc.DestroyClippingRegion(); // only one call to destroy (there's no stack) /* ** Clipping by wxRegion not implemented for SVG. Should be ** possible, but need to access points that define the wxRegion ** from inside DoSetDeviceClippingRegion() and wxRegion does not ** implement anything like getPoints(). points[0].x = 180; points[0].y = 250; points[1].x = 255; points[1].y = 250; points[2].x = 180; points[2].y = 325; points[3].x = 255; points[3].y = 325; points[4].x = 180; points[4].y = 250; dc.DrawLines (5, points); wxRegion reg = wxRegion(5,points); dc.SetClippingRegion(reg); dc.DrawCheckMark ( 180,250,75,75); dc.DestroyClippingRegion(); */ #if wxUSE_STATUSBAR s = wxT("Clipping region"); #endif // wxUSE_STATUSBAR break; case 8: wxString txtStr; wxCoord txtX, txtY, txtW, txtH, txtDescent, txtEL; wxCoord txtPad = 0; wP = *wxRED_PEN; dc.SetPen(wP); //dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); //dc.SetTextBackground(*wxBLUE); // Horizontal text txtStr = wxT("Horizontal string"); dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL); txtX = 50; txtY = 300; dc.DrawRectangle(txtX, txtY, txtW + 2*txtPad, txtH + 2*txtPad); dc.DrawText(txtStr, txtX + txtPad, txtY + txtPad); // Vertical text txtStr = wxT("Vertical string"); dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL); txtX = 50; txtY = 250; dc.DrawRectangle(txtX, txtY - (txtW + 2*txtPad), txtH + 2*txtPad, txtW + 2*txtPad); dc.DrawRotatedText(txtStr, txtX + txtPad, txtY - txtPad, 90); // 45 degree text txtStr = wxT("45 deg string"); dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL); double lenW = (double)(txtW + 2*txtPad) / sqrt(2.0); double lenH = (double)(txtH + 2*txtPad) / sqrt(2.0); double padding = (double)txtPad / sqrt(2.0); txtX = 150; txtY = 200; dc.DrawLine(txtX - padding, txtY, txtX + lenW, txtY - lenW); // top dc.DrawLine(txtX + lenW, txtY - lenW, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); dc.DrawLine(txtX - padding, txtY, txtX - padding + lenH, txtY + lenH); dc.DrawLine(txtX - padding + lenH, txtY + lenH, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); // bottom dc.DrawRotatedText(txtStr, txtX, txtY, 45); #if wxUSE_STATUSBAR s = wxT("Text position test page"); #endif // wxUSE_STATUSBAR break; } #if wxUSE_STATUSBAR m_child->SetStatusText(s); #endif // wxUSE_STATUSBAR }
////////////// // Draw image void BaseGrid::DrawImage(wxDC &dc) { dc.BeginDrawing(); // Get size and pos int w = 0; int h = 0; GetClientSize(&w,&h); // Set font dc.SetFont(font); // Clear background dc.SetBackground(wxBrush(Options.AsColour(_T("Grid Background")))); dc.Clear(); // Draw labels dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(Options.AsColour(_T("Grid left column")))); dc.DrawRectangle(0,lineHeight,colWidth[0],h-lineHeight); // Visible lines int drawPerScreen = h/lineHeight + 1; int nDraw = MID(0,drawPerScreen,GetRows()-yPos); int maxH = (nDraw+1) * lineHeight; // Row colors std::vector<wxBrush> rowColors; std::vector<wxColor> foreColors; rowColors.push_back(wxBrush(Options.AsColour(_T("Grid Background")))); // 0 = Standard foreColors.push_back(Options.AsColour(_T("Grid standard foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid Header")))); // 1 = Header foreColors.push_back(Options.AsColour(_T("Grid standard foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selection background")))); // 2 = Selected foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid comment background")))); // 3 = Commented foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid inframe background")))); // 4 = Video Highlighted foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selected comment background")))); // 5 = Commented & selected foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); // First grid row bool drawGrid = true; if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); dc.DrawLine(0,0,w,0); dc.SetPen(*wxTRANSPARENT_PEN); } // Draw rows int dx = 0; int dy = 0; int curColor = 0; AssDialogue *curDiag; for (int i=0;i<nDraw+1;i++) { // Prepare int curRow = i+yPos-1; curDiag = GetDialogue(curRow); dx = 0; dy = i*lineHeight; // Check for collisions bool collides = false; if (curDiag) { AssDialogue *sel = GetDialogue(editBox->linen); if (sel && sel != curDiag) { if (curDiag->CollidesWith(sel)) collides = true; } } // Text array wxArrayString strings; // Header if (i == 0) { strings.Add(_("#")); strings.Add(_("L")); strings.Add(_("Start")); strings.Add(_("End")); strings.Add(_("Style")); strings.Add(_("Actor")); strings.Add(_("Effect")); strings.Add(_("Left")); strings.Add(_("Right")); strings.Add(_("Vert")); strings.Add(_("Text")); curColor = 1; } // Lines else if (curDiag) { // Set fields strings.Add(wxString::Format(_T("%i"),curRow+1)); strings.Add(wxString::Format(_T("%i"),curDiag->Layer)); if (byFrame) { strings.Add(wxString::Format(_T("%i"),VFR_Output.GetFrameAtTime(curDiag->Start.GetMS(),true))); strings.Add(wxString::Format(_T("%i"),VFR_Output.GetFrameAtTime(curDiag->End.GetMS(),true))); } else { strings.Add(curDiag->Start.GetASSFormated()); strings.Add(curDiag->End.GetASSFormated()); } strings.Add(curDiag->Style); strings.Add(curDiag->Actor); strings.Add(curDiag->Effect); strings.Add(curDiag->GetMarginString(1)); strings.Add(curDiag->GetMarginString(2)); strings.Add(curDiag->GetMarginString(3)); // Set text int mode = Options.AsInt(_T("Grid Hide Overrides")); wxString value = _T(""); // Hidden overrides if (mode == 1 || mode == 2) { wxString replaceWith = Options.AsText(_T("Grid hide overrides char")); curDiag->ParseASSTags(); size_t n = curDiag->Blocks.size(); for (size_t i=0;i<n;i++) { AssDialogueBlock *block = curDiag->Blocks.at(i); AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block); if (plain) { value += plain->GetText(); } else { if (mode == 1) { value += replaceWith; } } } curDiag->ClearBlocks(); } // Show overrides else value = curDiag->Text; // Cap length and set text if (value.Length() > 512) value = value.Left(512) + _T("..."); strings.Add(value); // Set color curColor = 0; bool inSel = IsInSelection(curRow,0); if (inSel && curDiag->Comment) curColor = 5; else if (inSel) curColor = 2; else if (curDiag->Comment) curColor = 3; else if (Options.AsBool(_T("Highlight subs in frame")) && IsDisplayed(curDiag)) curColor = 4; } else { for (int j=0;j<11;j++) strings.Add(_T("?")); } // Draw row background color if (curColor) { dc.SetBrush(rowColors[curColor]); dc.DrawRectangle((curColor == 1) ? 0 : colWidth[0],i*lineHeight+1,w,lineHeight); } // Set text color if (collides) dc.SetTextForeground(Options.AsColour(_T("Grid collision foreground"))); else { dc.SetTextForeground(foreColors[curColor]); } // Draw text wxRect cur; bool isCenter; for (int j=0;j<11;j++) { // Is center? isCenter = !(j == 4 || j == 5 || j == 6 || j == 10); // Calculate clipping cur = wxRect(dx+4,dy,colWidth[j]-6,lineHeight); // Set clipping dc.DestroyClippingRegion(); dc.SetClippingRegion(cur); // Draw dc.DrawLabel(strings[j],cur,isCenter ? wxALIGN_CENTER : (wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT)); dx += colWidth[j]; } //if (collides) dc.SetPen(wxPen(wxColour(255,0,0))); // Draw grid dc.DestroyClippingRegion(); if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); dc.DrawLine(0,dy+lineHeight,w,dy+lineHeight); dc.SetPen(*wxTRANSPARENT_PEN); } } // Draw grid columns dx = 0; if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); for (int i=0;i<10;i++) { dx += colWidth[i]; dc.DrawLine(dx,0,dx,maxH); } dc.DrawLine(0,0,0,maxH); dc.DrawLine(w-1,0,w-1,h); } // Draw currently active line border dc.SetPen(wxPen(Options.AsColour(_T("Grid Active border")))); dc.SetBrush(*wxTRANSPARENT_BRUSH); dy = (editBox->linen+1-yPos) * lineHeight; dc.DrawRectangle(0,dy,w,lineHeight+1); // Done dc.EndDrawing(); }
void CtrlRegisterList::OnDraw(wxDC& dc) { #ifdef _WIN32 wxFont font = wxFont(wxSize(charWidth,rowHeight-2),wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console"); #else wxFont font = wxFont(8,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console"); font.SetPixelSize(wxSize(charWidth,rowHeight-2)); #endif dc.SetFont(font); refreshChangedRegs(); wxColor colorChanged = wxColor(0xFF0000FF); wxColor colorUnchanged = wxColor(0xFF004000); wxColor colorNormal = wxColor(0xFF600000); int startRow; GetViewStart(nullptr,&startRow); int endRow = startRow + ceil(float(GetClientSize().y) / rowHeight); // draw categories int width = GetClientSize().x; if (startRow == 0) { int piece = width /cpu->getRegisterCategoryCount(); for (int i = 0; i < cpu->getRegisterCategoryCount(); i++) { const char* name = cpu->getRegisterCategoryName(i); int x = i*piece; if (i == category) { dc.SetBrush(wxBrush(wxColor(0xFF70FF70))); dc.SetPen(wxPen(wxColor(0xFF000000))); } else { dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8))); dc.SetPen(wxPen(wxColor(0xFF000000))); } if (i == cpu->getRegisterCategoryCount()-1) piece += width-piece*cpu->getRegisterCategoryCount()-1; dc.DrawRectangle(x,0,piece+1,rowHeight); // center text x += (piece-strlen(name)*charWidth)/2; dc.DrawText(wxString(name,wxConvUTF8),x,2); } } // skip the tab row startRow = std::max<int>(0,startRow-1); endRow = std::min<int>(cpu->getRegisterCount(category)-1,endRow-1); int nameStart = 17; int valueStart = startPositions[category]; ChangedReg* changedRegs = changedCategories[category]; int registerBits = cpu->getRegisterSize(category); DebugInterface::RegisterType type = cpu->getRegisterType(category); for (int i = startRow; i <= endRow; i++) { int x = valueStart; int y = rowHeight*(i+1); wxColor backgroundColor; if (currentRows[category] == i) backgroundColor = wxColor(0xFFFFCFC8); else if (i % 2) backgroundColor = wxColor(237, 242, 255, 255); else backgroundColor = wxColor(0xFFFFFFFF); dc.SetBrush(backgroundColor); dc.SetPen(backgroundColor); dc.DrawRectangle(0, y, width, rowHeight); const char* name = cpu->getRegisterName(category,i); dc.SetTextForeground(colorNormal); dc.DrawText(wxString(name,wxConvUTF8),nameStart,y+2); u128 value = cpu->getRegister(category,i); ChangedReg& changed = changedRegs[i]; switch (type) { case DebugInterface::NORMAL: // display them in 32 bit parts switch (registerBits) { case 128: { int startIndex = std::min<int>(3, maxBits / 32 - 1); if (resolvePointerStrings && cpu && cpu->isAlive()) { char *strval = cpu->stringFromPointer(value._u32[0]); if (strval) { static wxColor clr = wxColor(0xFF228822); dc.SetTextForeground(clr); dc.DrawText(wxString(strval), width - (32 * charWidth + 12), y + 2); startIndex = 0; } } int actualX = width-4-(startIndex+1)*(8*charWidth+2); x = std::max<int>(actualX,x); if (startIndex != 3) { bool c = false; for (int i = 3; i > startIndex; i--) c = c || changed.changed[i]; if (c) { dc.SetTextForeground(colorChanged); dc.DrawText(L"+",x-charWidth,y+2); } } for (int i = startIndex; i >= 0; i--) { if (changed.changed[i]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[i],x,y+2); x += charWidth*8+2; } break; } case 64: { if (maxBits < 64 && changed.changed[1]) { dc.SetTextForeground(colorChanged); dc.DrawText(L"+",x-charWidth,y+2); } for (int i = 1; i >= 0; i--) { if (changed.changed[i]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[i],x,y+2); x += charWidth*8+2; } break; } case 32: { if (changed.changed[0]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[0],x,y+2); break; } } break; case DebugInterface::SPECIAL: // let debug interface format them and just display them { if (changed.changed[0] || changed.changed[1] || changed.changed[2] || changed.changed[3]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); dc.DrawText(cpu->getRegisterString(category,i),x,y+2); break; } } } }
// ----------------------------------------------------------------------------- // Draws function args text for [context] at [left,top]. // Returns a rect of the bounds of the drawn text // ----------------------------------------------------------------------------- wxRect SCallTip::drawArgs( wxDC& dc, const TLFunction::Context& context, int left, int top, wxColour& col_faded, wxFont& bold) const { wxRect rect{ left, top, 0, 0 }; int max_right = left; int args_left = left; int args_top = top; size_t params_lenght = 0; for (const auto& param : context.params) { // Count param name + space length if (!param.type.empty()) params_lenght += param.name.size() + 1; // Count param type + space length if (!param.type.empty()) params_lenght += param.type.size() + 1; // Count param default_value + " = " length if (!param.default_value.empty()) params_lenght += param.default_value.size() + 3; // Count brackets for optional params if (param.optional) params_lenght += 2; } if (context.params.empty()) params_lenght = 4; // void params_lenght *= UI::scalePx(font_.GetPixelSize().GetWidth()); bool long_params = (args_left + params_lenght) > MAX_WIDTH; for (int a = 0; a < (int)context.params.size(); a++) { auto& arg = context.params[a]; // Go down to next line if current is too long if ((a != 0 && (long_params && !(a % 2))) || left > MAX_WIDTH) { left = args_left; top = rect.GetBottom() + UI::scalePx(2); } // Set highlight colour if current arg if (a == arg_current_) { dc.SetTextForeground(wxcol_fg_hl); dc.SetFont(bold); } // Optional opening bracket if (arg.optional && !txed_calltips_dim_optional) left = drawText(dc, "[", left, top, &rect); // Type if (!arg.type.empty()) { wxString arg_type = arg.type == "void" ? "void" : wxString::Format("%s ", arg.type); if (a != arg_current_) dc.SetTextForeground(wxcol_type); left = drawText(dc, arg_type, left, top, &rect); } // Name if (a != arg_current_) dc.SetTextForeground(arg.optional ? col_faded : wxcol_fg); // Faded text if optional left = drawText(dc, arg.name, left, top, &rect); // Default value if (!arg.default_value.empty()) left = drawText(dc, wxString::Format(" = %s", arg.default_value), left, top, &rect); // Optional closing bracket if (arg.optional && !txed_calltips_dim_optional) left = drawText(dc, "]", left, top, &rect); // Comma (if needed) dc.SetFont(font_); dc.SetTextForeground(wxcol_fg); if (a < (int)context.params.size() - 1) left = drawText(dc, ", ", left, top, &rect); // Update max width max_right = std::max(max_right, rect.GetRight()); } // Draw closing bracket drawText(dc, ")", left, top, &rect); max_right = std::max(max_right, rect.GetRight()); return { args_left, args_top, max_right - args_left, rect.GetBottom() - args_top }; }
void ChipPackage::Draw(wxDC& dc, const wxSize& sz, const wxString& chipModel) { // set some GUI objects common to all packages-drawing code dc.SetPen(*wxBLACK_PEN); switch (Type) { case PDIP: case SOIC: case SSOP: { // some drawing constants: // in these package types, pins are organized in two columns: const unsigned int PinPerSide = GetPinCount()/2; if ((GetPinCount()%2) != 0) { wxLogWarning(_("Invalid odd pin count: %d"), GetPinCount()); return; } // choose reasonable package width&height to // - make best use of the available space // - avoid drawing package excessively big const unsigned int BoxW = sz.GetWidth()/3; const unsigned int BoxH = (unsigned int)((double)sz.GetHeight()*0.8); const unsigned int BoxX = (sz.GetWidth()-BoxW)/2; const unsigned int BoxY = (sz.GetHeight()-BoxH)/2; const unsigned int R = BoxW/6; if (int(BoxW/8) == 0) return; // this happens for very small package sizes; // the check avoids an assertion failure from wxFont ctor later // draw the PIC package box dc.DrawRectangle(BoxX, BoxY, BoxW, BoxH); dc.DrawArc(sz.GetWidth()/2-R, BoxY + 1, sz.GetWidth()/2+R, BoxY + 1, sz.GetWidth()/2, BoxY + 1); dc.SetFont(wxFont(wxSize(0, BoxW/8), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); const wxSize& nameSz = dc.GetTextExtent(chipModel); dc.DrawRotatedText(chipModel, (sz.GetWidth() + nameSz.GetHeight())/2, (sz.GetHeight() - nameSz.GetWidth())/2, -90); // draw the pins DrawPins(dc, wxPoint(BoxX, BoxY), BoxH, 0, PinPerSide, 0, wxLEFT); DrawPins(dc, wxPoint(BoxX+BoxW, BoxY), BoxH, PinPerSide, GetPinCount(), DRAWPIN_INVERTED_ORDER, wxRIGHT); } break; case MQFP: case TQFP: case PLCC: case QFN: { // some drawing constants: // in these package types, pins are organized in two columns: const unsigned int PinPerSide = GetPinCount()/4; if ((GetPinCount()%4) != 0) { wxLogWarning(_("Invalid pin count: %d"), GetPinCount()); return; } // choose reasonable package width&height to // - make best use of the available space // - avoid drawing package excessively big const unsigned int BoxL = max(sz.GetWidth()/2,80); const unsigned int BoxX = (sz.GetWidth()-BoxL)/2; const unsigned int BoxY = (sz.GetHeight()-BoxL)/2; const unsigned int R = BoxL/10; if (int(BoxL/10) == 0) return; // this happens for very small package sizes; // the check avoids an assertion failure from wxFont ctor later // draw the PIC package box dc.DrawRectangle(BoxX, BoxY, BoxL, BoxL); dc.DrawCircle(BoxX+int(R*1.3), BoxY+int(R*1.3), R/2); // draw the name of the PIC model in the centre of the box dc.SetFont(wxFont(wxSize(0, BoxL/10), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); const wxSize& nameSz = dc.GetTextExtent(chipModel); dc.DrawText(chipModel, (sz.GetWidth() - nameSz.GetWidth())/2, (sz.GetHeight() - nameSz.GetHeight())/2); // draw the pins DrawPins(dc, wxPoint(BoxX, BoxY), BoxL, 0, PinPerSide, DRAWPIN_NUMBERS_INSIDE_PINS, wxLEFT); DrawPins(dc, wxPoint(BoxX, BoxY+BoxL), BoxL, PinPerSide, PinPerSide*2, DRAWPIN_NUMBERS_INSIDE_PINS, wxBOTTOM); DrawPins(dc, wxPoint(BoxX+BoxL, BoxY), BoxL, PinPerSide*2, PinPerSide*3, DRAWPIN_INVERTED_ORDER|DRAWPIN_NUMBERS_INSIDE_PINS, wxRIGHT); DrawPins(dc, wxPoint(BoxX, BoxY), BoxL, PinPerSide*3, PinPerSide*4, DRAWPIN_INVERTED_ORDER|DRAWPIN_NUMBERS_INSIDE_PINS, wxTOP); } break; default: break; } }
// ----------------------------------------------------------------------------- // Using [dc], draw the calltip contents at [xoff,yoff]. // Returns the dimensions of the drawn calltip text // ----------------------------------------------------------------------------- wxSize SCallTip::drawCallTip(wxDC& dc, int xoff, int yoff) { wxSize ct_size; auto bold = font_.Bold(); // Setup faded text colour ColRGBA faded; if (txed_calltips_dim_optional) faded = ColRGBA( (uint8_t)round((col_fg_.r + col_bg_.r) * 0.5), (uint8_t)round((col_fg_.g + col_bg_.g) * 0.5), (uint8_t)round((col_fg_.b + col_bg_.b) * 0.5)); else faded = col_fg_; // Clear dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(WXCOL(col_bg_))); dc.DrawRectangle(0, 0, 1000, 1000); // Wx Colours (to avoid creating them multiple times) wxcol_fg = WXCOL(col_fg_); wxcol_fg_hl = WXCOL(col_fg_hl); wxcol_type = WXCOL(col_type_); auto wxcol_faded = WXCOL(faded); if (function_) { dc.SetFont(font_); dc.SetTextForeground(wxcol_fg); wxRect rect; int left = xoff; int max_right = 0; int bottom = yoff; // Context switching calltip if (switch_contexts_) { // up-filled \xE2\x96\xB2 // up-empty \xE2\x96\xB3 // down-filled \xE2\x96\xBC // down-empty \xE2\x96\xBD // Up arrow dc.SetTextForeground((btn_mouse_over_ == 2) ? wxcol_fg_hl : wxcol_fg); dc.DrawLabel( wxString::FromUTF8("\xE2\x96\xB2"), wxNullBitmap, wxRect(xoff, yoff, 100, 100), 0, -1, &rect_btn_up_); // Arg set int width = dc.GetTextExtent("X/X").x; dc.SetTextForeground(wxcol_fg); dc.DrawLabel( wxString::Format("%lu/%lu", context_current_ + 1, function_->contexts().size()), wxNullBitmap, wxRect(rect_btn_up_.GetRight() + UI::scalePx(4), yoff, width, 900), wxALIGN_CENTER_HORIZONTAL); // Down arrow dc.SetTextForeground((btn_mouse_over_ == 1) ? wxcol_fg_hl : wxcol_fg); dc.DrawLabel( wxString::FromUTF8("\xE2\x96\xBC"), wxNullBitmap, wxRect(rect_btn_up_.GetRight() + width + UI::scalePx(8), yoff, 900, 900), 0, -1, &rect_btn_down_); left = rect_btn_down_.GetRight() + UI::scalePx(8); rect_btn_up_.Offset(WxUtils::scaledPoint(12, 8)); rect_btn_down_.Offset(WxUtils::scaledPoint(12, 8)); // Draw function (current context) rect = drawFunctionContext(dc, context_, left, yoff, wxcol_faded, bold); max_right = rect.GetRight(); bottom = rect.GetBottom(); } // Normal calltip - show (potentially) multiple contexts else { // Determine separator colour wxColour col_sep; if (col_bg_.greyscale().r < 128) col_sep = WXCOL(col_bg_.amp(30, 30, 30, 0)); else col_sep = WXCOL(col_bg_.amp(-30, -30, -30, 0)); bool first = true; auto num = std::min<unsigned long>(function_->contexts().size(), 12u); for (auto a = 0u; a < num; a++) { auto& context = function_->contexts()[a]; if (!first) { dc.SetPen(wxPen(col_sep)); dc.DrawLine(xoff, bottom + 5, 2000, bottom + 5); } rect = drawFunctionContext( dc, context, xoff, bottom + (first ? 0 : UI::scalePx(11)), wxcol_faded, bold); bottom = (int)round(rect.GetBottom() + UI::scaleFactor()); max_right = std::max(max_right, rect.GetRight()); first = false; } // Show '... # more' if there are too many contexts if (function_->contexts().size() > num) { dc.SetTextForeground(wxcol_faded); drawText( dc, wxString::Format("... %lu more", function_->contexts().size() - num), xoff, bottom + UI::scalePx(11), &rect); bottom = (int)round(rect.GetBottom() + UI::scaleFactor()); } if (num > 1) bottom--; } if (!rect.IsEmpty() && !context_.description.empty()) { auto rect_desc = drawFunctionDescription(dc, context_.description, left, rect.GetBottom()); max_right = std::max(max_right, rect_desc.GetRight()); bottom = rect_desc.GetBottom(); } // Size buffer bitmap to fit ct_size.SetWidth((int)round(max_right + UI::scaleFactor())); ct_size.SetHeight((int)round(bottom + UI::scaleFactor())); } else { // No function, empty buffer ct_size.SetWidth(16); ct_size.SetHeight(16); } return ct_size; }
void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) { // Old, but in some ways better (drawing opaque tabs) #ifndef wxUSE_NEW_METHOD if (!m_view) return; // Top-left of tab view area int viewX = m_view->GetViewRect().x; int viewY = m_view->GetViewRect().y; // Top-left of tab control int tabX = GetX() + viewX; int tabY = GetY() + viewY; int tabHeightInc = 0; if (m_isSelected) { tabHeightInc = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); tabY -= tabHeightInc; } dc.SetPen(*wxTRANSPARENT_PEN); // Draw grey background if (m_view->GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) { dc.SetBrush(*m_view->GetBackgroundBrush()); // Add 1 because the pen is transparent. Under Motif, may be different. #ifdef __WXMOTIF__ dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + tabHeightInc)); #else dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc)); #endif } // Draw highlight and shadow dc.SetPen(*m_view->GetHighlightPen()); // Calculate the top of the tab beneath. It's the height of the tab, MINUS // a bit if the tab below happens to be selected. Check. wxTabControl *tabBeneath = NULL; int subtractThis = 0; if (GetColPosition() > 0) tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition()); if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); // Vertical highlight: if first tab, draw to bottom of view if (tabX == m_view->GetViewRect().x && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y + m_view->GetViewRect().height)); else if (tabX == m_view->GetViewRect().x) // Not box drawing, just to top of view. dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y)); else dc.DrawLine(tabX, tabY, tabX, (tabY + GetHeight() + tabHeightInc - subtractThis)); dc.DrawLine(tabX, tabY, (tabX + GetWidth()), tabY); dc.SetPen(*m_view->GetShadowPen()); // Test if we're outside the right-hand edge of the view area if (((tabX + GetWidth()) >= m_view->GetViewRect().x + m_view->GetViewRect().width) && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) { int bottomY = m_view->GetViewRect().y + m_view->GetViewRect().height + GetY() + m_view->GetTabHeight() + m_view->GetTopMargin(); // Add a tab height since we wish to draw to the bottom of the view. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), bottomY); // Calculate the far-right of the view, since we don't wish to // draw inside that int rightOfView = m_view->GetViewRect().x + m_view->GetViewRect().width + 1; // Draw the horizontal bit to connect to the view rectangle dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY-1), (tabX + GetWidth()), (bottomY-1)); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), bottomY); // Draw the horizontal bit to connect to the view rectangle dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY), (tabX + GetWidth() + 1), (bottomY)); } else { if (lastInRow) { // 25/5/97 UNLESS it's less than the max number of positions in this row int topY = m_view->GetViewRect().y - m_view->GetTopMargin(); int maxPositions = ((wxTabLayer *)m_view->GetLayers().Item(0)->GetData())->GetCount(); // Only down to the bottom of the tab, not to the top of the view if ( GetRowPosition() < (maxPositions - 1) ) topY = tabY + GetHeight() + tabHeightInc; #ifdef __WXMOTIF__ topY -= 1; #endif // Shadow dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), topY); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), topY); } else { // Calculate the top of the tab beneath. It's the height of the tab, MINUS // a bit if the tab below (and next col along) happens to be selected. Check. wxTabControl *tabBeneath = NULL; int subtractThis = 0; if (GetColPosition() > 0) tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition() + 1); if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); #ifdef __WXMOTIF__ subtractThis += 1; #endif // Draw only to next tab down. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc - subtractThis)); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), (tabY + GetHeight() + tabHeightInc - subtractThis)); } } // Draw centered text int textY = tabY + m_view->GetVerticalTabTextSpacing() + tabHeightInc; if (m_isSelected) dc.SetFont(* m_view->GetSelectedTabFont()); else dc.SetFont(* GetFont()); wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); dc.SetBackgroundMode(wxTRANSPARENT); long textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); int textX = (int)(tabX + (GetWidth() - textWidth)/2.0); if (textX < (tabX + 2)) textX = (tabX + 2); dc.SetClippingRegion(tabX, tabY, GetWidth(), GetHeight()); dc.DrawText(GetLabel(), textX, textY); dc.DestroyClippingRegion(); if (m_isSelected) { dc.SetPen(*m_view->GetHighlightPen()); // Draw white highlight from the tab's left side to the left hand edge of the view dc.DrawLine(m_view->GetViewRect().x, (tabY + GetHeight() + tabHeightInc), tabX, (tabY + GetHeight() + tabHeightInc)); // Draw white highlight from the tab's right side to the right hand edge of the view dc.DrawLine((tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc), m_view->GetViewRect().x + m_view->GetViewRect().width, (tabY + GetHeight() + tabHeightInc)); } #else // New HEL version with rounder tabs if (!m_view) return; int tabInc = 0; if (m_isSelected) { tabInc = m_view->GetTabSelectionHeight() - m_view->GetTabHeight(); } int tabLeft = GetX() + m_view->GetViewRect().x; int tabTop = GetY() + m_view->GetViewRect().y - tabInc; int tabRight = tabLeft + m_view->GetTabWidth(); int left = m_view->GetViewRect().x; int top = tabTop + m_view->GetTabHeight() + tabInc; int right = left + m_view->GetViewRect().width; int bottom = top + m_view->GetViewRect().height; if (m_isSelected) { // TAB is selected - draw TAB and the View's full outline dc.SetPen(*(m_view->GetHighlightPen())); wxPoint pnts[10]; int n = 0; pnts[n].x = left; pnts[n++].y = bottom; pnts[n].x = left; pnts[n++].y = top; pnts[n].x = tabLeft; pnts[n++].y = top; pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; dc.DrawLines(n, pnts); if (!lastInRow) { dc.DrawLine( (tabRight + 2), top, right, top ); } dc.SetPen(*(m_view->GetShadowPen())); dc.DrawLine( tabRight, tabTop + 2, tabRight, top ); dc.DrawLine( right, top, right, bottom ); dc.DrawLine( right, bottom, left, bottom ); dc.SetPen(*wxBLACK_PEN); dc.DrawPoint( tabRight, tabTop + 1 ); dc.DrawPoint( tabRight + 1, tabTop + 2 ); if (lastInRow) { dc.DrawLine( tabRight + 1, bottom, tabRight + 1, tabTop + 1 ); } else { dc.DrawLine( tabRight + 1, tabTop + 2, tabRight + 1, top ); dc.DrawLine( right + 1, top, right + 1, bottom + 1 ); } dc.DrawLine( right + 1, bottom + 1, left + 1, bottom + 1 ); } else { // TAB is not selected - just draw TAB outline and RH edge // if the TAB is the last in the row int maxPositions = ((wxTabLayer*)m_view->GetLayers().Item(0)->GetData())->GetCount(); wxTabControl* tabBelow = 0; wxTabControl* tabBelowRight = 0; if (GetColPosition() > 0) { tabBelow = m_view->FindTabControlForPosition( GetColPosition() - 1, GetRowPosition() ); } if (!lastInRow && GetColPosition() > 0) { tabBelowRight = m_view->FindTabControlForPosition( GetColPosition() - 1, GetRowPosition() + 1 ); } float raisedTop = top - m_view->GetTabSelectionHeight() + m_view->GetTabHeight(); dc.SetPen(*(m_view->GetHighlightPen())); wxPoint pnts[10]; int n = 0; pnts[n].x = tabLeft; if (tabBelow && tabBelow->IsSelected()) { pnts[n++].y = (long)raisedTop; } else { pnts[n++].y = top; } pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; dc.DrawLines(n, pnts); dc.SetPen(*(m_view->GetShadowPen())); if (GetRowPosition() >= maxPositions - 1) { dc.DrawLine( tabRight, (tabTop + 2), tabRight, bottom ); dc.DrawLine( tabRight, bottom, (tabRight - m_view->GetHorizontalTabOffset()), bottom ); } else { if (tabBelowRight && tabBelowRight->IsSelected()) { dc.DrawLine( tabRight, (long)raisedTop, tabRight, tabTop + 1 ); } else { dc.DrawLine( tabRight, top - 1, tabRight, tabTop + 1 ); } } dc.SetPen(*wxBLACK_PEN); dc.DrawPoint( tabRight, tabTop + 1 ); dc.DrawPoint( tabRight + 1, tabTop + 2 ); if (GetRowPosition() >= maxPositions - 1) { // draw right hand edge to bottom of view dc.DrawLine( tabRight + 1, bottom + 1, tabRight + 1, tabTop + 2 ); dc.DrawLine( tabRight + 1, bottom + 1, (tabRight - m_view->GetHorizontalTabOffset()), bottom + 1 ); } else { // draw right hand edge of TAB if (tabBelowRight && tabBelowRight->IsSelected()) { dc.DrawLine( tabRight + 1, (long)(raisedTop - 1), tabRight + 1, tabTop + 2 ); } else { dc.DrawLine( tabRight + 1, top - 1, tabRight + 1, tabTop + 2 ); } } } // Draw centered text dc.SetPen(*wxBLACK_PEN); if (m_isSelected) { dc.SetFont(*(m_view->GetSelectedTabFont())); } else { dc.SetFont(*(GetFont())); } wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); dc.SetBackgroundMode(wxTRANSPARENT); long textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); float textX = (tabLeft + tabRight - textWidth) / 2; float textY = (tabInc + tabTop + m_view->GetVerticalTabTextSpacing()); dc.DrawText(GetLabel(), (long)textX, (long)textY); #endif }
void wxRibbonAUIArtProvider::DrawPanelBackground( wxDC& dc, wxRibbonPanel* wnd, const wxRect& rect) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_background_brush); dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); wxRect true_rect(rect); RemovePanelPadding(&true_rect); dc.SetPen(m_panel_border_pen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(true_rect.x, true_rect.y, true_rect.width, true_rect.height); true_rect.x++; true_rect.width -= 2; true_rect.y++; dc.SetFont(m_panel_label_font); wxSize label_size = dc.GetTextExtent(wnd->GetLabel()); int label_height = label_size.GetHeight() + 5; wxRect label_rect(true_rect); label_rect.height = label_height - 1; dc.DrawLine(label_rect.x, label_rect.y + label_rect.height, label_rect.x + label_rect.width, label_rect.y + label_rect.height); wxColour label_bg_colour = m_panel_label_background_colour; wxColour label_bg_grad_colour = m_panel_label_background_gradient_colour; if(wnd->IsHovered()) { label_bg_colour = m_panel_hover_label_background_colour; label_bg_grad_colour = m_panel_hover_label_background_gradient_colour; dc.SetTextForeground(m_panel_hover_label_colour); } else { dc.SetTextForeground(m_panel_label_colour); } dc.GradientFillLinear(label_rect, #ifdef __WXMAC__ label_bg_grad_colour, label_bg_colour, wxSOUTH); #else label_bg_colour, label_bg_grad_colour, wxSOUTH); #endif dc.SetFont(m_panel_label_font); dc.DrawText(wnd->GetLabel(), label_rect.x + 3, label_rect.y + 2); if(wnd->IsHovered()) { wxRect gradient_rect(true_rect); gradient_rect.y += label_rect.height + 1; gradient_rect.height = true_rect.height - label_rect.height - 3; #ifdef __WXMAC__ wxColour colour = m_page_hover_background_gradient_colour; wxColour gradient = m_page_hover_background_colour; #else wxColour colour = m_page_hover_background_colour; wxColour gradient = m_page_hover_background_gradient_colour; #endif dc.GradientFillLinear(gradient_rect, colour, gradient, wxSOUTH); } if(wnd->HasExtButton()) { if(wnd->IsExtButtonHovered()) { dc.SetPen(m_panel_hover_button_border_pen); dc.SetBrush(m_panel_hover_button_background_brush); dc.DrawRoundedRectangle(label_rect.GetRight() - 13, label_rect.GetBottom() - 13, 13, 13, 1.0); dc.DrawBitmap(m_panel_extension_bitmap[1], label_rect.GetRight() - 10, label_rect.GetBottom() - 10, true); } else dc.DrawBitmap(m_panel_extension_bitmap[0], label_rect.GetRight() - 10, label_rect.GetBottom() - 10, true); } }
void TestScrollWinCanvas::PaintShapes(wxDC& dc) { TemplateCanvas::PaintShapes(dc); dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxRED_BRUSH); dc.SetTextForeground(*wxBLACK); dc.SetTextBackground(wxTransparentColor); // new const in wxWidgets 2.9.1 dc.SetFont(*wxSMALL_FONT); int y=10; int dy=20; int i=0; dc.DrawLine(30,30, 250,15); dc.DrawText("*wxSMALL_FONT", 10, y+(dy*i++)); dc.SetFont(*wxNORMAL_FONT); dc.DrawText("*wxNORMAL_FONT", 10, y+(dy*i++)); dc.SetFont(wxSystemSettings::GetFont(wxSYS_ANSI_VAR_FONT)); dc.DrawText("GetFont(wxSYS_ANSI_VAR_FONT)", 10, y+(dy*i++)); dc.SetFont(wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT)); dc.DrawText("GetFont(wxSYS_SYSTEM_FONT)", 10, y+(dy*i++)); wxFont f1(8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); dc.SetFont(f1); dc.DrawText("8, wxFONTFAMILY_SWISS", 10, y+(dy*i++)); wxFont f1_1(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); dc.SetFont(f1_1); dc.DrawText("9, wxFONTFAMILY_SWISS", 10, y+(dy*i++)); wxFont f2(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); dc.SetFont(f2); dc.DrawText("10, wxFONTFAMILY_SWISS", 10, y+(dy*i++)); wxFont f3(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); dc.SetFont(f3); dc.DrawText("11, wxFONTFAMILY_SWISS", 10, y+(dy*i++)); wxFont f4(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); dc.SetFont(f4); dc.DrawText("12, wxFONTFAMILY_SWISS", 10, y+(dy*i++)); wxFont f5(14, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); dc.SetFont(f5); dc.DrawText("14, wxFONTFAMILY_SWISS", 10, y+(dy*i++)); f5.SetPointSize(16); dc.SetFont(f5); dc.DrawText("16, wxFONTFAMILY_SWISS", 10, y+(dy*i++)); f5.SetPixelSize(wxSize(0,15)); dc.SetFont(f5); dc.DrawText("SetPixelSize(0,15), wxFONTFAMILY_SWISS", 10, y+(dy*i++)); f5.SetPixelSize(wxSize(0,10)); dc.SetFont(f5); dc.DrawText("SetPixelSize(0,10), wxFONTFAMILY_SWISS", 10, y+(dy*i++)); f5.SetPixelSize(wxSize(0,20)); dc.SetFont(f5); dc.DrawText("SetPixelSize(0,20), wxFONTFAMILY_SWISS", 10, y+(dy*i++)); dc.SetFont(*GdaConst::small_font); dc.DrawText("*GdaConst::small_font", 10, y+(dy*i++)); dc.SetFont(*GdaConst::medium_font); dc.DrawText("*GdaConst::medium_font", 10, y+(dy*i++)); dc.SetTextForeground(GdaConst::selectable_fill_color); dc.SetFont(*GdaConst::large_font); dc.DrawText("*GdaConst::large_font", 10, y+(dy*i++)); }
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 wxStdRenderer::DrawFrameTitle(wxDC& dc, const wxRect& rect, const wxString& title, int flags) { wxColour col = m_scheme->Get(flags & wxTOPLEVEL_ACTIVE ? wxColourScheme::TITLEBAR_ACTIVE_TEXT : wxColourScheme::TITLEBAR_TEXT); dc.SetTextForeground(col); wxRect r = GetFrameClientArea(rect, flags & ~wxTOPLEVEL_TITLEBAR); r.height = FRAME_TITLEBAR_HEIGHT; if ( flags & wxTOPLEVEL_ICON ) { r.x += FRAME_TITLEBAR_HEIGHT; r.width -= FRAME_TITLEBAR_HEIGHT + 2; } else { r.x += 1; r.width -= 3; } if ( flags & wxTOPLEVEL_BUTTON_CLOSE ) r.width -= FRAME_BUTTON_WIDTH + 2; if ( flags & wxTOPLEVEL_BUTTON_MAXIMIZE ) r.width -= FRAME_BUTTON_WIDTH; if ( flags & wxTOPLEVEL_BUTTON_RESTORE ) r.width -= FRAME_BUTTON_WIDTH; if ( flags & wxTOPLEVEL_BUTTON_ICONIZE ) r.width -= FRAME_BUTTON_WIDTH; if ( flags & wxTOPLEVEL_BUTTON_HELP ) r.width -= FRAME_BUTTON_WIDTH; dc.SetFont(m_titlebarFont); wxString s; wxCoord textW; dc.GetTextExtent(title, &textW, NULL); if ( textW > r.width ) { // text is too big, let's shorten it and add "..." after it: size_t len = title.length(); wxCoord WSoFar, letterW; dc.GetTextExtent(wxT("..."), &WSoFar, NULL); if ( WSoFar > r.width ) { // not enough space to draw anything return; } s.Alloc(len); for (size_t i = 0; i < len; i++) { dc.GetTextExtent(title[i], &letterW, NULL); if ( letterW + WSoFar > r.width ) break; WSoFar += letterW; s << title[i]; } s << wxT("..."); } else // no need to truncate the title { s = title; } dc.DrawLabel(s, wxNullBitmap, r, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL); }
void wxAuiMSWTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { if ( !IsThemed() ) { wxAuiGenericTabArt::DrawTab(dc, wnd, page, in_rect, close_button_state, out_tab_rect, out_button_rect, x_extent); return; } if ( !m_closeBtnSize.IsFullySpecified() ) InitSizes(wnd, dc); // figure out the size of the tab wxSize tabSize = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tabHeight = tabSize.y; wxCoord tabWidth = tabSize.x; wxCoord tabX = in_rect.x; wxCoord tabY = 0; if (!page.active) { tabY += wnd->FromDIP(2); tabHeight -= wnd->FromDIP(2); } else { tabX -= wnd->FromDIP(2); tabWidth += wnd->FromDIP(4); tabHeight += 2; } int clipWidth = tabWidth; if ( tabX + clipWidth > in_rect.x + in_rect.width ) clipWidth = (in_rect.x + in_rect.width) - tabX; dc.SetClippingRegion(tabX - wnd->FromDIP(2), tabY, clipWidth + wnd->FromDIP(4), tabHeight); // draw tab wxRect tabRect(tabX, tabY, tabWidth, tabHeight); int tabState; if ( page.active ) tabState = TIS_SELECTED; else if ( page.hover ) tabState = TIS_HOT; else tabState = TIS_NORMAL; wxUxThemeHandle hTabTheme(wnd, L"Tab"); RECT tabR; wxCopyRectToRECT(tabRect, tabR); ::DrawThemeBackground(hTabTheme, GetHdcOf(dc.GetTempHDC()), TABP_TABITEM, tabState, &tabR, NULL); // Apparently, in at least some Windows 10 installations the call above // does not draw the left edge of the first tab and it needs to be drawn // separately, or it wouldn't be drawn at all. if ( tabX == GetIndentSize() ) { ::DrawThemeBackground ( hTabTheme, GetHdcOf(dc.GetTempHDC()), TABP_TABITEMLEFTEDGE, tabState, &tabR, NULL ); } wxRect textRect = tabRect; if ( !page.active ) textRect.Offset(0, wnd->FromDIP(1)); if ( close_button_state != wxAUI_BUTTON_STATE_HIDDEN ) textRect.width -= m_closeBtnSize.x + wnd->FromDIP(3); dc.SetFont(wnd->GetFont()); dc.DrawLabel(page.caption, page.bitmap, textRect, wxALIGN_CENTRE); // draw focus rectangle if ( page.active && (wnd->FindFocus() == wnd) ) { wxRect focusRect = tabRect; focusRect.Deflate(wnd->FromDIP(2)); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if ( close_button_state != wxAUI_BUTTON_STATE_HIDDEN ) { wxUxThemeHandle hToolTipTheme(wnd, L"TOOLTIP"); int btnState; if ( close_button_state == wxAUI_BUTTON_STATE_HOVER ) btnState = TTCS_HOT; else if ( close_button_state == wxAUI_BUTTON_STATE_PRESSED ) btnState = TTCS_PRESSED; else btnState = TTCS_NORMAL; int offsetY = tabY; if ( wxGetWinVersion() < wxWinVersion_Vista ) offsetY++; // WinXP theme needs a little more padding wxRect rect(tabX + tabWidth - m_closeBtnSize.x - wnd->FromDIP(4), offsetY + (tabHeight / 2) - (m_closeBtnSize.y / 2), m_closeBtnSize.x, m_closeBtnSize.y); RECT btnR; wxCopyRectToRECT(rect, btnR); ::DrawThemeBackground(hToolTipTheme, GetHdcOf(dc.GetTempHDC()), TTP_CLOSE, btnState, &btnR, NULL); if ( out_button_rect ) *out_button_rect = rect; } *out_tab_rect = wxRect(tabX, tabY, tabWidth, tabHeight); dc.DestroyClippingRegion(); }
void clAuiDockArt::DrawCaption(wxDC& dc, wxWindow* window, const wxString& text, const wxRect& rect, wxAuiPaneInfo& pane) { wxRect tmpRect(wxPoint(0, 0), rect.GetSize()); // Hackishly prevent assertions on linux if(tmpRect.GetHeight() == 0) tmpRect.SetHeight(1); if(tmpRect.GetWidth() == 0) tmpRect.SetWidth(1); #ifdef __WXOSX__ tmpRect = rect; window->PrepareDC(dc); // Prepare the colours wxColour bgColour, penColour, textColour; textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); bgColour = DrawingUtils::DarkColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 2.0); ; // Same as the notebook background colour penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); penColour = bgColour; wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); dc.SetFont(f); dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawRectangle(tmpRect); // Fill the caption to look like OSX caption wxColour topColour("#d3d2d3"); wxColour bottomColour("#e8e8e8"); dc.GradientFillLinear(tmpRect, topColour, bottomColour, wxNORTH); dc.SetPen(penColour); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(tmpRect); int caption_offset = 0; if(pane.icon.IsOk()) { DrawIcon(dc, tmpRect, pane); caption_offset += pane.icon.GetWidth() + 3; } else { caption_offset = 3; } dc.SetTextForeground(textColour); wxCoord w, h; dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); wxRect clip_rect = tmpRect; clip_rect.width -= 3; // text offset clip_rect.width -= 2; // button padding if(pane.HasCloseButton()) clip_rect.width -= m_buttonSize; if(pane.HasPinButton()) clip_rect.width -= m_buttonSize; if(pane.HasMaximizeButton()) clip_rect.width -= m_buttonSize; wxString draw_text = wxAuiChopText(dc, text, clip_rect.width); wxSize textSize = dc.GetTextExtent(draw_text); dc.SetTextForeground(textColour); dc.DrawText(draw_text, tmpRect.x + 3 + caption_offset, tmpRect.y + ((tmpRect.height - textSize.y) / 2)); #else wxBitmap bmp(tmpRect.GetSize()); { wxMemoryDC memDc; memDc.SelectObject(bmp); wxGCDC gdc; wxDC* pDC = NULL; if(!DrawingUtils::GetGCDC(memDc, gdc)) { pDC = &memDc; } else { pDC = &gdc; } // Prepare the colours wxColour bgColour, penColour, textColour; textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); bgColour = DrawingUtils::DarkColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 2.0); ; // Same as the notebook background colour penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); penColour = bgColour; wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); pDC->SetFont(f); pDC->SetPen(penColour); pDC->SetBrush(bgColour); pDC->DrawRectangle(tmpRect); pDC->SetPen(penColour); pDC->SetBrush(*wxTRANSPARENT_BRUSH); pDC->DrawRectangle(tmpRect); int caption_offset = 0; if(pane.icon.IsOk()) { DrawIcon(gdc, tmpRect, pane); caption_offset += pane.icon.GetWidth() + 3; } else { caption_offset = 3; } pDC->SetTextForeground(textColour); wxCoord w, h; pDC->GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); wxRect clip_rect = tmpRect; clip_rect.width -= 3; // text offset clip_rect.width -= 2; // button padding if(pane.HasCloseButton()) clip_rect.width -= m_buttonSize; if(pane.HasPinButton()) clip_rect.width -= m_buttonSize; if(pane.HasMaximizeButton()) clip_rect.width -= m_buttonSize; wxString draw_text = wxAuiChopText(gdc, text, clip_rect.width); wxSize textSize = pDC->GetTextExtent(draw_text); pDC->SetTextForeground(textColour); pDC->DrawText(draw_text, tmpRect.x + 3 + caption_offset, tmpRect.y + ((tmpRect.height - textSize.y) / 2)); memDc.SelectObject(wxNullBitmap); } dc.DrawBitmap(bmp, rect.x, rect.y, true); #endif }
void wxRibbonMetroArtProvider::DrawTab( wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRibbonPageTabInfo& tab) { if(tab.rect.height <= 2) return; if(tab.active || tab.hovered) { if(tab.active) { wxRect background(tab.rect); background.x += 2; background.y += 1; background.width -= 3; background.height -= 1; dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_tab_active_background_colour); dc.DrawRectangle(background); // TODO: active and hovered } else if(tab.hovered) { wxRect background(tab.rect); background.x += 2; background.y += 1; background.width -= 3; background.height -= 2; dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_tab_hover_background_colour); dc.DrawRectangle(background); } wxPoint border_points[4]; border_points[0] = wxPoint(1, tab.rect.height - 2); border_points[1] = wxPoint(1, 0); border_points[2] = wxPoint(tab.rect.width - 1, 0); border_points[3] = wxPoint(tab.rect.width - 1, tab.rect.height - 1); if (tab.active) dc.SetPen(m_tab_border_pen); else dc.SetPen(m_tab_border_pen); // TODO: introduce hover border pen colour dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y); } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) { wxBitmap icon = tab.page->GetIcon(); if(icon.IsOk()) { int x = tab.rect.x + 4; if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - icon.GetHeight()) / 2, true); } } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) { wxString label = tab.page->GetLabel(); if(!label.IsEmpty()) { dc.SetFont(m_tab_label_font); dc.SetTextForeground(m_tab_label_colour); dc.SetBackgroundMode(wxTRANSPARENT); int text_height; int text_width; dc.GetTextExtent(label, &text_width, &text_height); int width = tab.rect.width - 5; int x = tab.rect.x + 3; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) { x += 3 + tab.page->GetIcon().GetWidth(); width -= 3 + tab.page->GetIcon().GetWidth(); } int y = tab.rect.y + (tab.rect.height - text_height) / 2; if(width <= text_width) { dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height); dc.DrawText(label, x, y); } else { dc.DrawText(label, x + (width - text_width) / 2 + 1, y); } } } }
void wxAuiGenericTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxCoord normal_textx, normal_texty; wxCoord selected_textx, selected_texty; wxCoord texty; // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); dc.SetFont(m_selectedFont); dc.GetTextExtent(caption, &selected_textx, &selected_texty); dc.SetFont(m_normalFont); dc.GetTextExtent(caption, &normal_textx, &normal_texty); // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tab_height = m_tabCtrlHeight - 3; wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height; caption = page.caption; // select pen, brush and font for the tab to be drawn if (page.active) { dc.SetFont(m_selectedFont); texty = selected_texty; } else { dc.SetFont(m_normalFont); texty = normal_texty; } // create points that will make the tab outline int clip_width = tab_width; if (tab_x + clip_width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - tab_x; /* wxPoint clip_points[6]; clip_points[0] = wxPoint(tab_x, tab_y+tab_height-3); clip_points[1] = wxPoint(tab_x, tab_y+2); clip_points[2] = wxPoint(tab_x+2, tab_y); clip_points[3] = wxPoint(tab_x+clip_width-1, tab_y); clip_points[4] = wxPoint(tab_x+clip_width+1, tab_y+2); clip_points[5] = wxPoint(tab_x+clip_width+1, tab_y+tab_height-3); // FIXME: these ports don't provide wxRegion ctor from array of points #if !defined(__WXDFB__) && !defined(__WXCOCOA__) // set the clipping region for the tab -- wxRegion clipping_region(WXSIZEOF(clip_points), clip_points); dc.SetClippingRegion(clipping_region); #endif // !wxDFB && !wxCocoa */ // since the above code above doesn't play well with WXDFB or WXCOCOA, // we'll just use a rectangle for the clipping region for now -- dc.SetClippingRegion(tab_x, tab_y, clip_width+1, tab_height-3); wxPoint border_points[6]; if (m_flags &wxAUI_NB_BOTTOM) { border_points[0] = wxPoint(tab_x, tab_y); border_points[1] = wxPoint(tab_x, tab_y+tab_height-6); border_points[2] = wxPoint(tab_x+2, tab_y+tab_height-4); border_points[3] = wxPoint(tab_x+tab_width-2, tab_y+tab_height-4); border_points[4] = wxPoint(tab_x+tab_width, tab_y+tab_height-6); border_points[5] = wxPoint(tab_x+tab_width, tab_y); } else //if (m_flags & wxAUI_NB_TOP) {} { border_points[0] = wxPoint(tab_x, tab_y+tab_height-4); border_points[1] = wxPoint(tab_x, tab_y+2); border_points[2] = wxPoint(tab_x+2, tab_y); border_points[3] = wxPoint(tab_x+tab_width-2, tab_y); border_points[4] = wxPoint(tab_x+tab_width, tab_y+2); border_points[5] = wxPoint(tab_x+tab_width, tab_y+tab_height-4); } // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} int drawn_tab_yoff = border_points[1].y; int drawn_tab_height = border_points[0].y - border_points[1].y; if (page.active) { // draw active tab // draw base background color wxRect r(tab_x, tab_y, tab_width, tab_height); dc.SetPen(wxPen(m_activeColour)); dc.SetBrush(wxBrush(m_activeColour)); dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4); // this white helps fill out the gradient at the top of the tab dc.SetPen(*wxWHITE_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4); // these two points help the rounded corners appear more antialiased dc.SetPen(wxPen(m_activeColour)); dc.DrawPoint(r.x+2, r.y+1); dc.DrawPoint(r.x+r.width-2, r.y+1); // set rectangle down a bit for gradient drawing r.SetHeight(r.GetHeight()/2); r.x += 2; r.width -= 3; r.y += r.height; r.y -= 2; // draw gradient background wxColor top_color = *wxWHITE; wxColor bottom_color = m_activeColour; dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); } else { // draw inactive tab wxRect r(tab_x, tab_y+1, tab_width, tab_height-3); // start the gradent up a bit and leave the inside border inset // by a pixel for a 3D look. Only the top half of the inactive // tab will have a slight gradient r.x += 3; r.y++; r.width -= 4; r.height /= 2; r.height--; // -- draw top gradient fill for glossy look wxColor top_color = m_baseColour; wxColor bottom_color = top_color.ChangeLightness(160); dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); r.y += r.height; r.y--; // -- draw bottom fill for glossy look top_color = m_baseColour; bottom_color = m_baseColour; dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); } // draw tab outline dc.SetPen(m_borderPen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawPolygon(WXSIZEOF(border_points), border_points); // there are two horizontal grey lines at the bottom of the tab control, // this gets rid of the top one of those lines in the tab control if (page.active) { if (m_flags &wxAUI_NB_BOTTOM) dc.SetPen(wxPen(m_baseColour.ChangeLightness(170))); // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP dc.SetPen(m_baseColourPen); dc.DrawLine(border_points[0].x+1, border_points[0].y, border_points[5].x, border_points[5].y); } int text_offset = tab_x + 8; int close_button_width = 0; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { close_button_width = m_activeCloseBmp.GetWidth(); } int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = tab_x + 8; // draw bitmap dc.DrawBitmap(page.bitmap, bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), true); text_offset = bitmap_offset + page.bitmap.GetWidth(); text_offset += 3; // bitmap padding } else { text_offset = tab_x + 8; } wxString draw_text = wxAuiChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width); // draw tab text dc.DrawText(draw_text, text_offset, drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1); // draw focus rectangle if (page.active && (wnd->FindFocus() == wnd)) { wxRect focusRectText(text_offset, (drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1), selected_textx, selected_texty); wxRect focusRect; wxRect focusRectBitmap; if (page.bitmap.IsOk()) focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), page.bitmap.GetWidth(), page.bitmap.GetHeight()); if (page.bitmap.IsOk() && draw_text.IsEmpty()) focusRect = focusRectBitmap; else if (!page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText; else if (page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText.Union(focusRectBitmap); focusRect.Inflate(2, 2); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if necessary if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxBitmap bmp = m_disabledCloseBmp; if (close_button_state == wxAUI_BUTTON_STATE_HOVER || close_button_state == wxAUI_BUTTON_STATE_PRESSED) { bmp = m_activeCloseBmp; } int offsetY = tab_y-1; if (m_flags & wxAUI_NB_BOTTOM) offsetY = 1; wxRect rect(tab_x + tab_width - close_button_width - 1, offsetY + (tab_height/2) - (bmp.GetHeight()/2), close_button_width, tab_height); IndentPressedBitmap(&rect, close_button_state); dc.DrawBitmap(bmp, rect.x, rect.y, true); *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); dc.DestroyClippingRegion(); }
void wxRibbonMetroArtProvider::DrawButtonBarButton( wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect, wxRibbonButtonKind kind, long state, const wxString& label, const wxBitmap& bitmap_large, const wxBitmap& bitmap_small) { if(kind == wxRIBBON_BUTTON_TOGGLE) { kind = wxRIBBON_BUTTON_NORMAL; if(state & wxRIBBON_BUTTONBAR_BUTTON_TOGGLED) state ^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK; } if(state & (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK | wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK)) { if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK) dc.SetPen(m_button_bar_active_border_pen); else dc.SetPen(m_button_bar_hover_border_pen); wxRect bg_rect(rect); bg_rect.x++; bg_rect.y++; bg_rect.width -= 2; bg_rect.height -= 2; wxRect bg_rect_top(bg_rect); bg_rect_top.height /= 3; bg_rect.y += bg_rect_top.height; bg_rect.height -= bg_rect_top.height; if(kind == wxRIBBON_BUTTON_HYBRID) { switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK) { case wxRIBBON_BUTTONBAR_BUTTON_LARGE: { int iYBorder = rect.y + bitmap_large.GetHeight() + 4; wxRect partial_bg(rect); if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED) { partial_bg.SetBottom(iYBorder - 1); } else { partial_bg.height -= (iYBorder - partial_bg.y + 1); partial_bg.y = iYBorder + 1; } dc.DrawLine(rect.x, iYBorder, rect.x + rect.width, iYBorder); bg_rect.Intersect(partial_bg); bg_rect_top.Intersect(partial_bg); } break; case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM: { int iArrowWidth = 9; if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED) { bg_rect.width -= iArrowWidth; bg_rect_top.width -= iArrowWidth; dc.DrawLine(bg_rect_top.x + bg_rect_top.width, rect.y, bg_rect_top.x + bg_rect_top.width, rect.y + rect.height); } else { --iArrowWidth; bg_rect.x += bg_rect.width - iArrowWidth; bg_rect_top.x += bg_rect_top.width - iArrowWidth; bg_rect.width = iArrowWidth; bg_rect_top.width = iArrowWidth; dc.DrawLine(bg_rect_top.x - 1, rect.y, bg_rect_top.x - 1, rect.y + rect.height); } } break; case wxRIBBON_BUTTONBAR_BUTTON_SMALL: break; } } if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_button_bar_active_background_colour); dc.DrawRectangle(bg_rect_top); dc.DrawRectangle(bg_rect); } else { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_button_bar_hover_background_colour); dc.DrawRectangle(bg_rect_top); dc.DrawRectangle(bg_rect); } if(state & wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK) dc.SetPen(m_button_bar_active_border_pen); else dc.SetPen(m_button_bar_hover_border_pen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(rect); } dc.SetFont(m_button_bar_label_font); dc.SetTextForeground(m_button_bar_label_colour); DrawButtonBarButtonForeground(dc, rect, kind, state, label, bitmap_large, bitmap_small); }
void wxAuiSimpleTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxCoord normal_textx, normal_texty; wxCoord selected_textx, selected_texty; wxCoord textx, texty; // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); dc.SetFont(m_selectedFont); dc.GetTextExtent(caption, &selected_textx, &selected_texty); dc.SetFont(m_normalFont); dc.GetTextExtent(caption, &normal_textx, &normal_texty); // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tab_height = tab_size.y; wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height; caption = page.caption; // select pen, brush and font for the tab to be drawn if (page.active) { dc.SetPen(m_selectedBkPen); dc.SetBrush(m_selectedBkBrush); dc.SetFont(m_selectedFont); textx = selected_textx; texty = selected_texty; } else { dc.SetPen(m_normalBkPen); dc.SetBrush(m_normalBkBrush); dc.SetFont(m_normalFont); textx = normal_textx; texty = normal_texty; } // -- draw line -- wxPoint points[7]; points[0].x = tab_x; points[0].y = tab_y + tab_height - 1; points[1].x = tab_x + tab_height - 3; points[1].y = tab_y + 2; points[2].x = tab_x + tab_height + 3; points[2].y = tab_y; points[3].x = tab_x + tab_width - 2; points[3].y = tab_y; points[4].x = tab_x + tab_width; points[4].y = tab_y + 2; points[5].x = tab_x + tab_width; points[5].y = tab_y + tab_height - 1; points[6] = points[0]; dc.SetClippingRegion(in_rect); dc.DrawPolygon(WXSIZEOF(points) - 1, points); dc.SetPen(*wxGREY_PEN); //dc.DrawLines(active ? WXSIZEOF(points) - 1 : WXSIZEOF(points), points); dc.DrawLines(WXSIZEOF(points), points); int text_offset; int close_button_width = 0; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { close_button_width = m_activeCloseBmp.GetWidth(); text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2); } else { text_offset = tab_x + (tab_height/3) + (tab_width/2) - (textx/2); } // set minimum text offset if (text_offset < tab_x + tab_height) text_offset = tab_x + tab_height; // chop text if necessary wxString draw_text = wxAuiChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width); // draw tab text dc.DrawText(draw_text, text_offset, (tab_y + tab_height)/2 - (texty/2) + 1); // draw focus rectangle if (page.active && (wnd->FindFocus() == wnd)) { wxRect focusRect(text_offset, ((tab_y + tab_height)/2 - (texty/2) + 1), selected_textx, selected_texty); focusRect.Inflate(2, 2); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if necessary if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxBitmap bmp; if (page.active) bmp = m_activeCloseBmp; else bmp = m_disabledCloseBmp; wxRect rect(tab_x + tab_width - close_button_width - 1, tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1, close_button_width, tab_height - 1); DrawButtons(dc, rect, bmp, *wxWHITE, close_button_state); *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); dc.DestroyClippingRegion(); }
void Meter::HandlePaint(wxDC &dc) { int i; dc.SetFont(GetFont()); if (mLeftSize.x == 0) { dc.GetTextExtent(mLeftText, &mLeftSize.x, &mLeftSize.y); dc.GetTextExtent(mRightText, &mRightSize.x, &mRightSize.y); } if (!mLayoutValid) HandleLayout(); #ifndef USE_AQUA_THEME #ifdef EXPERIMENTAL_THEMING if( !mMeterDisabled ) { mBkgndBrush.SetColour( GetParent()->GetBackgroundColour() ); } #endif dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(mBkgndBrush); dc.DrawRectangle(0, 0, mWidth, mHeight); #endif dc.DrawBitmap(*mIcon, mIconPos.x, mIconPos.y, true); #if WANT_METER_MENU // Draws a beveled button and a down pointing triangle. // The style and sizing matches the ones in the title // bar of the waveform left-hand-side panels. { wxRect r = mMenuRect; AColor::Bevel(dc, true, r); dc.SetPen(*wxBLACK_PEN); int triWid = 11; int xStart = r.x+3; int yStart = r.y+4; for(i=0;i<=triWid/2;i++){ dc.DrawLine(xStart+i, yStart+i, xStart + triWid - i,yStart+i); } } if (mNumBars>0) mRuler.Draw(dc); #else // Label as "Mix Volume" and "Input Volume" for Camp Jam. int nFontSize = this->GetFont().GetPointSize(); int nXPos = mIconPos.x + mIcon->GetWidth() + 8; int nYPos = mIconPos.y + (mIcon->GetHeight() - nFontSize - 6)/2; if (nYPos < 0) nYPos = 0; if (mIsInput) dc.DrawText(_("Input Volume"), nXPos, nYPos); else dc.DrawText(_("Mix Volume"), nXPos, nYPos); #endif // WANT_METER_MENU dc.SetFont(GetFont()); dc.DrawText(mLeftText, mLeftTextPos.x, mLeftTextPos.y); dc.DrawText(mRightText, mRightTextPos.x, mRightTextPos.y); for(i=0; i<mNumBars; i++) DrawMeterBar(dc, &mBar[i]); }
void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { GtkWidget *widget = wnd->GetHandle(); GtkStyle *style_notebook = gtk_widget_get_style(wxGTKPrivate::GetNotebookWidget()); wxRect const &window_rect = wnd->GetRect(); int focus_width = 0; gtk_widget_style_get(wxGTKPrivate::GetNotebookWidget(), "focus-line-width", &focus_width, NULL); int tab_pos; if (m_flags &wxAUI_NB_BOTTOM) tab_pos = wxAUI_NB_BOTTOM; else //if (m_flags & wxAUI_NB_TOP) {} tab_pos = wxAUI_NB_TOP; // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxRect tab_rect = in_rect; tab_rect.width = tab_size.x; tab_rect.height = tab_size.y; tab_rect.y += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; if (page.active) tab_rect.height += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; // if no bitmap is set, we need a tiny correction if (! page.bitmap.IsOk()) tab_rect.height += 1; int gap_rect_height = 6 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; int gap_rect_x = 1, gap_start = 0, gap_width = 0; int gap_rect_y = tab_rect.y - gap_rect_height; int gap_rect_width = window_rect.width; switch (tab_pos) { case wxAUI_NB_TOP: tab_rect.y -= 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; if (!page.active) tab_rect.y += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; gap_rect_y = tab_rect.y + tab_rect.height - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2; // fall through case wxAUI_NB_BOTTOM: gap_start = tab_rect.x - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder / 2; gap_width = tab_rect.width; break; // TODO: case wxAUI_NB_LEFT: break; // TODO: case wxAUI_NB_RIGHT: break; } tab_rect.y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2; gap_rect_y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2; int padding = focus_width + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; int clip_width = tab_rect.width; if (tab_rect.x + tab_rect.width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - tab_rect.x; dc.SetClippingRegion(tab_rect.x, tab_rect.y - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder, clip_width, tab_rect.height + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder); GdkRectangle area; area.x = tab_rect.x - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder; area.y = tab_rect.y - 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; area.width = clip_width + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder; area.height = tab_rect.height + 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); GdkWindow* window = impldc->GetGDKWindow(); if (tab_pos == wxAUI_NB_BOTTOM) { if (page.active) { gtk_paint_box_gap(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, const_cast<char*>("notebook"), gap_rect_x, gap_rect_y, gap_rect_width, gap_rect_height, GTK_POS_BOTTOM, gap_start , gap_width); } gtk_paint_extension(style_notebook, window, page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT, &area, widget, const_cast<char*>("tab"), tab_rect.x, tab_rect.y, tab_rect.width, tab_rect.height, GTK_POS_TOP); } else { if (page.active) { gtk_paint_box_gap(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, const_cast<char*>("notebook"), gap_rect_x, gap_rect_y, gap_rect_width, gap_rect_height, GTK_POS_TOP, gap_start , gap_width); } gtk_paint_extension(style_notebook, window, page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT, &area, widget, const_cast<char*>("tab"), tab_rect.x, tab_rect.y, tab_rect.width, tab_rect.height, GTK_POS_BOTTOM); } wxCoord textX = tab_rect.x + padding + style_notebook->xthickness; int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = textX; // draw bitmap int bitmapY = tab_rect.y +(tab_rect.height - page.bitmap.GetHeight()) / 2; if(!page.active) { if (tab_pos == wxAUI_NB_TOP) bitmapY += style_notebook->ythickness / 2; else bitmapY -= style_notebook->ythickness / 2; } dc.DrawBitmap(page.bitmap, bitmap_offset, bitmapY, true); textX += page.bitmap.GetWidth() + padding; } wxCoord textW, textH, textY; dc.SetFont(m_normalFont); dc.GetTextExtent(page.caption, &textW, &textH); textY = tab_rect.y + (tab_rect.height - textH) / 2; if(!page.active) { if (tab_pos == wxAUI_NB_TOP) textY += style_notebook->ythickness / 2; else textY -= style_notebook->ythickness / 2; } // draw tab text GdkColor text_colour = page.active ? style_notebook->fg[GTK_STATE_NORMAL] : style_notebook->fg[GTK_STATE_ACTIVE]; dc.SetTextForeground(wxColor(text_colour)); GdkRectangle focus_area; int padding_focus = padding - focus_width; focus_area.x = tab_rect.x + padding_focus; focus_area.y = textY - focus_width; focus_area.width = tab_rect.width - 2 * padding_focus; focus_area.height = textH + 2 * focus_width; if(page.active && (wnd->FindFocus() == wnd) && focus_area.x <= (area.x + area.width)) { // clipping seems not to work here, so we we have to recalc the focus-area manually if((focus_area.x + focus_area.width) > (area.x + area.width)) focus_area.width = area.x + area.width - focus_area.x + focus_width - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder; gtk_paint_focus (style_notebook, window, GTK_STATE_ACTIVE, NULL, widget, "tab", focus_area.x, focus_area.y, focus_area.width, focus_area.height); } dc.DrawText(page.caption, textX, textY); // draw close-button on tab (if enabled) if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxRect rect(tab_rect.x, tab_rect.y, tab_rect.width - style_notebook->xthickness, tab_rect.height); if(!page.active) { if (tab_pos == wxAUI_NB_TOP) rect.y += style_notebook->ythickness / 2; else rect.y -= style_notebook->ythickness / 2; } *out_button_rect = DrawCloseButton(dc, widget, close_button_state, rect, wxRIGHT, &area); } tab_rect.width = std::min(tab_rect.width, clip_width); *out_tab_rect = tab_rect; dc.DestroyClippingRegion(); }