void Route::CalculateDCRect( wxDC& dc_route, wxRect *prect, ViewPort &VP ) { dc_route.ResetBoundingBox(); dc_route.DestroyClippingRegion(); // Draw the route in skeleton form on the dc // That is, draw only the route points, assuming that the segements will // always be fully contained within the resulting rectangle. // Can we prove this? if( m_bVisible ) { wxRoutePointListNode *node = pRoutePointList->GetFirst(); while( node ) { RoutePoint *prp2 = node->GetData(); bool blink_save = prp2->m_bBlink; prp2->m_bBlink = false; ocpnDC odc_route( dc_route ); prp2->Draw( odc_route, NULL ); prp2->m_bBlink = blink_save; node = node->GetNext(); } } // Retrieve the drawing extents prect->x = dc_route.MinX() - 1; prect->y = dc_route.MinY() - 1; prect->width = dc_route.MaxX() - dc_route.MinX() + 2; prect->height = dc_route.MaxY() - dc_route.MinY() + 2; }
void Route::CalculateDCRect( wxDC& dc_route, wxRect *prect ) { dc_route.ResetBoundingBox(); dc_route.DestroyClippingRegion(); wxRect update_rect; // Draw the route in skeleton form on the dc // That is, draw only the route points, assuming that the segements will // always be fully contained within the resulting rectangle. // Can we prove this? if( m_bVisible ) { wxRoutePointListNode *node = pRoutePointList->GetFirst(); while( node ) { RoutePoint *prp2 = node->GetData(); bool blink_save = prp2->m_bBlink; prp2->m_bBlink = false; ocpnDC odc_route( dc_route ); prp2->Draw( odc_route, NULL ); prp2->m_bBlink = blink_save; wxRect r = prp2->CurrentRect_in_DC ; r.Inflate(m_hiliteWidth, m_hiliteWidth); // allow for large hilite circles at segment ends update_rect.Union( r ); node = node->GetNext(); } } *prect = update_rect; }
void TLView::DrawItem(wxDC& dc, TLItem* item, long left, long delta_left, long top, long width, long height) { /* - Item itself - */ Draw3dRect( &dc, left, top, width, height, item->GetSample()->GetColour() ); /* - Selection - */ if ( item->IsSelected() ) { dc.SetPen( wxPen( *wxWHITE, 3, wxSHORT_DASH ) ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.DrawRectangle( left, top, width, height ); } /* - Label (Filename) - */ if ( width > 1 ) { dc.SetPen( *wxBLACK_PEN ); dc.SetClippingRegion( left, top, width, height ); dc.SetFont( *wxSMALL_FONT ); wxFileName fn( item->GetSample()->GetFilename() ); long v3 = left + delta_left; dc.DrawText( fn.GetName(), v3, top + 1 ); /* - Extras ;) -*/ dc.SetPen( *wxBLACK_PEN ); dc.SetBrush( *wxWHITE_BRUSH ); if ( item->m_toggleEnvelope ) { item->DrawEnvelope( dc, left + delta_left, top ); } dc.DrawIcon(*dropDownIcon, left+delta_left+(item->GetLen()/GetRealZoom())-7,top+height-7); dc.DestroyClippingRegion(); } // dc.DrawRectangle( left + item->m_x_test, top+item->m_y_test, 10, 10); }
void ModernDockArt::DrawCaption(wxDC& dc, wxWindow* WXUNUSED(window), const wxString& text, const wxRect& rect, wxAuiPaneInfo& pane) { dc.SetPen(*wxTRANSPARENT_PEN); DrawCaptionBackground(dc, rect, (pane.state & wxAuiPaneInfo::optionActive)?true:false); // Active captions are drawn with bold text if (pane.state & wxAuiPaneInfo::optionActive) m_caption_font.SetWeight(wxFONTWEIGHT_BOLD); else m_caption_font.SetWeight(wxFONTWEIGHT_NORMAL); dc.SetFont(m_caption_font); dc.SetTextForeground(m_inactive_caption_text_colour); wxCoord w,h; dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); dc.SetClippingRegion(rect); dc.DrawText(text, rect.x+m_caption_text_indent, rect.y+(rect.height/2)-(h/2)-1); dc.DestroyClippingRegion(); }
void oglDrawFormattedText(wxDC& dc, wxList *text_list, double m_xpos, double m_ypos, double width, double height, int formatMode) { double xoffset, yoffset; if (formatMode & FORMAT_CENTRE_HORIZ) xoffset = m_xpos; else xoffset = (double)(m_xpos - (width / 2.0)); if (formatMode & FORMAT_CENTRE_VERT) yoffset = m_ypos; else yoffset = (double)(m_ypos - (height / 2.0)); dc.SetClippingRegion( (long)(m_xpos - width/2.0), (long)(m_ypos - height/2.0), (long)width+1, (long)height+1); // +1 to allow for rounding errors wxObjectList::compatibility_iterator current = text_list->GetFirst(); while (current) { wxShapeTextLine *line = (wxShapeTextLine *)current->GetData(); dc.DrawText(line->GetText(), WXROUND(xoffset + line->GetX()), WXROUND(yoffset + line->GetY())); current = current->GetNext(); } dc.DestroyClippingRegion(); }
void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) { int leftMargin = 2; wxRect rect; GetFieldRect(i, rect); if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) { dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; } wxString text(GetStatusText(i)); long x, y; dc.GetTextExtent(text, &x, &y); int xpos = rect.x + leftMargin + 1 ; int ypos = 1 ; dc.SetClippingRegion(rect.x, 0, rect.width, m_height); dc.DrawText(text, xpos, ypos); dc.DestroyClippingRegion(); }
void wxStatusBarGeneric::DrawFieldText(wxDC& dc, int i) { int leftMargin = 2; wxRect rect; GetFieldRect(i, rect); wxString text(GetStatusText(i)); long x = 0, y = 0; dc.GetTextExtent(text, &x, &y); int xpos = rect.x + leftMargin; int ypos = (int) (((rect.height - y) / 2 ) + rect.y + 0.5) ; #if defined( __WXGTK__ ) || defined(__WXMAC__) xpos++; ypos++; #endif dc.SetClippingRegion(rect.x, rect.y, rect.width, rect.height); dc.DrawText(text, xpos, ypos); dc.DestroyClippingRegion(); }
void AudioDisplay::PaintLabels(wxDC &dc, TimeRange updtime) { std::vector<AudioLabelProvider::AudioLabel> labels; controller->GetTimingController()->GetLabels(updtime, labels); if (labels.empty()) return; wxDCFontChanger fc(dc); wxFont font = dc.GetFont(); font.SetWeight(wxFONTWEIGHT_BOLD); dc.SetFont(font); dc.SetTextForeground(*wxWHITE); for (auto const& label : labels) { wxSize extent = dc.GetTextExtent(label.text); int left = RelativeXFromTime(label.range.begin()); int width = AbsoluteXFromTime(label.range.length()); // If it doesn't fit, truncate if (width < extent.GetWidth()) { dc.SetClippingRegion(left, audio_top + 4, width, extent.GetHeight()); dc.DrawText(label.text, left, audio_top + 4); dc.DestroyClippingRegion(); } // Otherwise center in the range else { dc.DrawText(label.text, left + (width - extent.GetWidth()) / 2, audio_top + 4); } } }
void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) { int leftMargin = 2; int w, h ; GetSize( &w , &h ) ; wxRect rect; GetFieldRect(i, rect); if ( !MacIsReallyHilited() ) { dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; } wxString text(GetStatusText(i)); long x, y; dc.GetTextExtent(text, &x, &y); int xpos = rect.x + leftMargin + 1 ; int ypos = 1 ; if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) ypos++ ; dc.SetClippingRegion(rect.x, 0, rect.width, h); dc.DrawText(text, xpos, ypos); dc.DestroyClippingRegion(); }
void ClippingBoxTestCaseBase::OneRegionAndReset() { // Setting one clipping box and next destroy it. // Final clipping box should be the same as DC surface. m_dc->SetClippingRegion(10, 20, 80, 75); m_dc->DestroyClippingRegion(); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight()); }
/* paints the progress bar */ void CBOINCGridCellProgressRenderer::DoProgressDrawing(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) { wxRect rect = rectCell; rect.Inflate(-1); // erase only this cells background, overflow cells should have been erased this->DrawBackground(grid, dc, rectCell, row, isSelected); // set text attributes int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); SetTextColoursAndFont(grid, attr, dc, isSelected); //calculate the two parts of the progress rect // double dv = 0.0; wxString strValue = grid.GetCellValue(row,col); if(m_bDoPercentAppending) { strValue = strValue + wxT(" %"); } // Project view uses the format: %0.0f (%0.2f%%) // Everyone else uses: %.3f%% if (strValue.Find(wxT("(")) != wxNOT_FOUND) { strValue.SubString(strValue.Find(wxT("(")) + 1, strValue.Find(wxT(")")) - 1).ToDouble( &dv ); } else { strValue.ToDouble ( &dv ); // NOTE: we should do error-checking/reporting here!! } wxRect p1(rect); wxRect p2(rect); int r = (int)((rect.GetRight()-rect.GetLeft())*dv / 100.0); p1.SetRight(rect.GetLeft()+r); p2.SetLeft(rect.GetLeft()+r+1); p2.SetRight(rect.GetRight()-1); //start drawing dc.SetClippingRegion(rect); wxBrush old = dc.GetBrush(); wxColour progressColour = wxTheColourDatabase->Find(wxT("LIGHT BLUE")); wxBrush* progressBrush = wxTheBrushList->FindOrCreateBrush(progressColour); wxPen* progressPen = wxThePenList->FindOrCreatePen(progressColour,1,wxSOLID); //draw the outline rectangle dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetPen(*progressPen); dc.DrawRectangle(rect); // Draw the left part dc.SetBrush(*progressBrush); dc.DrawRectangle(p1); //draw the right part dc.SetBrush(old); dc.DrawRectangle(p2); // dc.DestroyClippingRegion(); // draw the text grid.DrawTextRectangle(dc, strValue, rect, hAlign, vAlign); }
void wxSheetCellBitmapRendererRefData::Draw(wxSheet& sheet, const wxSheetCellAttr& attr, wxDC& dc, const wxRect& rect_, const wxSheetCoords& coords, bool isSelected) { wxSheetCellRendererRefData::Draw(sheet, attr, dc, rect_, coords, isSelected); wxRect rect(rect_); wxSize bmpSize; if (m_bitmap.Ok()) { bmpSize.x = m_bitmap.GetWidth(); bmpSize.y = m_bitmap.GetHeight(); } wxSize txtSize(wxSheetCellStringRendererRefData::GetBestSize(sheet, attr, dc, coords)); if ((txtSize.x == 0) && (bmpSize.x == 0)) return; int margin = 2; if ((txtSize.x == 0) || (bmpSize.x == 0)) margin = 0; int txt_align = attr.GetAlignment(); int bmp_align = m_align; wxRect bmpRect(wxPoint(0,0), bmpSize); wxRect txtRect(wxPoint(0,0), txtSize); if (txtSize.x > 0) txtRect.Inflate(1); rect.Inflate(-1); AlignBmpTextRects(rect, bmp_align, txt_align, margin, bmpRect, txtRect); rect.Inflate(1); //dc.SetBrush(*wxTRANSPARENT_BRUSH); //dc.SetPen(*wxRED_PEN); //dc.DrawRectangle(txtRect); //dc.SetPen(*wxGREEN_PEN); //dc.DrawRectangle(bmpRect); if ((txtRect.width > 0) && (txtRect.height > 0)) wxSheetCellStringRendererRefData::DoDraw(sheet, attr, dc, txtRect, coords, isSelected); if (m_bitmap.Ok() && (bmpRect.width > 0) && (bmpRect.height > 0)) { dc.SetClippingRegion(rect); bmpRect.SetPosition(wxSheet::AlignInRect(m_align, bmpRect, bmpSize)); dc.DrawBitmap(m_bitmap, bmpRect.x, bmpRect.y, true); dc.DestroyClippingRegion(); } }
void MyCanvas::EraseShape(DragShape* shape, wxDC& dc) { wxSize sz = GetClientSize(); wxRect rect(0, 0, sz.x, sz.y); wxRect rect2(shape->GetRect()); dc.SetClippingRegion(rect2.x, rect2.y, rect2.width, rect2.height); wxGetApp().TileBitmap(rect, dc, wxGetApp().GetBackgroundBitmap()); dc.DestroyClippingRegion(); }
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back) { SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetTextBackground(wxColourFromCA(back)); FillRectangle(rc, back); hdc->SetClippingRegion(wxRectFromPRectangle(rc)); // see comments above hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); hdc->DestroyClippingRegion(); }
void CellRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) { dc.SetClippingRegion(rect); wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, false); if( m_Renderer != NULL && imageName != NULL && StrOp.len(imageName) > 0 ) { int cx = 0; int cy = 0; if( imageBitmap == NULL ) { wxMemoryDC tmpDC; m_Renderer->sizeSvgSym( imageName, wItem.west, &cx, &cy ); if( imageBitmap != NULL ) delete imageBitmap; imageBitmap = new wxBitmap(); imageBitmap->Create(cx * 32 * m_Scale, cy * 32 * m_Scale , -1); tmpDC.SelectObject(*imageBitmap); tmpDC.SetBackground(*wxWHITE_BRUSH); tmpDC.Clear(); tmpDC.SetUserScale( m_Scale, m_Scale ); m_Renderer->drawSvgSym( (wxPaintDC&)tmpDC, 0, 0, imageName, wItem.west, &cx, &cy ); tmpDC.SelectObject(wxNullBitmap); m_RowSize = cy * 32 * m_Scale + 4; if( grid.GetColSize(col) < cx * 32 * m_Scale ) grid.SetColSize(col, cx * 32 * m_Scale ); if( grid.GetRowSize(row) < m_RowSize ) grid.SetRowSize(row, m_RowSize ); TraceOp.trc( "cellrenderer", TRCLEVEL_DEBUG, __LINE__, 9999, "image: %s dc=%X row=%d col=%d cx=%d cy=%d rowsize=%d", imageName, &dc, row, col, cx, cy, m_RowSize ); } dc.DrawBitmap(*imageBitmap, rect.x, rect.y + 2); } else if( imageName != NULL && StrOp.len(imageName) > 0 ) { if( imageBitmap == NULL ) updateImage(rect); if( imageBitmap != NULL ) { dc.DrawBitmap(*imageBitmap, rect.x, rect.y); if( !m_bDidResize ) { grid.AutoSizeColumn(col); m_bDidResize = true; } } } dc.DestroyClippingRegion(); }
void RoutePoint::CalculateDCRect( wxDC& dc, wxRect *prect ) { dc.ResetBoundingBox(); dc.DestroyClippingRegion(); // Draw the mark on the dc ocpnDC odc( dc ); Draw( odc, NULL ); // Retrieve the drawing extents prect->x = dc.MinX() - 1; prect->y = dc.MinY() - 1; prect->width = dc.MaxX() - dc.MinX() + 2; // Mouse Poop? prect->height = dc.MaxY() - dc.MinY() + 2; }
void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight) { int w, h; GetSize( &w , &h ); wxString text(GetStatusText( i )); int xpos = rect.x + wxFIELD_TEXT_MARGIN + 1; int ypos = 2 + (rect.height - textHeight) / 2; if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL ) ypos++; dc.SetClippingRegion(rect.x, 0, rect.width, h); dc.DrawText(text, xpos, ypos); dc.DestroyClippingRegion(); }
void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window), const wxString& text, const wxRect& rect, wxAuiPaneInfo& pane) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetFont(m_captionFont); DrawCaptionBackground(dc, rect, (pane.state & wxAuiPaneInfo::optionActive)?true:false); int caption_offset = 0; if ( pane.icon.IsOk() ) { DrawIcon(dc, rect, pane); caption_offset += pane.icon.GetWidth() + 3; } if (pane.state & wxAuiPaneInfo::optionActive) dc.SetTextForeground(m_activeCaptionTextColour); else dc.SetTextForeground(m_inactiveCaptionTextColour); wxCoord w,h; dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); wxRect clip_rect = rect; 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); dc.SetClippingRegion(clip_rect); dc.DrawText(draw_text, rect.x+3 + caption_offset, rect.y+(rect.height/2)-(h/2)-1); dc.DestroyClippingRegion(); }
void wxIFMComponent::Paint(wxDC &dc, const wxRegion ®ion) { // get component rect first wxRect rect = m_rect; // set clipping region of DC dc.DestroyClippingRegion(); dc.SetClippingRegion(region); // paint background first wxIFMPaintEvent bgevt(wxEVT_IFM_PAINTBG, this, region, dc); m_ip->ProcessPluginEvent(bgevt); // paint border second wxIFMPaintEvent bdevt(wxEVT_IFM_PAINTBORDER, this, region, dc); m_ip->ProcessPluginEvent(bdevt); // paint decorations last wxIFMPaintEvent dcevt(wxEVT_IFM_PAINTDECOR, this, region, dc); m_ip->ProcessPluginEvent(dcevt); // recursively paint children of this component for( size_t i = 0; i < m_children.GetCount(); i++ ) //for( wxIFMComponentArray::const_iterator i = m_children.begin(), end = m_children.end(); i != end; ++i ) { //wxIFMComponent *child = *i; wxIFMComponent *child = m_children[i]; // only paint the child if needed if( child->IsVisible() ) { wxRegionContain result = region.Contains(child->m_rect); if( result == wxPartRegion || result == wxInRegion ) { //wxRegion new_region = region; //new_region.Intersect(child->m_rect); child->Paint(dc, region); } } } }
void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int WXUNUSED(textHeight)) { int w, h; GetSize( &w , &h ); if ( !MacIsReallyHilited() ) dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) ); wxString text(GetStatusText( i )); /*wxCoord x, y; dc.GetTextExtent(text, &x, &y); -- seems unused (FM)*/ int xpos = rect.x + wxFIELD_TEXT_MARGIN + 1; int ypos = 1; if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL ) ypos++; dc.SetClippingRegion(rect.x, 0, rect.width, h); dc.DrawText(text, xpos, ypos); dc.DestroyClippingRegion(); }
void wxStatusBarGeneric::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight) { wxString text(GetStatusText(i)); if (text.empty()) return; // optimization int xpos = rect.x + wxFIELD_TEXT_MARGIN, maxWidth = rect.width - 2*wxFIELD_TEXT_MARGIN, ypos = (int) (((rect.height - textHeight) / 2) + rect.y + 0.5); if (ShowsSizeGrip()) { // don't write text over the size grip: // NOTE: overloading DoGetClientSize() and GetClientAreaOrigin() wouldn't // work because the adjustment needs to be done only when drawing // the field text and not also when drawing the background, the // size grip itself, etc if ((GetLayoutDirection() == wxLayout_RightToLeft && i == 0) || (GetLayoutDirection() != wxLayout_RightToLeft && i == (int)m_panes.GetCount()-1)) { const wxRect& gripRc = GetSizeGripRect(); // NOTE: we don't need any special treatment wrt to the layout direction // since DrawText() will automatically adjust the origin of the // text accordingly to the layout in use maxWidth -= gripRc.width; } } // eventually ellipsize the text so that it fits the field width wxEllipsizeMode ellmode = wxELLIPSIZE_NONE; if (HasFlag(wxSTB_ELLIPSIZE_START)) ellmode = wxELLIPSIZE_START; else if (HasFlag(wxSTB_ELLIPSIZE_MIDDLE)) ellmode = wxELLIPSIZE_MIDDLE; else if (HasFlag(wxSTB_ELLIPSIZE_END)) ellmode = wxELLIPSIZE_END; if (ellmode == wxELLIPSIZE_NONE) { // if we have the wxSTB_SHOW_TIPS we must set the ellipsized flag even if // we don't ellipsize the text but just truncate it if (HasFlag(wxSTB_SHOW_TIPS)) SetEllipsizedFlag(i, dc.GetTextExtent(text).GetWidth() > maxWidth); dc.SetClippingRegion(rect); } else { text = wxControl::Ellipsize(text, dc, ellmode, maxWidth, wxELLIPSIZE_FLAGS_EXPAND_TABS); // Ellipsize() will do something only if necessary // update the ellipsization status for this pane; this is used later to // decide whether a tooltip should be shown or not for this pane // (if we have wxSTB_SHOW_TIPS) SetEllipsizedFlag(i, text != GetStatusText(i)); } #if defined( __WXGTK__ ) || defined(__WXMAC__) xpos++; ypos++; #endif // draw the text dc.DrawText(text, xpos, ypos); if (ellmode == wxELLIPSIZE_NONE) dc.DestroyClippingRegion(); }
wxColour wxJigsawShape::DrawBackground(wxDC & dc, const wxPoint & pos, const wxSize & headerSize, const wxSize & size, double scale) { wxColour color(m_Colour); if(wxJigsawEditorMainFrame::Get()->GetCanvas()->GetSelectedShape() == this) { //Shape selected. Give a feedback to the user! double bright = 1.15 + .08*GetLevelColor(); color.Set(__min(bright*color.Red(), 255), __min(bright*color.Green(), 255), __min(bright*color.Blue(), 255)); } else if(m_Parent && m_Colour == m_Parent->GetColour()) { //Change the shape bright to contrast with the parent shape double bright = 1 + .08*GetLevelColor(); color.Set(__min(bright*color.Red(), 255), __min(bright*color.Green(), 255), __min(bright*color.Blue(), 255)); } dc.SetBrush(wxBrush(color)); dc.SetPen(*wxTRANSPARENT_PEN); wxPoint connector[5] = { wxPoint(0,0), wxPoint(wxJigsawShape::ConnectorSize.GetHeight(), wxJigsawShape::ConnectorSize.GetHeight()), wxPoint(wxJigsawShape::ConnectorSize.GetWidth()-wxJigsawShape::ConnectorSize.GetHeight(), wxJigsawShape::ConnectorSize.GetHeight()), wxPoint(wxJigsawShape::ConnectorSize.GetWidth(),0), wxPoint(0,0) }; for(size_t i = 0; i < 5; i++) { connector[i].x *= scale; connector[i].y *= scale; } wxSize childrenSize = GetChildrenSize(dc, scale); int cShapeHeight = wxMax(childrenSize.GetHeight(), 10*scale); wxRegion clippingRegion(0, 0, dc.GetSize().GetWidth(), dc.GetSize().GetHeight()); if(m_HasNotch) { wxRegion connectorRegion(5, connector); connectorRegion.Offset(pos.x + wxJigsawShape::ConnectorSize.GetWidth()*scale, pos.y); clippingRegion.Xor(connectorRegion); } if(m_HasCShape) { wxRegion connectorRegion(5, connector); connectorRegion.Offset( pos.x + (wxJigsawShape::CShapeThickness+wxJigsawShape::ConnectorSize.GetWidth())*scale, pos.y + headerSize.GetHeight()+cShapeHeight); clippingRegion.Xor(connectorRegion); } dc.SetClippingRegion(clippingRegion); //dc.DrawRoundedRectangle(m_Position.x, m_Position.y, headerSize.GetWidth(), headerSize.GetHeight(), 4); DrawShapeHeader(dc, pos, headerSize, IntToJigsawShapeStyle(m_Style)); if(m_HasCShape) { dc.DrawRectangle(pos.x, pos.y + headerSize.GetHeight() / 2, (wxJigsawShape::CShapeThickness+4)*scale, headerSize.GetHeight() / 2 + cShapeHeight + (wxJigsawShape::CShapeThickness*scale)/2); dc.DrawRoundedRectangle(pos.x, pos.y + headerSize.GetHeight()+cShapeHeight, headerSize.GetWidth(), wxJigsawShape::CShapeThickness*scale, 4); // Upper inner notch dc.DrawPolygon(5, connector, pos.x + (wxJigsawShape::CShapeThickness+wxJigsawShape::ConnectorSize.GetWidth())*scale, pos.y + headerSize.GetHeight()); } if(m_HasBump) { dc.DrawPolygon(5, connector, pos.x + wxJigsawShape::ConnectorSize.GetWidth()*scale, pos.y + size.GetHeight()); } dc.DestroyClippingRegion(); return color; }
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 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 SjCoverBrowser::DoPaint(wxDC& dc) { long x, y, w, h; #define SPACE_BRUSH g_mainFrame->m_workspaceColours[SJ_COLOUR_NORMAL].bgBrush // reset required and waiting images g_mainFrame->m_imgThread->RequireStart(m_window); // draw stuff very left (does not scroll) dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(SPACE_BRUSH); dc.DrawRectangle(0, 0, SPACE_LEFT, m_window->m_clientH); dc.SetClippingRegion(wxRect(0, 0, SPACE_LEFT-SEL_BORDER_W, m_window->m_clientH)); w = m_fontHeight - 4; h = m_fontHeight - 4; x = (SPACE_LEFT-w) / 2; y = SPACE_TOP + 2; dc.SetPen(g_mainFrame->m_workspaceColours[SJ_COLOUR_TITLE1].fgPen); SjTools::DrawIcon(dc, wxRect(x, y, w, h), (m_flags&SJ_BROWSER_VIEW_COVER)? SJ_DRAWICON_TRIANGLE_DOWN : SJ_DRAWICON_TRIANGLE_RIGHT); if( g_mainFrame->m_libraryModule ) m_window->DrawUpText(dc, g_mainFrame->m_libraryModule->GetUpText(), 0, SPACE_TOP+m_fontHeight, SPACE_LEFT, m_window->m_clientH-(SPACE_TOP+m_fontHeight)); dc.DestroyClippingRegion(); // draw space atop of all covers long currY = -m_scrollY; dc.SetBrush(SPACE_BRUSH); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(SPACE_LEFT, currY, m_window->m_clientW, g_mainFrame->m_currColumnYSpace); // go through all cover rows int coverIndex = 0; currY += g_mainFrame->m_currColumnYSpace; for( int yIndex = 0; yIndex < m_coversYCount+ADD_ROWS/*try two rows more*/; yIndex++ ) { // go through all cover columns long currX = SPACE_LEFT; for( int xIndex = 0; xIndex < m_coversXCount; xIndex++ ) { bool selectCover = false, coverDrawn = false, borderBottom = true; if( coverIndex < m_allocatedCoverCount ) { SjCol* cover = m_allocatedCover[coverIndex++]; if( cover && cover->m_rowCount>0 && cover->m_rows[0]->m_roughType==SJ_RRTYPE_COVER ) { SjImgThreadObj* cachedImg = m_window->RequireImage(cover->m_rows[0]->m_textm); // cachedImg may be NULL, but this is okay for PaintCover() and for ReleaseImage() m_window->PaintCover(dc, cachedImg, currX, currY); g_mainFrame->m_imgThread->ReleaseImage(m_window, cachedImg); coverDrawn = true; selectCover = cover->FindFirstSelectedRow()!=NULL; // draw text below cover if( m_flags&SJ_BROWSER_VIEW_COVER ) { // get text wxString texts[2]; int trackCount = 0; for( int r = 0; r < cover->m_rowCount; r++ ) { SjRow* row = cover->m_rows[r]; if( row ) { if( row->m_roughType == SJ_RRTYPE_TITLE1 || row->m_roughType == SJ_RRTYPE_TITLE2 ) { if( texts[0].IsEmpty() ) texts[0] = row->m_textm; else texts[1] = row->m_textm; } else if( row->m_roughType == SJ_RRTYPE_NORMAL ) { trackCount ++; } } } if( texts[0].IsEmpty() ) { texts[0].Printf(_("%s tracks"), SjTools::FormatNumber(trackCount).c_str()); } // draw text for( int i=0; i<m_linesBelowCover; i++ ) { wxRect drawRect(currX, currY+g_mainFrame->m_currCoverHeight+m_fontHeight*i, g_mainFrame->m_currCoverWidth, m_fontHeight); SjSkinColour* bgcolour = &g_mainFrame->m_workspaceColours[selectCover? SJ_COLOUR_SELECTIONODD : SJ_COLOUR_NORMAL]; SjSkinColour* fgcolour = &g_mainFrame->m_workspaceColours[selectCover? SJ_COLOUR_SELECTIONODD : (i==0?SJ_COLOUR_TITLE1:SJ_COLOUR_TITLE2)]; wxFont* stdFont = i==0? &g_mainFrame->m_currBoldFont : &g_mainFrame->m_currStdFont; wxFont* smallFont = i==0? &g_mainFrame->m_currSmallBoldFont : &g_mainFrame->m_currSmallFont; dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(bgcolour->bgBrush); dc.DrawRectangle(drawRect); dc.SetTextBackground(fgcolour->bgColour); dc.SetTextForeground(fgcolour->fgColour); g_tools->DrawSingleLineText(dc, texts[i], drawRect, *stdFont, *smallFont, NULL, fgcolour->hiColour); if( selectCover ) borderBottom = false; } } } } if( !coverDrawn ) { // draw space instead of cover (normally this happens if this are the last covers) dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(g_mainFrame->m_workspaceColours[SJ_COLOUR_NORMAL].bgBrush); dc.DrawRectangle(currX-SEL_BORDER_W, currY-SEL_BORDER_W, g_mainFrame->m_currCoverWidth+SEL_BORDER_W*2, m_coverNTitleHeight+SEL_BORDER_W*2); } else { // draw the (selection) border SjSkinColour* colour = &g_mainFrame->m_workspaceColours[selectCover? SJ_COLOUR_SELECTIONODD : SJ_COLOUR_NORMAL]; dc.SetPen(colour->bgPen); dc.SetBrush(*wxTRANSPARENT_BRUSH); for( int i = 1; i <= SEL_BORDER_W; i++ ) { dc.DrawRectangle(currX-i, currY-i, g_mainFrame->m_currCoverWidth+i*2, m_coverNTitleHeight+i*(borderBottom?2:1)); if( !borderBottom ) { dc.SetPen(g_mainFrame->m_workspaceColours[SJ_COLOUR_NORMAL].bgPen); y = currY+m_coverNTitleHeight+i-1; dc.DrawLine(currX-SEL_BORDER_W, y, currX+g_mainFrame->m_currCoverWidth+SEL_BORDER_W, y); dc.SetPen(colour->bgPen); } } } // draw space aright of the cover x = currX+g_mainFrame->m_currCoverWidth+SEL_BORDER_W; y = currY-SEL_BORDER_W; h = m_coverNTitleHeight+SEL_BORDER_W*2; w = m_coverXSpace-SEL_BORDER_W*2; if( xIndex == m_coversXCount-1 ) w = m_window->m_clientW-(currX+g_mainFrame->m_currCoverWidth+SEL_BORDER_W); if( w > 0 ) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(SPACE_BRUSH); dc.DrawRectangle(x, y, w, h); } // next cover in row currX += g_mainFrame->m_currCoverWidth+m_coverXSpace; } // draw space below this cover row x = SPACE_LEFT-SEL_BORDER_W; y = currY+m_coverNTitleHeight+SEL_BORDER_W; w = m_window->m_clientW-x; h = g_mainFrame->m_currColumnYSpace-SEL_BORDER_W*2; if( yIndex == (m_coversYCount-1)+ADD_ROWS /*we've added 2 in the for() loop, so no -1 here*/ ) h = m_window->m_clientH-(currY+m_coverNTitleHeight+SEL_BORDER_W); if( h > 0 ) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(SPACE_BRUSH); dc.DrawRectangle(x, y, w, h); } // next row currY += m_coverNTitleHeight+g_mainFrame->m_currColumnYSpace; } // free all images that are no longer required but still waiting g_mainFrame->m_imgThread->RequireEnd(m_window); }
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) { if(m_view->GetBackgroundBrush()) 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); wxCoord 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::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 || tab.highlight) { 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); if(tab.highlight) { dc.GradientFillLinear(grad_rect, m_tab_highlight_top_colour, m_tab_highlight_top_gradient_colour, wxSOUTH); } else { 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); } }
/* draws text with ellipses instead cutting it */ void CBOINCGridCtrl::DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect& rect, int horizAlign, int vertAlign, int textOrientation ) { long textWidth, textHeight; long lineWidth, lineHeight; unsigned int nLines; dc.SetClippingRegion( rect ); nLines = (unsigned int)lines.GetCount(); if( nLines > 0 ) { unsigned int l; float x = 0.0, y = 0.0; if( textOrientation == wxHORIZONTAL ) GetTextBoxSize(dc, lines, &textWidth, &textHeight); else GetTextBoxSize( dc, lines, &textHeight, &textWidth ); switch( vertAlign ) { case wxALIGN_BOTTOM: if( textOrientation == wxHORIZONTAL ) y = rect.y + (rect.height - textHeight - 1); else x = rect.x + rect.width - textWidth; break; case wxALIGN_CENTRE: if( textOrientation == wxHORIZONTAL ) y = rect.y + ((rect.height - textHeight)/2); else x = rect.x + ((rect.width - textWidth)/2); break; case wxALIGN_TOP: default: if( textOrientation == wxHORIZONTAL ) y = rect.y + 1; else x = rect.x + 1; break; } // Align each line of a multi-line label for( l = 0; l < nLines; l++ ) { dc.GetTextExtent(lines[l], &lineWidth, &lineHeight); switch( horizAlign ) { case wxALIGN_RIGHT: if( textOrientation == wxHORIZONTAL ) x = rect.x + (rect.width - lineWidth - 1); else y = rect.y + lineWidth + 1; break; case wxALIGN_CENTRE: if( textOrientation == wxHORIZONTAL ) x = rect.x + ((rect.width - lineWidth)/2); else y = rect.y + rect.height - ((rect.height - lineWidth)/2); break; case wxALIGN_LEFT: default: if( textOrientation == wxHORIZONTAL ) x = rect.x + 1; else y = rect.y + rect.height - 1; break; } if( textOrientation == wxHORIZONTAL ) { //changes applies here wxString formattedText = FormatTextWithEllipses(dc,lines[l],rect.width); dc.DrawText( formattedText, (int)x, (int)y ); y += lineHeight; } else { dc.DrawRotatedText( lines[l], (int)x, (int)y, 90.0 ); x += lineHeight; } } } dc.DestroyClippingRegion(); }
void wxGridCellStringRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) { wxRect rect = rectCell; rect.Inflate(-1); // erase only this cells background, overflow cells should have been erased wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); int overflowCols = 0; if (attr.GetOverflow()) { int cols = grid.GetNumberCols(); int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth(); int cell_rows, cell_cols; attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <= 0 if ((best_width > rectCell.width) && (col < cols) && grid.GetTable()) { int i, c_cols, c_rows; for (i = col+cell_cols; i < cols; i++) { bool is_empty = true; for (int j=row; j < row + cell_rows; j++) { // check w/ anchor cell for multicell block grid.GetCellSize(j, i, &c_rows, &c_cols); if (c_rows > 0) c_rows = 0; if (!grid.GetTable()->IsEmptyCell(j + c_rows, i)) { is_empty = false; break; } } if (is_empty) { rect.width += grid.GetColSize(i); } else { i--; break; } if (rect.width >= best_width) break; } overflowCols = i - col - cell_cols + 1; if (overflowCols >= cols) overflowCols = cols - 1; } if (overflowCols > 0) // redraw overflow cells w/ proper hilight { hAlign = wxALIGN_LEFT; // if oveflowed then it's left aligned wxRect clip = rect; clip.x += rectCell.width; // draw each overflow cell individually int col_end = col + cell_cols + overflowCols; if (col_end >= grid.GetNumberCols()) col_end = grid.GetNumberCols() - 1; for (int i = col + cell_cols; i <= col_end; i++) { clip.width = grid.GetColSize(i) - 1; dc.DestroyClippingRegion(); dc.SetClippingRegion(clip); SetTextColoursAndFont(grid, attr, dc, grid.IsInSelection(row,i)); grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), rect, hAlign, vAlign); clip.x += grid.GetColSize(i) - 1; } rect = rectCell; rect.Inflate(-1); rect.width++; dc.DestroyClippingRegion(); } } // now we only have to draw the text SetTextColoursAndFont(grid, attr, dc, isSelected); grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), rect, hAlign, vAlign); }
void SjOscTitle::Draw(wxDC& dc, const wxSize& clientSize, bool titleChanged, const wxString& newTitle) { // client size changed? if( m_clientSize != clientSize ) { m_clientSize = clientSize; // create new font int pt = clientSize.y / 20; if( pt < 7 ) pt = 7; m_font.SetPointSize(pt); // calculate new size CalcCurrTitleSize(dc); } // title changed? if( titleChanged ) { if( m_currTitle.IsEmpty() ) { m_currTitle = newTitle; CalcCurrTitleSize(dc); m_titleOp = TITLEOP_WIPEIN; m_titleWipe = 0.0F; } else if( m_titleOp == TITLEOP_WIPEIN ) { m_nextTitle = newTitle; // fast switch - however, this only happens for very short tracks CalcCurrTitleSize(dc); } else if( newTitle != m_currTitle ) { m_nextTitle = newTitle; CalcCurrTitleSize(dc); if( m_titleOp == TITLEOP_NOP ) { m_titleOp = TITLEOP_WIPEOUT; m_titleWipe = 0.0F; } } } // draw the title dc.SetFont(m_font); // scroll? #define SCROLL_PIX 8 #define SCROLL_INITIAL_WAIT_MS 2000 #define SCROLL_LEFT_END_WAIT_MS 2000 #define SCROLL_RIGHT_END_WAIT_MS 12000 if( m_scroll == SCROLL_WAIT ) { m_scrollCnt--; if( m_scrollCnt <= 0 ) { m_scroll = m_currTitleX<0? SCROLL_RIGHT : SCROLL_LEFT; } } else if( m_scroll == SCROLL_LEFT ) { m_currTitleX -= SCROLL_PIX; if( m_currTitleX+m_currTitleW <= m_clientSize.x ) { m_scroll = SCROLL_WAIT; m_scrollCnt = (SCROLL_LEFT_END_WAIT_MS / SLEEP_MS); } } else if( m_scroll == SCROLL_RIGHT ) { m_currTitleX += SCROLL_PIX; if( m_currTitleX >= 0 ) { m_scroll = SCROLL_WAIT; m_scrollCnt = (SCROLL_RIGHT_END_WAIT_MS / SLEEP_MS); } } // apply our wipe effect if( m_titleOp ) { m_titleWipe += 1.0L/(double)SLEEP_MS; wxRect wipeRect(0, m_currTitleY, m_clientSize.x, m_currTitleH); if( m_titleOp == TITLEOP_WIPEIN ) { wipeRect.width = (int) ( wipeRect.width * m_titleWipe ); } else { wipeRect.x = (int) ( wipeRect.width * m_titleWipe ); } // clip out the wipe rectangle and draw the text //dc.DrawRectangle(wipeRect); dc.SetClippingRegion(wipeRect); dc.DrawText(m_currTitle, m_currTitleX, m_currTitleY); dc.DestroyClippingRegion(); // this wipe done? if( m_titleWipe >= 1.0 ) { if( m_titleOp == TITLEOP_WIPEOUT ) { m_currTitle = m_nextTitle; CalcCurrTitleSize(dc); m_titleOp = TITLEOP_WIPEIN; m_titleWipe = 0.0F; } else { m_titleOp = TITLEOP_NOP; } } } else { // just draw the text, no wiping currently needed dc.DrawText(m_currTitle, m_currTitleX, m_currTitleY); } }