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 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 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 wxStatusBarGeneric::DrawFieldText(wxDC& dc, int i) { int leftMargin = 2; wxRect rect; GetFieldRect(i, rect); wxString text(GetStatusText(i)); long x, y; 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 ClippingBoxTestCaseBase::OneRegion() { // Setting one clipping box inside DC area. m_dc->SetClippingRegion(10, 20, 80, 75); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(10, 20, 80, 75); }
void ClippingBoxTestCaseBase::OneRegionNegDim() { // Setting one clipping box with negative sizes values. // Final clipping box should have standard positive size values. m_dc->SetClippingRegion(10, 20, -80, -75); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(0, 0, 11, 21); }
void ClippingBoxTestCaseBase::OneOuterRegion() { // Setting one clipping box entirely outside DC surface. // Final clipping box should be empty. m_dc->SetClippingRegion(-100, -80, 20, 40); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(0, 0, 0, 0); }
void ClippingBoxTestCaseBase::OneLargeRegion() { // Setting one clipping box larger then DC surface. // Final clipping box should be limited to the DC extents. m_dc->SetClippingRegion(-10, -20, s_dcSize.GetWidth()+30, s_dcSize.GetHeight()+50); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight()); }
void ClippingBoxTestCaseBase::TwoRegionsNonOverlapping() { // Setting one clipping box and next another box (non-overlapping). // Final clipping box should be empty. m_dc->SetClippingRegion(10, 20, 30, 30); m_dc->SetClippingRegion(50, 60, 50, 40); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(0, 0, 0, 0); }
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()); }
void ClippingBoxTestCaseBase::TwoRegionsOverlapping() { // Setting one clipping box and next another box (partially overlapping). // Final clipping box should be an intersection of these two boxes. m_dc->SetClippingRegion(10, 20, 80, 75); m_dc->SetClippingRegion(50, 60, 50, 40); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(50, 60, 40, 35); }
/* 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 SplashScreen::DoPaint( wxDC &dc ) { static const wxString release = "release"; static const wxString revision = "revision"; #ifdef __WIN32__ dc.SetClippingRegion( r ); #endif dc.DrawBitmap( m_label, 0, 0, false ); }
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 ClippingBoxTestCaseBase::OneRegionWithTransformedDC() { // Setting one clipping box inside DC area // with applied some transformations. m_dc->SetDeviceOrigin(10, 15); m_dc->SetUserScale(0.5, 1.5); m_dc->SetLogicalScale(4.0, 2.0); m_dc->SetLogicalOrigin(-15, -20); m_dc->SetClippingRegion(-10, -20, 80, 75); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(-10, -20, 40, 35); }
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 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 Stage::ClipElementsThatDrawThemselves(wxDC &inDC) { // Clip our heavyweight elements, so that we don't attempt to redraw // the stage over movies or edit boxes. Note that we don't use // wxCLIP_CHILDREN here, because some of our children (particularly // movies) *need* to be overdrawn until they're ready to draw // themselves. bool need_clipping = false; wxRegion clip_to(wxRect(wxPoint(0, 0), GetSize())); ElementCollection::iterator i = mElements.begin(); for (; i != mElements.end(); ++i) if ((*i)->IsShown() && (*i)->ApplyClippingToStage(clip_to)) need_clipping = true; // If we actually made any changes to our clipping region, apply it. // The SetClippingRegion function actually calculates the intersection // of the old clipping region and the new one, and uses _that_. // (Remember, we get a new wxDC every time we need to repaint, and the // operating system may attempt to set up a reasonable clipping region // for us.) if (need_clipping) inDC.SetClippingRegion(clip_to); }
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(); }
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 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); }