void ClueListBox::OnDrawItem(wxDC & dc, const wxRect & rect, size_t n) const { wxRect numRect(rect); numRect.SetWidth(m_numWidth); wxRect textRect(rect); textRect.SetX(numRect.GetRight() + GetMargins().x); textRect.SetWidth(rect.width - GetMargins().x); // Get fonts and colors dc.SetFont(GetFont()); if (IsSelected(n)) dc.SetTextForeground(GetSelectionForeground()); else dc.SetTextForeground(GetForegroundColour()); XPuzzle::Clue clue = GetItem(n); dc.DrawLabel(wxString::Format(_T("%d."), clue.Number()), numRect, wxALIGN_RIGHT|wxALIGN_TOP); wxASSERT(! m_cachedClues.at(n).empty()); dc.DrawLabel(m_cachedClues.at(n), textRect); //dc.DrawLine(textRect.x, textRect.y, textRect.x + textRect.width, textRect.y + textRect.height); }
void wxJigsawInputParameter::Draw(wxDC & dc, const wxPoint & pos, const wxSize & offset, double scale, wxColour color) { wxPoint realPosition( pos.x + offset.GetWidth(), pos.y /*+ offset.GetHeight()*/); /*wxLogTrace(wxTraceMask(), _("ParameterPos = %i,%i; Offset=%i, %i"), realPosition.x, realPosition.y, offset.x, offset.y);*/ wxSize labelSize; wxSize size = GetSize(dc, scale); dc.GetTextExtent(m_Label, &labelSize.x, &labelSize.y, 0, 0, (wxFont *)&dc.GetFont()); //Draw the text with bevel wxRect rectText(realPosition, size); rectText.x++; rectText.y++; dc.SetTextForeground(*wxBLACK); dc.DrawLabel(m_Label, rectText, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); rectText.x--; rectText.y--; dc.SetTextForeground(*wxWHITE); dc.DrawLabel(m_Label, rectText, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); wxPoint shapePos; wxSize shapeSize; if(m_Shape) { shapeSize = m_Shape->GetSize(dc, scale); shapePos = wxPoint( pos.x + labelSize.x + wxJigsawInputParameter::ParameterSpacing*scale, pos.y + (size.GetHeight()-shapeSize.GetHeight())/2); m_Shape->SetPosition(shapePos.x, shapePos.y + (size.GetHeight()-shapeSize.GetHeight())*scale/2 - offset.GetHeight()); m_Shape->Draw(dc, offset, scale); } else { dc.SetPen(*wxBLACK_PEN); wxBrush paramBrush(wxColour(color.Red()*.9,color.Green()*.9,color.Blue()*.9)); dc.SetBrush(paramBrush); //dc.SetBrush(*wxWHITE_BRUSH); shapeSize = wxJigsawInputParameter::GetDefaultParameterSize(); shapeSize.x *= scale; shapeSize.y *= scale; shapePos = wxPoint( realPosition.x + labelSize.x + wxJigsawInputParameter::ParameterSpacing*scale, realPosition.y + (size.GetHeight()-shapeSize.GetHeight())/2); wxJigsawShape::DrawShapeHeader(dc, shapePos, shapeSize, GetStyle()); } //dc.SetBrush(*wxTRANSPARENT_BRUSH); //dc.SetPen(*wxBLACK_PEN); //dc.DrawRectangle(realPosition, size); }
/** * Render the event in the bitmap */ void CppCodeEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform) { #if !defined(GD_NO_WX_GUI) gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get(); const int titleTextHeight = 20; //Draw header rectangle wxRect headerRect(x, y, width, GetRenderedHeight(width, platform)); renderingHelper->DrawNiceRectangle(dc, headerRect); //Header dc.SetFont( renderingHelper->GetNiceFont().Bold() ); dc.SetTextForeground(wxColour(0,0,0)); dc.DrawText( (displayedName.empty() ? _("C++ code") : _("C++ code:")) + displayedName, x + 4, y + 3 ); if ( codeDisplayedInEditor ) { dc.SetFont( renderingHelper->GetFont() ); dc.SetBrush(renderingHelper->GetActionsRectangleFillBrush()); dc.SetPen(renderingHelper->GetActionsRectangleOutlinePen()); dc.DrawRectangle(wxRect(x + 4, y + 3 + titleTextHeight + 2, width-8, GetRenderedHeight(width, platform)-(3 + titleTextHeight + 5))); dc.DrawLabel( inlineCode, wxNullBitmap, wxRect(x + 4, y + 3 + titleTextHeight + 4, width-2, GetRenderedHeight(width, platform))); } #endif }
void wxStdRenderer::DrawItem(wxDC& dc, const wxString& label, const wxRect& rect, int flags) { wxDCTextColourChanger colChanger(dc); if ( flags & wxCONTROL_SELECTED ) { colChanger.Set(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT)); const wxColour colBg = wxSCHEME_COLOUR(m_scheme, HIGHLIGHT); dc.SetBrush(colBg); dc.SetPen(colBg); dc.DrawRectangle(rect); } // horizontal adjustment is arbitrary wxRect rectText = rect; rectText.Deflate(2, ITEM_MARGIN); dc.DrawLabel(label, wxNullBitmap, rectText); if ( flags & wxCONTROL_FOCUSED ) { DrawFocusRect(NULL, dc, rect, flags); } }
void CustomGrid::DrawColLabel( wxDC& dc, int col ) { //init dc font and colours dc.SetFont(m_labelFont); if(col == m_gParent->m_pIndex){ dc.SetBrush(wxBrush(m_greenColour, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_greenColour, 1)); }else { dc.SetBrush(wxBrush(m_labelBackgroundColour, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_labelBackgroundColour, 1)); } //draw retangle wxRect tRect( GetColLeft(col), 1, GetColWidth(col)-2, m_colLabelHeight -2); dc.DrawRectangle(tRect); //draw lines aroud label dc.SetPen(GetDefaultGridLinePen()); dc.DrawLine( GetColLeft(col) -1, 0, GetColRight(col), 0 ); if( col > -1 && (col == 0 || GetColLabelValue( col ).BeforeFirst('-') != GetColLabelValue( col - 1 ).BeforeFirst('-')) ) dc.SetPen(wxPen(*wxBLACK, 4)); dc.DrawLine( GetColLeft(col) -1, 0, GetColLeft(col) - 1, m_colLabelHeight); if( col == m_numCols - 1 ){ dc.SetPen(wxPen(*wxBLACK, 4)); dc.DrawLine( GetColRight(col), 0, GetColRight(col), m_colLabelHeight); } //then draw label dc.DrawLabel(GetColLabelValue(col), tRect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL); }
void CustomGrid::DrawRowLabel( wxDC& dc, int row ) { //init dc font and colours dc.SetFont( m_labelFont ); dc.SetPen(GetDefaultGridLinePen()); dc.SetBrush( wxBrush( m_labelBackgroundColour, wxBRUSHSTYLE_SOLID ) ); int w = dc.GetTextExtent(_T("Speed")).x; wxString label1,label2; label1 = GetRowLabelValue(row).BeforeFirst(',', &label2); bool pline = true; //row is the first of 3 for the same parameter (wind ... waves ...) if(GetNumberRows() > row + 2 && label1 == GetRowLabelValue(row + 2).BeforeFirst(',')){ pline = false; if(IsRowVisible(row + 2)) label1 = _T(" "); } //row is the second of 3 or the first of 2 else if(GetNumberRows() > row + 1 && label1 == GetRowLabelValue(row + 1).BeforeFirst(',')){ pline = false; if(row > 0 && label1 == GetRowLabelValue(row - 1).BeforeFirst(',')){ //second of 3 if(!IsRowVisible(row + 1)) label1 = _T(" "); } } //row is the last of 3 else if(row > 1 && label1 == GetRowLabelValue(row - 2).BeforeFirst(',')){ if(IsRowVisible(row - 1)) label1 = _T(" "); } //row is the last of 2 else if(row > 0 && label1 == GetRowLabelValue(row - 1).BeforeFirst(',')){ if(IsRowVisible(row - 1)) label1 = _T(" "); } //draw first part of the label wxRect aRect(5, GetRowTop(row), m_rowLabelWidth - w, GetRowHeight(row)); dc.DrawLabel(label1, aRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); //draw second part of the label wxRect bRect(m_rowLabelWidth - w, GetRowTop(row), w, GetRowHeight(row)); dc.SetFont( wxFont(m_labelFont).Scale(0.85) ); dc.DrawLabel(label2 , bRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); //draw row lines around labels if(pline) dc.DrawLine(0, GetRowBottom(row) - 1, m_rowLabelWidth, GetRowBottom(row) - 1); dc.DrawLine(0, GetRowTop(row), 0, GetRowBottom(row) ); dc.DrawLine(m_rowLabelWidth - 1, GetRowTop(row), m_rowLabelWidth - 1, GetRowBottom(row) ); }
void wxStdRenderer::DrawButtonLabel(wxDC& dc, const wxString& label, const wxBitmap& image, const wxRect& rect, int flags, int alignment, int indexAccel, wxRect *rectBounds) { wxDCTextColourChanger clrChanger(dc); wxRect rectLabel = rect; if ( !label.empty() && (flags & wxCONTROL_DISABLED) ) { if ( flags & wxCONTROL_PRESSED ) { // shift the label if a button is pressed rectLabel.Offset(1, 1); } // draw shadow of the text clrChanger.Set(m_penHighlight.GetColour()); wxRect rectShadow = rect; rectShadow.Offset(1, 1); dc.DrawLabel(label, rectShadow, alignment, indexAccel); // make the main label text grey clrChanger.Set(m_penDarkGrey.GetColour()); if ( flags & wxCONTROL_FOCUSED ) { // leave enough space for the focus rect rectLabel.Inflate(-2); } } dc.DrawLabel(label, image, rectLabel, alignment, indexAccel, rectBounds); if ( !label.empty() && (flags & wxCONTROL_FOCUSED) ) { rectLabel.Inflate(-1); DrawFocusRect(NULL, dc, rectLabel); } }
void wxGenericStaticText::DoDrawLabel(wxDC& dc, const wxRect& rect) { #if wxUSE_MARKUP if ( m_markupText ) m_markupText->Render(dc, rect, wxMarkupText::Render_ShowAccels); else #endif // wxUSE_MARKUP dc.DrawLabel(m_label, rect, GetAlignment(), m_mnemonic); }
// draw the header control button (used by wxListCtrl) virtual void DrawHeaderButton(wxWindow *win, wxDC& dc, const wxRect& rect, int flags = 0) { dc.SetBrush(*wxCYAN_BRUSH); dc.SetTextForeground(*wxRED); dc.DrawRoundedRectangle(rect, 10); dc.DrawLabel(_T("MyDllRenderer"), wxNullBitmap, rect, wxALIGN_CENTER); }
void ColorChoice::OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const { if (item == wxNOT_FOUND) return; wxRect smallRect = rect; smallRect.Deflate(popupPadding); if (! s_colors[item].color.IsOk()) dc.DrawLabel(other_color, smallRect, wxALIGN_CENTER_VERTICAL); else Draw(dc, rect, s_colors[item].color, s_colors[item].label); }
virtual int DrawHeaderButton(wxWindow *WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags) = 0, wxHeaderSortIconType WXUNUSED(sortArrow) = wxHDR_SORT_ICON_NONE, wxHeaderButtonParams* WXUNUSED(params) = NULL) { dc.SetBrush(*wxBLUE_BRUSH); dc.SetTextForeground(*wxWHITE); dc.DrawRoundedRectangle(rect, 5); dc.DrawLabel(_T("MyRenderer"), wxNullBitmap, rect, wxALIGN_CENTER); return rect.width; }
void ColorChoice::Draw(wxDC& dc, const wxRect& rect, const wxColour & color, const wxString & label) const { wxRect smallRect(rect); smallRect.Deflate(popupPadding); // Make a box for the color int h = smallRect.GetHeight(); wxRect colorRect = wxRect(smallRect.GetTopLeft(), wxSize(h * 1.5, h)); smallRect.Offset(colorRect.width + popupPadding, 0); dc.SetBrush(wxBrush(color, wxSOLID)); dc.SetPen(*wxBLACK_PEN); dc.DrawRectangle(colorRect); dc.DrawLabel(label, smallRect, wxALIGN_CENTER_VERTICAL); }
virtual int DrawHeaderButton(wxWindow *WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags) = 0, wxHeaderSortIconType WXUNUSED(sortArrow) = wxHDR_SORT_ICON_NONE, wxHeaderButtonParams* params = NULL) { wxDCBrushChanger setBrush(dc, *wxBLUE_BRUSH); wxDCTextColourChanger setFgCol(dc, *wxWHITE); dc.DrawRoundedRectangle(rect, 5); wxString label; if ( params ) label = params->m_labelText; dc.DrawLabel(label, wxNullBitmap, rect, wxALIGN_CENTER); return rect.width; }
/* * Here we do the actual rendering. I put it in a separate * method so that it can work no matter what type of DC * (e.g. wxPaintDC or wxClientDC) is used. */ void wxStateButton::render(wxDC& dc) { int w; int h; dc.GetSize(&w,&h); if (m_bChecked) { dc.SetBrush(*wxGREY_BRUSH); dc.SetTextForeground(wxColor(255, 255, 255)); } else { dc.SetBrush(wxBrush(wxColor(64, 64, 64))); dc.SetTextForeground(*wxLIGHT_GREY); } dc.SetPen(*wxGREY_PEN); wxRect r = GetClientRect(); dc.DrawRectangle(0, 0, w, h); dc.SetFont(wxSystemSettings::GetFont(wxSystemFont::wxSYS_DEFAULT_GUI_FONT)); dc.DrawLabel(GetLabel(), r, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL); }
////////////// // Draw image void BaseGrid::DrawImage(wxDC &dc) { dc.BeginDrawing(); // Get size and pos int w = 0; int h = 0; GetClientSize(&w,&h); // Set font dc.SetFont(font); // Clear background dc.SetBackground(wxBrush(Options.AsColour(_T("Grid Background")))); dc.Clear(); // Draw labels dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(Options.AsColour(_T("Grid left column")))); dc.DrawRectangle(0,lineHeight,colWidth[0],h-lineHeight); // Visible lines int drawPerScreen = h/lineHeight + 1; int nDraw = MID(0,drawPerScreen,GetRows()-yPos); int maxH = (nDraw+1) * lineHeight; // Row colors std::vector<wxBrush> rowColors; std::vector<wxColor> foreColors; rowColors.push_back(wxBrush(Options.AsColour(_T("Grid Background")))); // 0 = Standard foreColors.push_back(Options.AsColour(_T("Grid standard foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid Header")))); // 1 = Header foreColors.push_back(Options.AsColour(_T("Grid standard foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selection background")))); // 2 = Selected foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid comment background")))); // 3 = Commented foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid inframe background")))); // 4 = Video Highlighted foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selected comment background")))); // 5 = Commented & selected foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); // First grid row bool drawGrid = true; if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); dc.DrawLine(0,0,w,0); dc.SetPen(*wxTRANSPARENT_PEN); } // Draw rows int dx = 0; int dy = 0; int curColor = 0; AssDialogue *curDiag; for (int i=0;i<nDraw+1;i++) { // Prepare int curRow = i+yPos-1; curDiag = GetDialogue(curRow); dx = 0; dy = i*lineHeight; // Check for collisions bool collides = false; if (curDiag) { AssDialogue *sel = GetDialogue(editBox->linen); if (sel && sel != curDiag) { if (curDiag->CollidesWith(sel)) collides = true; } } // Text array wxArrayString strings; // Header if (i == 0) { strings.Add(_("#")); strings.Add(_("L")); strings.Add(_("Start")); strings.Add(_("End")); strings.Add(_("Style")); strings.Add(_("Actor")); strings.Add(_("Effect")); strings.Add(_("Left")); strings.Add(_("Right")); strings.Add(_("Vert")); strings.Add(_("Text")); curColor = 1; } // Lines else if (curDiag) { // Set fields strings.Add(wxString::Format(_T("%i"),curRow+1)); strings.Add(wxString::Format(_T("%i"),curDiag->Layer)); if (byFrame) { strings.Add(wxString::Format(_T("%i"),VFR_Output.GetFrameAtTime(curDiag->Start.GetMS(),true))); strings.Add(wxString::Format(_T("%i"),VFR_Output.GetFrameAtTime(curDiag->End.GetMS(),true))); } else { strings.Add(curDiag->Start.GetASSFormated()); strings.Add(curDiag->End.GetASSFormated()); } strings.Add(curDiag->Style); strings.Add(curDiag->Actor); strings.Add(curDiag->Effect); strings.Add(curDiag->GetMarginString(1)); strings.Add(curDiag->GetMarginString(2)); strings.Add(curDiag->GetMarginString(3)); // Set text int mode = Options.AsInt(_T("Grid Hide Overrides")); wxString value = _T(""); // Hidden overrides if (mode == 1 || mode == 2) { wxString replaceWith = Options.AsText(_T("Grid hide overrides char")); curDiag->ParseASSTags(); size_t n = curDiag->Blocks.size(); for (size_t i=0;i<n;i++) { AssDialogueBlock *block = curDiag->Blocks.at(i); AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block); if (plain) { value += plain->GetText(); } else { if (mode == 1) { value += replaceWith; } } } curDiag->ClearBlocks(); } // Show overrides else value = curDiag->Text; // Cap length and set text if (value.Length() > 512) value = value.Left(512) + _T("..."); strings.Add(value); // Set color curColor = 0; bool inSel = IsInSelection(curRow,0); if (inSel && curDiag->Comment) curColor = 5; else if (inSel) curColor = 2; else if (curDiag->Comment) curColor = 3; else if (Options.AsBool(_T("Highlight subs in frame")) && IsDisplayed(curDiag)) curColor = 4; } else { for (int j=0;j<11;j++) strings.Add(_T("?")); } // Draw row background color if (curColor) { dc.SetBrush(rowColors[curColor]); dc.DrawRectangle((curColor == 1) ? 0 : colWidth[0],i*lineHeight+1,w,lineHeight); } // Set text color if (collides) dc.SetTextForeground(Options.AsColour(_T("Grid collision foreground"))); else { dc.SetTextForeground(foreColors[curColor]); } // Draw text wxRect cur; bool isCenter; for (int j=0;j<11;j++) { // Is center? isCenter = !(j == 4 || j == 5 || j == 6 || j == 10); // Calculate clipping cur = wxRect(dx+4,dy,colWidth[j]-6,lineHeight); // Set clipping dc.DestroyClippingRegion(); dc.SetClippingRegion(cur); // Draw dc.DrawLabel(strings[j],cur,isCenter ? wxALIGN_CENTER : (wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT)); dx += colWidth[j]; } //if (collides) dc.SetPen(wxPen(wxColour(255,0,0))); // Draw grid dc.DestroyClippingRegion(); if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); dc.DrawLine(0,dy+lineHeight,w,dy+lineHeight); dc.SetPen(*wxTRANSPARENT_PEN); } } // Draw grid columns dx = 0; if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); for (int i=0;i<10;i++) { dx += colWidth[i]; dc.DrawLine(dx,0,dx,maxH); } dc.DrawLine(0,0,0,maxH); dc.DrawLine(w-1,0,w-1,h); } // Draw currently active line border dc.SetPen(wxPen(Options.AsColour(_T("Grid Active border")))); dc.SetBrush(*wxTRANSPARENT_BRUSH); dy = (editBox->linen+1-yPos) * lineHeight; dc.DrawRectangle(0,dy,w,lineHeight+1); // Done dc.EndDrawing(); }
void wxStdRenderer::DrawFrameTitle(wxDC& dc, const wxRect& rect, const wxString& title, int flags) { wxColour col = m_scheme->Get(flags & wxTOPLEVEL_ACTIVE ? wxColourScheme::TITLEBAR_ACTIVE_TEXT : wxColourScheme::TITLEBAR_TEXT); dc.SetTextForeground(col); wxRect r = GetFrameClientArea(rect, flags & ~wxTOPLEVEL_TITLEBAR); r.height = FRAME_TITLEBAR_HEIGHT; if ( flags & wxTOPLEVEL_ICON ) { r.x += FRAME_TITLEBAR_HEIGHT; r.width -= FRAME_TITLEBAR_HEIGHT + 2; } else { r.x += 1; r.width -= 3; } if ( flags & wxTOPLEVEL_BUTTON_CLOSE ) r.width -= FRAME_BUTTON_WIDTH + 2; if ( flags & wxTOPLEVEL_BUTTON_MAXIMIZE ) r.width -= FRAME_BUTTON_WIDTH; if ( flags & wxTOPLEVEL_BUTTON_RESTORE ) r.width -= FRAME_BUTTON_WIDTH; if ( flags & wxTOPLEVEL_BUTTON_ICONIZE ) r.width -= FRAME_BUTTON_WIDTH; if ( flags & wxTOPLEVEL_BUTTON_HELP ) r.width -= FRAME_BUTTON_WIDTH; dc.SetFont(m_titlebarFont); wxString s; wxCoord textW; dc.GetTextExtent(title, &textW, NULL); if ( textW > r.width ) { // text is too big, let's shorten it and add "..." after it: size_t len = title.length(); wxCoord WSoFar, letterW; dc.GetTextExtent(wxT("..."), &WSoFar, NULL); if ( WSoFar > r.width ) { // not enough space to draw anything return; } s.Alloc(len); for (size_t i = 0; i < len; i++) { dc.GetTextExtent(title[i], &letterW, NULL); if ( letterW + WSoFar > r.width ) break; WSoFar += letterW; s << title[i]; } s << wxT("..."); } else // no need to truncate the title { s = title; } dc.DrawLabel(s, wxNullBitmap, r, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL); }
// ----------------------------------------------------------------------------- // Using [dc], draw [text] at [left,top], writing the bounds of the drawn text // to [bounds] // ----------------------------------------------------------------------------- int SCallTip::drawText(wxDC& dc, const wxString& text, int left, int top, wxRect* bounds) const { dc.DrawLabel(text, wxNullBitmap, wxRect(left, top, 900, 900), 0, -1, bounds); return bounds->GetRight() + 1; }
//------------------------------------------------------------------------------ // custom renderer //------------------------------------------------------------------------------ void CustomRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) { dc.SetPen(wxPen(attr.GetBackgroundColour(), 1)); dc.SetBrush(wxBrush( attr.GetBackgroundColour(), wxBRUSHSTYLE_SOLID )); dc.DrawRectangle( rect ); if( m_IsDigit || m_dDir == GRIB_NOTDEF ) { //digital format wxString text(wxEmptyString); if( m_dDir != GRIB_NOTDEF ) text.Printf(_T("%03d\u00B0"), (int)m_dDir); dc.DrawLabel(text, rect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); } else { //graphical format double si = sin( (m_dDir - 90) * M_PI / 180. ); double co = cos( (m_dDir - 90) * M_PI / 180. ); int i = rect.GetTopLeft().x + (rect.GetWidth() / 2); int j = rect.GetTopLeft().y + (rect.GetHeight() / 2); int arrowSize = rect.GetHeight() - 3; int dec = -arrowSize / 2; #if wxUSE_GRAPHICS_CONTEXT wxGraphicsContext *gdc; wxClientDC *cdc = new wxClientDC(wxDynamicCast( &grid, wxWindow)); cdc = wxDynamicCast(&dc, wxClientDC); if( cdc ) { gdc = wxGraphicsContext::Create(*cdc); #ifdef __WXGTK__ /*platforms don't manage the same way the gdc origin for linux, we have to re-compute the good one. To DO : verify it works on all other plateforms (done for MSW*/ bool vis = false; int r = 0; for( int c = 0; c < grid.GetNumberCols(); c++){ for(r = 0; r < grid.GetNumberRows(); r++) { if(grid.IsVisible(r, c)){ //find the first row/col vis = true; i -= (c * grid.GetColSize(0)); j -= (r * grid.GetRowHeight(0)); break; } } if(vis) break; } #endif gdc->SetPen(wxPen(attr.GetTextColour(), 3)); gdc->SetBrush(wxBrush( attr.GetBackgroundColour(), wxBRUSHSTYLE_SOLID )); double ii, jj, kk, ll; GetArrowsPoints( si, co, i, j, dec, 0, dec + arrowSize, 0, ii, jj, kk, ll ); gdc->StrokeLine( ii, jj, kk, ll ); GetArrowsPoints( si, co, i, j, dec - 3, 0, dec + 5, 3, ii, jj, kk, ll ); gdc->StrokeLine( ii, jj, kk, ll ); GetArrowsPoints( si, co, i, j, dec - 3, 0, dec + 5, -3, ii, jj, kk, ll ); gdc->StrokeLine( ii, jj, kk, ll ); delete gdc; } else #endif { dc.SetPen(wxPen(attr.GetTextColour(), 3)); double ii, jj, kk, ll; GetArrowsPoints( si, co, i, j, dec, 0, dec + arrowSize, 0, ii, jj, kk, ll ); dc.DrawLine( (int)ii, (int)jj, (int)kk, (int)ll ); GetArrowsPoints( si, co, i, j, dec - 3, 0, dec + 5, 3, ii, jj, kk, ll ); dc.DrawLine( (int)ii, (int)jj, (int)kk, (int)ll ); GetArrowsPoints( si, co, i, j, dec - 3, 0, dec + 5, -3, ii, jj, kk, ll ); dc.DrawLine( (int)ii, (int)jj, (int)kk, (int)ll ); } } }
void wxAuiMSWTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { if ( !IsThemed() ) { wxAuiGenericTabArt::DrawTab(dc, wnd, page, in_rect, close_button_state, out_tab_rect, out_button_rect, x_extent); return; } if ( !m_closeBtnSize.IsFullySpecified() ) InitSizes(wnd, dc); // figure out the size of the tab wxSize tabSize = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tabHeight = tabSize.y; wxCoord tabWidth = tabSize.x; wxCoord tabX = in_rect.x; wxCoord tabY = 0; if (!page.active) { tabY += wnd->FromDIP(2); tabHeight -= wnd->FromDIP(2); } else { tabX -= wnd->FromDIP(2); tabWidth += wnd->FromDIP(4); tabHeight += 2; } int clipWidth = tabWidth; if ( tabX + clipWidth > in_rect.x + in_rect.width ) clipWidth = (in_rect.x + in_rect.width) - tabX; dc.SetClippingRegion(tabX - wnd->FromDIP(2), tabY, clipWidth + wnd->FromDIP(4), tabHeight); // draw tab wxRect tabRect(tabX, tabY, tabWidth, tabHeight); int tabState; if ( page.active ) tabState = TIS_SELECTED; else if ( page.hover ) tabState = TIS_HOT; else tabState = TIS_NORMAL; wxUxThemeHandle hTabTheme(wnd, L"Tab"); RECT tabR; wxCopyRectToRECT(tabRect, tabR); ::DrawThemeBackground(hTabTheme, GetHdcOf(dc.GetTempHDC()), TABP_TABITEM, tabState, &tabR, NULL); // Apparently, in at least some Windows 10 installations the call above // does not draw the left edge of the first tab and it needs to be drawn // separately, or it wouldn't be drawn at all. if ( tabX == GetIndentSize() ) { ::DrawThemeBackground ( hTabTheme, GetHdcOf(dc.GetTempHDC()), TABP_TABITEMLEFTEDGE, tabState, &tabR, NULL ); } wxRect textRect = tabRect; if ( !page.active ) textRect.Offset(0, wnd->FromDIP(1)); if ( close_button_state != wxAUI_BUTTON_STATE_HIDDEN ) textRect.width -= m_closeBtnSize.x + wnd->FromDIP(3); dc.SetFont(wnd->GetFont()); dc.DrawLabel(page.caption, page.bitmap, textRect, wxALIGN_CENTRE); // draw focus rectangle if ( page.active && (wnd->FindFocus() == wnd) ) { wxRect focusRect = tabRect; focusRect.Deflate(wnd->FromDIP(2)); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if ( close_button_state != wxAUI_BUTTON_STATE_HIDDEN ) { wxUxThemeHandle hToolTipTheme(wnd, L"TOOLTIP"); int btnState; if ( close_button_state == wxAUI_BUTTON_STATE_HOVER ) btnState = TTCS_HOT; else if ( close_button_state == wxAUI_BUTTON_STATE_PRESSED ) btnState = TTCS_PRESSED; else btnState = TTCS_NORMAL; int offsetY = tabY; if ( wxGetWinVersion() < wxWinVersion_Vista ) offsetY++; // WinXP theme needs a little more padding wxRect rect(tabX + tabWidth - m_closeBtnSize.x - wnd->FromDIP(4), offsetY + (tabHeight / 2) - (m_closeBtnSize.y / 2), m_closeBtnSize.x, m_closeBtnSize.y); RECT btnR; wxCopyRectToRECT(rect, btnR); ::DrawThemeBackground(hToolTipTheme, GetHdcOf(dc.GetTempHDC()), TTP_CLOSE, btnState, &btnR, NULL); if ( out_button_rect ) *out_button_rect = rect; } *out_tab_rect = wxRect(tabX, tabY, tabWidth, tabHeight); dc.DestroyClippingRegion(); }
// ----------------------------------------------------------------------------- // Using [dc], draw the calltip contents at [xoff,yoff]. // Returns the dimensions of the drawn calltip text // ----------------------------------------------------------------------------- wxSize SCallTip::drawCallTip(wxDC& dc, int xoff, int yoff) { wxSize ct_size; auto bold = font_.Bold(); // Setup faded text colour ColRGBA faded; if (txed_calltips_dim_optional) faded = ColRGBA( (uint8_t)round((col_fg_.r + col_bg_.r) * 0.5), (uint8_t)round((col_fg_.g + col_bg_.g) * 0.5), (uint8_t)round((col_fg_.b + col_bg_.b) * 0.5)); else faded = col_fg_; // Clear dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(WXCOL(col_bg_))); dc.DrawRectangle(0, 0, 1000, 1000); // Wx Colours (to avoid creating them multiple times) wxcol_fg = WXCOL(col_fg_); wxcol_fg_hl = WXCOL(col_fg_hl); wxcol_type = WXCOL(col_type_); auto wxcol_faded = WXCOL(faded); if (function_) { dc.SetFont(font_); dc.SetTextForeground(wxcol_fg); wxRect rect; int left = xoff; int max_right = 0; int bottom = yoff; // Context switching calltip if (switch_contexts_) { // up-filled \xE2\x96\xB2 // up-empty \xE2\x96\xB3 // down-filled \xE2\x96\xBC // down-empty \xE2\x96\xBD // Up arrow dc.SetTextForeground((btn_mouse_over_ == 2) ? wxcol_fg_hl : wxcol_fg); dc.DrawLabel( wxString::FromUTF8("\xE2\x96\xB2"), wxNullBitmap, wxRect(xoff, yoff, 100, 100), 0, -1, &rect_btn_up_); // Arg set int width = dc.GetTextExtent("X/X").x; dc.SetTextForeground(wxcol_fg); dc.DrawLabel( wxString::Format("%lu/%lu", context_current_ + 1, function_->contexts().size()), wxNullBitmap, wxRect(rect_btn_up_.GetRight() + UI::scalePx(4), yoff, width, 900), wxALIGN_CENTER_HORIZONTAL); // Down arrow dc.SetTextForeground((btn_mouse_over_ == 1) ? wxcol_fg_hl : wxcol_fg); dc.DrawLabel( wxString::FromUTF8("\xE2\x96\xBC"), wxNullBitmap, wxRect(rect_btn_up_.GetRight() + width + UI::scalePx(8), yoff, 900, 900), 0, -1, &rect_btn_down_); left = rect_btn_down_.GetRight() + UI::scalePx(8); rect_btn_up_.Offset(WxUtils::scaledPoint(12, 8)); rect_btn_down_.Offset(WxUtils::scaledPoint(12, 8)); // Draw function (current context) rect = drawFunctionContext(dc, context_, left, yoff, wxcol_faded, bold); max_right = rect.GetRight(); bottom = rect.GetBottom(); } // Normal calltip - show (potentially) multiple contexts else { // Determine separator colour wxColour col_sep; if (col_bg_.greyscale().r < 128) col_sep = WXCOL(col_bg_.amp(30, 30, 30, 0)); else col_sep = WXCOL(col_bg_.amp(-30, -30, -30, 0)); bool first = true; auto num = std::min<unsigned long>(function_->contexts().size(), 12u); for (auto a = 0u; a < num; a++) { auto& context = function_->contexts()[a]; if (!first) { dc.SetPen(wxPen(col_sep)); dc.DrawLine(xoff, bottom + 5, 2000, bottom + 5); } rect = drawFunctionContext( dc, context, xoff, bottom + (first ? 0 : UI::scalePx(11)), wxcol_faded, bold); bottom = (int)round(rect.GetBottom() + UI::scaleFactor()); max_right = std::max(max_right, rect.GetRight()); first = false; } // Show '... # more' if there are too many contexts if (function_->contexts().size() > num) { dc.SetTextForeground(wxcol_faded); drawText( dc, wxString::Format("... %lu more", function_->contexts().size() - num), xoff, bottom + UI::scalePx(11), &rect); bottom = (int)round(rect.GetBottom() + UI::scaleFactor()); } if (num > 1) bottom--; } if (!rect.IsEmpty() && !context_.description.empty()) { auto rect_desc = drawFunctionDescription(dc, context_.description, left, rect.GetBottom()); max_right = std::max(max_right, rect_desc.GetRight()); bottom = rect_desc.GetBottom(); } // Size buffer bitmap to fit ct_size.SetWidth((int)round(max_right + UI::scaleFactor())); ct_size.SetHeight((int)round(bottom + UI::scaleFactor())); } else { // No function, empty buffer ct_size.SetWidth(16); ct_size.SetHeight(16); } return ct_size; }
void wxJigsawShape::Draw(wxDC & dc, const wxSize & offset, double scale) { // Size of shape header wxSize headerSize = GetHeaderSize(dc, scale); // Size of whole shape wxSize size = GetSize(dc, scale); // Real position on DC, including offset wxPoint realPosition(m_Position.x+offset.x, m_Position.y+offset.y); // Start position of input parameters (top left corner of the rectangle which contains parameters) wxPoint parametersPos = GetinputParametersPosition(dc, scale); // Increment by offset // Size of input parameter (needed for drawing of each parameter) wxSize paramSize(0,0); // Draw background of a shape with connectors and C-Shape wxColour color(DrawBackground(dc, realPosition, headerSize, size, scale)); // Rectangle wich contains a label wxRect labelRect(realPosition.x + wxJigsawShape::ShapeLabelOffset.GetWidth()*scale, realPosition.y, headerSize.GetWidth()-2*wxJigsawShape::ShapeLabelOffset.GetWidth()*scale, headerSize.GetHeight()); // Draw a label (on the left side of a shape and centerred vertically) with a little bevel (to contrast with white backgrounds) dc.SetFont(labelFont); if(m_Bitmap.IsOk()) { labelRect.x++; labelRect.y++; dc.SetTextForeground(*wxBLACK); dc.DrawLabel(m_Name, m_Bitmap, labelRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); labelRect.x--; labelRect.y--; dc.SetTextForeground(*wxWHITE); dc.DrawLabel(m_Name, m_Bitmap, labelRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); } else { labelRect.x++; labelRect.y++; dc.SetTextForeground(*wxBLACK); dc.DrawLabel(m_Name, labelRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); labelRect.x--; labelRect.y--; dc.SetTextForeground(*wxWHITE); dc.DrawLabel(m_Name, labelRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); } // Draw parameters int paramIndex = 0; wxJigsawShapeHitTestInfo info = wxJigsawEditorMainFrame::Get()->GetCanvas()->GetSelectedShapeInfo(); for(wxJigsawInputParameters::Node * node = m_InputParameters.GetFirst(); node; node = node->GetNext(), paramIndex++) { // Obtain a pointer to input parameter wxJigsawInputParameter * param = node->GetData(); // Obtain parameter's size paramSize = param->GetSize(dc, scale); // Draw the parameter parametersPos.y = realPosition.y + (headerSize.GetHeight()-paramSize.GetHeight())/2; wxColour colorSlot(color); if(info.GetShape() == this && info.GetInputParameterIndex() == paramIndex) { //Highlight the slot double bright = 1.08; colorSlot.Set(__min(bright*color.Red(), 255), __min(bright*color.Green(), 255), __min(bright*color.Blue(), 255)); } param->Draw(dc, parametersPos, offset, scale, colorSlot); // Move to next parameter parametersPos.x += paramSize.GetWidth() + wxJigsawInputParameter::ParameterSpacing*scale; } wxPoint pos(0, m_Position.y + headerSize.GetHeight()); for(wxJigsawShapeList::Node * node = m_Children.GetFirst(); node; node = node->GetNext()) { wxJigsawShape * child = node->GetData(); if(!child) continue; child->SetPosition(wxPoint(child->GetPosition().x, pos.y)); child->Draw(dc, offset, scale); pos.y += child->GetSize(dc, scale).GetHeight(); } }
/// Draw the item bool InstanceVisual::Draw(wxDC& dc, InstanceCtrl* ctrl, const wxRect& rect, int style) { wxColour backgroundColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); wxColour highlightTextColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); wxColour focus_color = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); wxColour focussedSelection = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); wxRect imageRect(rect.x + (rect.width - 32) / 2, rect.y, 32, 32); if (style & wxINST_SELECTED) { wxBrush brush(focus_color); wxPen pen(focus_color); dc.SetBrush(brush); dc.SetPen(pen); } else { wxBrush brush(backgroundColor); wxPen pen(backgroundColor); dc.SetBrush(brush); dc.SetPen(pen); } // Draw the label wxString name = m_inst->GetName(); if (!name.IsEmpty()) { int margin = ctrl->GetItemMargin(); wxRect textRect; textRect.x = rect.x + margin; textRect.y = rect.y + imageRect.height + 2 * margin; textRect.width = rect.width - 2 * margin; dc.SetFont(ctrl->GetFont()); if (style & wxINST_SELECTED) dc.SetTextForeground(highlightTextColor); else dc.SetTextForeground(textColor); dc.SetBackgroundMode(wxTRANSPARENT); int yoffset = 0; wxSize textsize = dc.GetMultiLineTextExtent(name_wrapped); textRect.height = textsize.GetHeight(); if (style & wxINST_SELECTED) { wxRect hiRect; hiRect.x = rect.x + (rect.width - textsize.x) / 2 - margin; hiRect.y = textRect.y - margin; hiRect.SetSize(textsize + wxSize(2 * margin, 2 * margin)); dc.DrawRectangle(hiRect); } dc.DrawLabel(name_wrapped, textRect, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL); } // Draw the icon auto list = InstIconList::Instance(); wxImage icon; if (style & wxINST_SELECTED) icon = list->getHLImageForKey(m_inst->GetIconKey()); else icon = list->getImageForKey(m_inst->GetIconKey()); wxBitmap bmap = wxBitmap(icon); int x = imageRect.x + (imageRect.width - bmap.GetWidth()) / 2; int y = imageRect.y + (imageRect.height - bmap.GetHeight()) / 2; dc.DrawBitmap(bmap , x, y, true); return true; }