void wxCustomStatusBarFieldText::Render(wxDC& dc, const wxRect& rect, wxCustomStatusBarArt::Ptr_t art) { m_rect = rect; wxSize textSize = dc.GetTextExtent(m_text); // Center text wxCoord textY = (rect.GetHeight() - textSize.GetHeight()) / 2 + rect.y; wxCoord textX; if(m_textAlign == wxALIGN_CENTER) { textX = (rect.GetWidth() - textSize.GetWidth()) / 2 + rect.x; } else { // left textX = rect.x + 5; } // draw border line art->DrawFieldSeparator(dc, rect); // Draw the text art->DrawText(dc, textX, textY + 1, m_text); }
void DrawingUtils::PaintStraightGradientBox(wxDC& dc, const wxRect& rect, const wxColour& startColor, const wxColour& endColor, bool vertical) { int rd, gd, bd, high = 0; rd = endColor.Red() - startColor.Red(); gd = endColor.Green() - startColor.Green(); bd = endColor.Blue() - startColor.Blue(); /// Save the current pen and brush wxPen savedPen = dc.GetPen(); wxBrush savedBrush = dc.GetBrush(); if(vertical) high = rect.GetHeight() - 1; else high = rect.GetWidth() - 1; if(high < 1) return; for(int i = 0; i <= high; ++i) { int r = startColor.Red() + ((i * rd * 100) / high) / 100; int g = startColor.Green() + ((i * gd * 100) / high) / 100; int b = startColor.Blue() + ((i * bd * 100) / high) / 100; wxPen p(wxColor(r, g, b)); dc.SetPen(p); if(vertical) dc.DrawLine(rect.x, rect.y + i, rect.x + rect.width, rect.y + i); else dc.DrawLine(rect.x + i, rect.y, rect.x + i, rect.y + rect.height); } /// Restore the pen and brush dc.SetPen(savedPen); dc.SetBrush(savedBrush); }
void CPathItem::DrawFore(wxDC &dc, wxRect &rc) { dc.SetTextForeground(*wxBLACK); wxString csName(_T("mixer")); if(NULL != m_pInput) { const char *nname = m_pInput->GetName(); const char *dname = m_pInput->GetDisplayName(); csName = (wxChar*)(strlen(nname) > strlen(dname) ? dname : nname); } int width = rc.GetWidth(); if(!m_bFirst) width -= CORNER_LENGTH; wxFont oldFont = dc.GetFont(); wxFont font(7, wxSWISS, wxNORMAL, wxNORMAL); font.SetWeight(IsSelected() ? wxBOLD : wxNORMAL); font.SetStyle(IsSelected() ? wxITALIC : wxNORMAL ); font.SetPointSize( 7 ); dc.SetFont( font ); int w=0, h=0; dc.GetTextExtent(csName, &w, &h); if(h<rc.GetHeight()) { if(w>width) { csName.Printf(_T("%c"),csName[0]); dc.GetTextExtent(csName, &w, &h); } int x = rc.GetX() + width/2 - w/2 + (m_bFirst ? 0 : CORNER_LENGTH); int y = rc.GetY() + rc.GetHeight()/2 - h/2; dc.DrawText( csName, x, y ); } dc.SetFont( oldFont ); }
wxArrayString wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid& grid, wxDC& dc, const wxGridCellAttr& attr, const wxRect& rect, int row, int col) { dc.SetFont(attr.GetFont()); const wxCoord maxWidth = rect.GetWidth(); // Transform logical lines into physical ones, wrapping the longer ones. const wxArrayString logicalLines = wxSplit(grid.GetCellValue(row, col), '\n', '\0'); // Trying to do anything if the column is hidden anyhow doesn't make sense // and we run into problems in BreakLine() in this case. if ( maxWidth <= 0 ) return logicalLines; wxArrayString physicalLines; for ( wxArrayString::const_iterator it = logicalLines.begin(); it != logicalLines.end(); ++it ) { const wxString& line = *it; if ( dc.GetTextExtent(line).x > maxWidth ) { // Line does not fit, break it up. BreakLine(dc, line, maxWidth, physicalLines); } else // The entire line fits as is { physicalLines.push_back(line); } } return physicalLines; }
void CPathCtrl::DrawFore(wxDC &dc, wxRect &rc) { rc.Deflate(0, 2); // rc.SetWidth(rc.GetWidth() - CORNER_LENGTH); int count = m_PathList.GetCount(); if(count > 0) { wxRect rcItem = rc; int width = rc.GetWidth() / count; rcItem.SetWidth(width); ItemList::Node *node = m_PathList.GetFirst(); while (node) { CPathItem *item = (CPathItem*)node->GetData(); item->DrawFore(dc, rcItem); rcItem.Offset(width, 0); node = node->GetNext(); } } }
void wxAuiGenericTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { // draw background wxColor top_color = m_baseColour.ChangeLightness(90); wxColor bottom_color = m_baseColour.ChangeLightness(170); wxRect r; if (m_flags &wxAUI_NB_BOTTOM) r = wxRect(rect.x, rect.y, rect.width+2, rect.height); // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP r = wxRect(rect.x, rect.y, rect.width+2, rect.height-3); dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); // draw base lines dc.SetPen(m_borderPen); int y = rect.GetHeight(); int w = rect.GetWidth(); if (m_flags &wxAUI_NB_BOTTOM) { dc.SetBrush(wxBrush(bottom_color)); dc.DrawRectangle(-1, 0, w+2, 4); } // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP { dc.SetBrush(m_baseColourBrush); dc.DrawRectangle(-1, y-4, w+2, 4); } }
void BrowseTileListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const { ItemsMap::const_iterator item_iterator = items.find(int(n)); Item* item = item_iterator->second; Sprite* sprite = gui.gfx.getSprite(item->getClientID()); if (sprite) sprite->DrawTo(&dc, SPRITE_SIZE_32x32, rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight()); if (IsSelected(n)) { item->select(); dc.SetTextForeground(wxColor(0xFF, 0xFF, 0xFF)); } else { item->deselect(); dc.SetTextForeground(wxColor(0x00, 0x00, 0x00)); } wxString label; label << item->getID() << wxT(" - ") << item->getName(); dc.DrawText(label, rect.GetX() + 40, rect.GetY() + 6); }
void SAuiTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { // draw background wxColor top_color = (m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour; wxColor bottom_color = (m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour; wxRect r; if (m_flags &wxAUI_NB_BOTTOM) r = wxRect(rect.x, rect.y, rect.width + 2, rect.height); else r = wxRect(rect.x, rect.y, rect.width + 2, rect.height); dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); // draw base lines dc.SetPen(wxPen(m_baseColour)); int y = rect.GetHeight(); int w = rect.GetWidth(); if (m_flags &wxAUI_NB_BOTTOM) { dc.SetBrush(wxBrush(bottom_color)); dc.DrawRectangle(-1, 0, w + 2, 4); } else { //dc.SetPen(*wxTRANSPARENT_PEN); //dc.SetBrush(wxBrush(m_activeColour)); //dc.SetBrush(wxBrush(wxColor(224, 238, 255))); //dc.DrawRectangle(-1, y - 4, w + 2, 4); dc.SetPen(m_borderPen); dc.DrawLine(-2, y - 1, w + 2, y - 1); } }
void clAuiDockArt::DrawPaneButton( wxDC& dc, wxWindow* window, int button, int button_state, const wxRect& _rect, wxAuiPaneInfo& pane) { int xx = _rect.GetTopLeft().x + ((_rect.GetWidth() - AUI_BUTTON_SIZE) / 2); int yy = _rect.GetTopLeft().y + ((_rect.GetHeight() - AUI_BUTTON_SIZE) / 2); switch(button) { case wxAUI_BUTTON_CLOSE: dc.DrawBitmap(m_dockCloseBmp, xx, yy); break; case wxAUI_BUTTON_MAXIMIZE_RESTORE: if(pane.IsMaximized()) { dc.DrawBitmap(m_dockMinimizeBmp, xx, yy); } else { dc.DrawBitmap(m_dockExpandeBmp, xx, yy); } break; case wxAUI_BUTTON_PIN: dc.DrawBitmap(m_dockMoreBmp, xx, yy); break; default: wxAuiDefaultDockArt::DrawPaneButton(dc, window, button, button_state, _rect, pane); break; } }
static void DrawGradientRectangle(wxDC& dc, const wxRect& rect, const wxColour& start_color, const wxColour& end_color, int direction) { int rd, gd, bd, high = 0; rd = end_color.Red() - start_color.Red(); gd = end_color.Green() - start_color.Green(); bd = end_color.Blue() - start_color.Blue(); if (direction == wxAUI_GRADIENT_VERTICAL) high = rect.GetHeight()-1; else high = rect.GetWidth()-1; for (int i = 0; i <= high; ++i) { int r,g,b; r = start_color.Red() + (high <= 0 ? 0 : (((i*rd*100)/high)/100)); g = start_color.Green() + (high <= 0 ? 0 : (((i*gd*100)/high)/100)); b = start_color.Blue() + (high <= 0 ? 0 : (((i*bd*100)/high)/100)); wxPen p(wxColor((unsigned char)r, (unsigned char)g, (unsigned char)b)); dc.SetPen(p); if (direction == wxAUI_GRADIENT_VERTICAL) dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i); else dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height); } }
void CParameter::DrawFore(wxDC& dc, wxRect& rc) { m_iSamplesPerPixel = m_pTracks->GetSamplesPerPixel(); if(m_fMax == 0.f) return; m_fScale = (float)rc.GetHeight() / (float)(m_fMax - m_fMin); int start = m_pRegion->GetStartPos(); int end = m_pRegion->GetEndPos(); int offset = m_pRegion->GetStartOffset(); int top = rc.GetTop(); int bottom = rc.GetTop() + rc.GetHeight(); int left = rc.GetX() + 1; int right = left + rc.GetWidth() - 1; float value = 0.f; int prevX = left; int prevY = bottom; int pos = m_bAfterTrack ? 0 : start; bool bLoaded = false; bool bDrawCircle = true; if(!m_pInput->GetParamAt(pos, m_index, &value)) { pos = m_pInput->GetPrevOffset(pos); bDrawCircle = false; } else bLoaded = true; wxPen oldpen = dc.GetPen(); wxColor color = m_color; if( IsSelected() ) color.Set(255-color.Red(), 255-color.Green(), 255-color.Blue()); dc.SetPen( wxPen(color) ); do { if(m_pInput->GetParamAt(pos, m_index, &value)) { bLoaded = true; int x = pos; int y = (int)((float)bottom - (value * m_fScale)); if(y>top && y<bottom) { if(m_bAfterTrack && offset>=0) x += start - offset; x /= m_iSamplesPerPixel; if(x <= left) prevX = left; else if(x >= right) y = prevY; else { dc.DrawLine(prevX, prevY, x, prevY); // Horizontal line dc.DrawLine(x, prevY, x, y); // Vertical line if( bDrawCircle ) { if(m_pSelectedPoint && m_pSelectedPoint->m_offset==pos && m_pSelectedPoint->m_value==value) { dc.DrawRectangle(x-3, y-3, 6, 6); // Selected parameter } else dc.DrawCircle(x, y, 3); // Parameter } prevX = x; } bDrawCircle = true; prevY = y; } } pos = m_pInput->GetNextOffset(pos); } while ( pos>0 && pos<end && prevX<right ); if(bLoaded && prevX<right) // there have been parameters! dc.DrawLine(prevX, prevY, right, prevY); dc.SetPen(oldpen); }
void wxSFGridShape::FitShapeToRect(wxSFShapeBase *shape, const wxRect& rct) { wxRect shapeBB = shape->GetBoundingBox(); wxRealPoint prevPos = shape->GetRelativePosition(); // do vertical alignment switch( shape->GetVAlign() ) { case valignTOP: shape->SetRelativePosition( prevPos.x, rct.GetTop() + shape->GetVBorder() ); break; case valignMIDDLE: shape->SetRelativePosition( prevPos.x, rct.GetTop() + (rct.GetHeight()/2 - shapeBB.GetHeight()/2) ); break; case valignBOTTOM: shape->SetRelativePosition( prevPos.x, rct.GetBottom() - shapeBB.GetHeight() - shape->GetVBorder() ); break; case valignEXPAND: if( shape->ContainsStyle( sfsSIZE_CHANGE ) ) { shape->SetRelativePosition( prevPos.x, rct.GetTop() + shape->GetVBorder() ); shape->Scale( 1.f, double(rct.GetHeight() - 2*shape->GetVBorder())/shapeBB.GetHeight() ); } break; default: shape->SetRelativePosition( prevPos.x, rct.GetTop() ); break; } prevPos = shape->GetRelativePosition(); // do horizontal alignment switch( shape->GetHAlign() ) { case halignLEFT: shape->SetRelativePosition( rct.GetLeft() + shape->GetHBorder(), prevPos.y ); break; case halignCENTER: shape->SetRelativePosition( rct.GetLeft() + (rct.GetWidth()/2 - shapeBB.GetWidth()/2), prevPos.y ); break; case halignRIGHT: shape->SetRelativePosition( rct.GetRight() - shapeBB.GetWidth() - shape->GetHBorder(), prevPos.y ); break; case halignEXPAND: if( shape->ContainsStyle( sfsSIZE_CHANGE ) ) { shape->SetRelativePosition( rct.GetLeft() + shape->GetHBorder(), prevPos.y ); shape->Scale( double(rct.GetWidth() - 2*shape->GetHBorder())/shapeBB.GetWidth(), 1.f ); } break; default: shape->SetRelativePosition( rct.GetLeft(), prevPos.y ); break; } }
void ImageButton::SetGrid(const wxRect& rect) { SetGrid(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight()); }
void SDC::DrawRectangle(const wxRect& rect) { DrawRectangle(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight()); }
bool Camera_StarfishClass::Capture(int duration, usImage& img, int options, const wxRect& subframe) { bool debug = true; int xsize, ysize, xpos, ypos; bool usingSubFrames = UseSubframes && subframe.GetWidth() > 0 && subframe.GetHeight() > 0; IOReturn rval; // init memory if (img.Init(FullSize)) { DisconnectWithAlert(CAPT_FAIL_MEMORY); return true; } if (usingSubFrames) { xsize = subframe.GetWidth(); ysize = subframe.GetHeight(); xpos = subframe.GetLeft(); ypos = subframe.GetTop(); subImage.Init(xsize, ysize); subImage.Clear(); } else { xsize = FullSize.GetWidth(); ysize = FullSize.GetHeight(); xpos = 0; ypos = 0; } img.Clear(); // set ROI if something has changed if (lastSubFrame != subframe) { rval = fcUsb_cmd_setRoi(CamNum, (unsigned short)xpos, (unsigned short)ypos, (unsigned short)(xpos + xsize - 1), (unsigned short)(ypos + ysize - 1)); //Debug.AddLine(wxString::Format("Starfish: using %s", usingSubFrames ? " sub-frames" : " full frames")); //Debug.AddLine(wxString::Format("Starfish: ROI set from {%d,%d} to {%d,%d)", xpos, ypos, xpos + xsize - 1, ypos + ysize - 1)); if (rval != kIOReturnSuccess) { if (debug) pFrame->Alert(_T("Starfish Err 1")); return true; } lastSubFrame = subframe; } // set duration fcUsb_cmd_setIntegrationTime(CamNum, (unsigned int) duration); rval = fcUsb_cmd_startExposure(CamNum); if (rval != kIOReturnSuccess) { if (debug) pFrame->Alert(_T("Starfish Err 2")); return true; } CameraWatchdog watchdog(duration, GetTimeoutMs()); if (duration > 100) { // wait until near end of exposure if (WorkerThread::MilliSleep(duration - 100, WorkerThread::INT_ANY) && (WorkerThread::TerminateRequested() || StopExposure(CamNum))) { return true; } } // wait for image to finish and d/l while (fcUsb_cmd_getState(CamNum) != 0) { wxMilliSleep(50); if (WorkerThread::InterruptRequested() && (WorkerThread::TerminateRequested() || StopExposure(CamNum))) { return true; } if (watchdog.Expired()) { DisconnectWithAlert(CAPT_FAIL_TIMEOUT); return true; } } if (usingSubFrames) { rval = fcUsb_cmd_getRawFrame(CamNum, (unsigned short)ysize, (unsigned short)xsize, subImage.ImageData); // Transfer the subframe to the corresponding location in the full-size frame for (int y = 0; y < ysize; y++) { const unsigned short *pSrc = subImage.ImageData + y * xsize; unsigned short *pDest = img.ImageData + (ypos + y) * FullSize.GetWidth() + xpos; for (int x = 0; x < xsize; x++) *pDest++ = *pSrc++; } img.Subframe = subframe; } else { rval = fcUsb_cmd_getRawFrame(CamNum, (unsigned short)ysize, (unsigned short)xsize, img.ImageData); } /* if (rval != kIOReturnSuccess) { if (debug) pFrame->Alert(wxString::Format("Starfish Err 3 %d",rval)); //return true; }*/ if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img); return false; }
void wxPlFrame::SetClientSize( const wxRect &rect ) { SetClientSize( rect.GetWidth(), rect.GetHeight() ); }
// draw the item bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction, wxODStatus stat) { // we do nothing if item isn't ownerdrawn if ( !IsOwnerDrawn() ) return true; wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HDC hdc = GetHdcOf(*impl); RECT rect; wxCopyRectToRECT(rc, rect); { // set the font and colors wxFont font; GetFontToUse(font); wxColour colText, colBack; GetColourToUse(stat, colText, colBack); SelectInHDC selFont(hdc, GetHfontOf(font)); wxMSWImpl::wxTextColoursChanger textCol(hdc, colText, colBack); wxMSWImpl::wxBkModeChanger bkMode(hdc, wxBRUSHSTYLE_TRANSPARENT); AutoHBRUSH hbr(wxColourToPalRGB(colBack)); SelectInHDC selBrush(hdc, hbr); ::FillRect(hdc, &rect, hbr); // using native API because it recognizes '&' wxString text = GetName(); SIZE sizeRect; ::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &sizeRect); int flags = DST_PREFIXTEXT; if ( (stat & wxODDisabled) && !(stat & wxODSelected) ) flags |= DSS_DISABLED; if ( (stat & wxODHidePrefix) ) flags |= DSS_HIDEPREFIX; int x = rc.x + GetMarginWidth(); int y = rc.y + (rc.GetHeight() - sizeRect.cy) / 2; int cx = rc.GetWidth() - GetMarginWidth(); int cy = sizeRect.cy; ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(text), text.length(), x, y, cx, cy, flags); } // reset to default the font, colors and brush if (stat & wxODHasFocus) ::DrawFocusRect(hdc, &rect); return true; }
//------------------------------------------------------------------------------ // 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 FindCmdDlg::ActionList::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const { const bool isCurrent = IsCurrent(n); dc.SetTextForeground(isCurrent ? m_hlTextColor : m_textColor); const unsigned int ypos = rect.y + m_topMargen; unsigned int rightBorder = rect.GetRight(); const tmAction& action = *m_items[n].action; const vector<unsigned int>& hl = m_items[n].hlChars; wxString name = action.name; if (action.bundle) { name += wxT(" - "); name += action.bundle->name; } if ( !action.trigger.empty() ) { const wxString trig = action.trigger + wxT("\x21E5"); dc.SetFont(m_unifont); int trig_width, trig_height; dc.GetTextExtent(trig, &trig_width, &trig_height); // Draw a grey rounded rect as background for trigger const unsigned int bg_height = trig_height + 1; const unsigned int bg_width = trig_width + 10; const unsigned int bg_xpos = rect.GetWidth()-2-bg_width; const unsigned int bg_ypos = rect.y+ (int)((rect.GetHeight()-bg_height)/2.0); dc.SetPen(*wxLIGHT_GREY_PEN); dc.SetBrush(*wxLIGHT_GREY_BRUSH); dc.DrawRoundedRectangle(bg_xpos, bg_ypos, bg_width, bg_height, 2); // Draw the trigger text const wxColour prevColour = dc.GetTextForeground(); dc.SetTextForeground(*wxBLACK); dc.DrawText(trig, bg_xpos + 5, bg_ypos); dc.SetTextForeground(prevColour); rightBorder = bg_xpos; } else if (!action.key.shortcut.empty()) { const wxString& shortcut = action.key.shortcut; dc.SetFont(m_font); int accel_width, accel_height; dc.GetTextExtent(shortcut, &accel_width, &accel_height); const unsigned int xpos = rect.GetWidth()-2-accel_width; dc.DrawText(shortcut, xpos, ypos); rightBorder = xpos; } // Calc extension width static const wxString ext = wxT(".. "); dc.SetFont(m_font); int w, h; dc.GetTextExtent(ext, &w, &h); const unsigned int extwidth = w; // See if we have to resize the action name to fit // note that this is not 100% correct as bold chars take up a bit more space. unsigned int len = name.length(); dc.GetTextExtent(name, &w, &h); if (w > (int)rightBorder) { do { name.resize(--len); dc.GetTextExtent(name, &w, &h); } while (len > 0 && w + extwidth > rightBorder); name += ext; } // Draw action name DrawItemText(dc, rect, name, hl, isCurrent); }
wxImage ScaleImage(wxImage image, double source_scale_factor, double content_scale_factor, wxSize output_size, wxRect usable_rect, LSIFlags flags, const wxColour& fill_color) { if (!image.IsOk()) { wxFAIL_MSG("WxUtils::ScaleImage expects a valid image."); return image; } if (content_scale_factor != 1.0) { output_size *= content_scale_factor; usable_rect.SetPosition(usable_rect.GetPosition() * content_scale_factor); usable_rect.SetSize(usable_rect.GetSize() * content_scale_factor); } // Fix the output size if it's unset. wxSize img_size = image.GetSize(); if (output_size.GetWidth() < 1) output_size.SetWidth( static_cast<int>(img_size.GetWidth() * (content_scale_factor / source_scale_factor))); if (output_size.GetHeight() < 1) output_size.SetHeight( static_cast<int>(img_size.GetHeight() * (content_scale_factor / source_scale_factor))); // Fix the usable rect. If it's empty then the whole canvas is usable. if (usable_rect.IsEmpty()) { // Constructs a temp wxRect 0,0->output_size then move assigns it. usable_rect = output_size; } else if (!usable_rect.Intersects(output_size)) { wxFAIL_MSG("Usable Zone Rectangle is not inside the canvas. Check the output size is correct."); image.Create(1, 1, false); image.SetRGB(0, 0, fill_color.Red(), fill_color.Green(), fill_color.Blue()); if (fill_color.Alpha() == wxALPHA_TRANSPARENT) image.SetMaskColour(fill_color.Red(), fill_color.Green(), fill_color.Blue()); usable_rect = output_size; } // Step 1: Scale the image if ((flags & LSI_SCALE) != LSI_SCALE_NONE) { if (flags & LSI_SCALE_NO_ASPECT) { // Stretch scale without preserving the aspect ratio. bool scale_width = (img_size.GetWidth() > usable_rect.GetWidth() && flags & LSI_SCALE_DOWN) || (img_size.GetWidth() < usable_rect.GetWidth() && flags & LSI_SCALE_UP); bool scale_height = (img_size.GetHeight() > usable_rect.GetHeight() && flags & LSI_SCALE_DOWN) || (img_size.GetHeight() < usable_rect.GetHeight() && flags & LSI_SCALE_UP); if (scale_width || scale_height) { // NOTE: Using BICUBIC instead of HIGH because it's the same internally // except that downscaling uses a box filter with awful obvious aliasing // for non-integral scale factors. image.Rescale(scale_width ? usable_rect.GetWidth() : img_size.GetWidth(), scale_height ? usable_rect.GetHeight() : img_size.GetHeight(), wxIMAGE_QUALITY_BICUBIC); } } else { // Scale while preserving the aspect ratio. double scale = std::min(static_cast<double>(usable_rect.GetWidth()) / img_size.GetWidth(), static_cast<double>(usable_rect.GetHeight()) / img_size.GetHeight()); int target_width = static_cast<int>(img_size.GetWidth() * scale); int target_height = static_cast<int>(img_size.GetHeight() * scale); // Bilinear produces sharper images when upscaling, bicubic tends to smear/blur sharp edges. if (scale > 1.0 && flags & LSI_SCALE_UP) image.Rescale(target_width, target_height, wxIMAGE_QUALITY_BILINEAR); else if (scale < 1.0 && flags & LSI_SCALE_DOWN) image.Rescale(target_width, target_height, wxIMAGE_QUALITY_BICUBIC); } img_size = image.GetSize(); } // Step 2: Resize the canvas to match the output size. // NOTE: If NOT using LSI_SCALE_DOWN then this will implicitly crop the image if (img_size != output_size || usable_rect.GetPosition() != wxPoint()) { wxPoint base = usable_rect.GetPosition(); if (flags & LSI_ALIGN_HCENTER) base.x += (usable_rect.GetWidth() - img_size.GetWidth()) / 2; else if (flags & LSI_ALIGN_RIGHT) base.x += usable_rect.GetWidth() - img_size.GetWidth(); if (flags & LSI_ALIGN_VCENTER) base.y += (usable_rect.GetHeight() - img_size.GetHeight()) / 2; else if (flags & LSI_ALIGN_BOTTOM) base.y += usable_rect.GetHeight() - img_size.GetHeight(); int r = -1, g = -1, b = -1; if (fill_color.Alpha() != wxALPHA_TRANSPARENT) { r = fill_color.Red(); g = fill_color.Green(); b = fill_color.Blue(); } image.Resize(output_size, base, r, g, b); } return image; }
void wxSFShapeBase::_GetCompleteBoundingBox(wxRect &rct, int mask) { //wxASSERT(m_pParentManager); if(!m_pParentManager)return; if( m_lstProcessed.IndexOf(this) != wxNOT_FOUND )return; else m_lstProcessed.Append(this); ShapeList lstChildren; //SerializableList lstConnections; // firts, get bounding box of the current shape if(mask & bbSELF) { if(rct.IsEmpty())rct = this->GetBoundingBox().Inflate( abs(m_nHBorder), abs(m_nVBorder) ); else rct.Union(this->GetBoundingBox().Inflate( abs(m_nHBorder), abs(m_nVBorder)) ); // add also shadow offset if neccessary if( (mask & bbSHADOW) && (m_nStyle & sfsSHOW_SHADOW) && GetParentCanvas() ) { wxRealPoint nOffset = GetParentCanvas()->GetShadowOffset(); if( nOffset.x < 0 ) { rct.SetX(rct.GetX() + (int)nOffset.x); rct.SetWidth(rct.GetWidth() - (int)nOffset.x); } else rct.SetWidth(rct.GetWidth() + (int)nOffset.x); if( nOffset.y < 0 ) { rct.SetY(rct.GetY() + (int)nOffset.y); rct.SetHeight(rct.GetHeight() - (int)nOffset.y); } else rct.SetHeight(rct.GetHeight() + (int)nOffset.y);; } } else mask |= bbSELF; // get list of all connection lines assigned to the shape and find their child shapes if(mask & bbCONNECTIONS) { wxSFShapeBase *pLine; ShapeList lstLines; GetAssignedConnections( CLASSINFO(wxSFLineShape), lineBOTH, lstLines ); ShapeList::compatibility_iterator node = lstLines.GetFirst(); while(node) { pLine = node->GetData(); //rct.Union(pLine->GetBoundingBox()); lstChildren.Append(pLine); // get children of the connections pLine->GetChildShapes(sfANY, lstChildren); node = node->GetNext(); } } // get children of this shape if(mask & bbCHILDREN) { this->GetChildShapes(sfANY, lstChildren, sfNORECURSIVE); // now, call this function for all children recursively... ShapeList::compatibility_iterator node = lstChildren.GetFirst(); while(node) { node->GetData()->_GetCompleteBoundingBox(rct, mask); node = node->GetNext(); } } }
//--------------------------------------------------------- void CVariogram_Diagram::On_Draw(wxDC &dc, wxRect rDraw) { if( m_pVariogram->Get_Count() > 0 ) { int i, ix, iy, jx, jy; double x, dx; //------------------------------------------------- if( m_pModel->Get_Data_Count() > 0 ) { ix = Get_xToScreen(m_pModel->Get_Data_XMax()); dc.SetPen (wxPen(wxColour( 0, 127, 0), 2)); dc.DrawLine(ix, Get_yToScreen(m_yMin), ix, Get_yToScreen(m_yMax)); } //------------------------------------------------- if( m_bPairs && m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_COUNT) > 0 ) { double dScale = m_yMax / m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_COUNT); dc.SetPen (wxColour(191, 191, 191)); dc.SetBrush(wxColour(191, 191, 191)); for(i=0; i<m_pVariogram->Get_Count(); i++) { CSG_Table_Record *pRecord = m_pVariogram->Get_Record(i); ix = Get_xToScreen(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE)); iy = Get_yToScreen(pRecord->asDouble(CSG_Variogram::FIELD_COUNT ) * dScale); dc.DrawCircle(ix, iy, 3); } } //------------------------------------------------- dc.SetPen (wxColour(127, 127, 127)); dc.SetBrush(wxColour( 0, 0, 0)); for(i=0; i<m_pVariogram->Get_Count(); i++) { CSG_Table_Record *pRecord = m_pVariogram->Get_Record(i); ix = Get_xToScreen(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE)); iy = Get_yToScreen(pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP )); dc.DrawCircle(ix, iy, 3); } //------------------------------------------------- if( m_pModel->is_Okay() ) { dc.SetPen(wxPen(*wxRED, 2)); dx = (m_xMax - m_xMin) / (double)rDraw.GetWidth(); ix = Get_xToScreen(m_xMin); iy = Get_yToScreen(m_pModel->Get_Value(m_xMin)); for(x=m_xMin+dx; x<=m_xMax; x+=dx) { jx = ix; jy = iy; ix = Get_xToScreen(x); iy = Get_yToScreen(m_pModel->Get_Value(x)); dc.DrawLine(jx, jy, ix, iy); } } } }
wxRect wxRibbonPanel::GetExpandedPosition(wxRect panel, wxSize expanded_size, wxDirection direction) { // Strategy: // 1) Determine primary position based on requested direction // 2) Move the position so that it sits entirely within a display // (for single monitor systems, this moves it into the display region, // but for multiple monitors, it does so without splitting it over // more than one display) // 2.1) Move in the primary axis // 2.2) Move in the secondary axis wxPoint pos; bool primary_x = false; int secondary_x = 0; int secondary_y = 0; switch(direction) { case wxNORTH: pos.x = panel.GetX() + (panel.GetWidth() - expanded_size.GetWidth()) / 2; pos.y = panel.GetY() - expanded_size.GetHeight(); primary_x = true; secondary_y = 1; break; case wxEAST: pos.x = panel.GetRight(); pos.y = panel.GetY() + (panel.GetHeight() - expanded_size.GetHeight()) / 2; secondary_x = -1; break; case wxSOUTH: pos.x = panel.GetX() + (panel.GetWidth() - expanded_size.GetWidth()) / 2; pos.y = panel.GetBottom(); primary_x = true; secondary_y = -1; break; case wxWEST: default: pos.x = panel.GetX() - expanded_size.GetWidth(); pos.y = panel.GetY() + (panel.GetHeight() - expanded_size.GetHeight()) / 2; secondary_x = 1; break; } wxRect expanded(pos, expanded_size); wxRect best(expanded); int best_distance = INT_MAX; const unsigned display_n = wxDisplay::GetCount(); unsigned display_i; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for(display_i = 0; display_i < display_n; ++display_i) { wxRect display = wxDisplay(display_i).GetGeometry(); if(display.Contains(expanded)) { return expanded; } else if(display.Intersects(expanded)) { wxRect new_rect(expanded); int distance = 0; if(primary_x) { if(expanded.GetRight() > display.GetRight()) { distance = expanded.GetRight() - display.GetRight(); new_rect.x -= distance; } else if(expanded.GetLeft() < display.GetLeft()) { distance = display.GetLeft() - expanded.GetLeft(); new_rect.x += distance; } } else { if(expanded.GetBottom() > display.GetBottom()) { distance = expanded.GetBottom() - display.GetBottom(); new_rect.y -= distance; } else if(expanded.GetTop() < display.GetTop()) { distance = display.GetTop() - expanded.GetTop(); new_rect.y += distance; } } if(!display.Contains(new_rect)) { // Tried moving in primary axis, but failed. // Hence try moving in the secondary axis. int dx = secondary_x * (panel.GetWidth() + expanded_size.GetWidth()); int dy = secondary_y * (panel.GetHeight() + expanded_size.GetHeight()); new_rect.x += dx; new_rect.y += dy; // Squaring makes secondary moves more expensive (and also // prevents a negative cost) distance += dx * dx + dy * dy; } if(display.Contains(new_rect) && distance < best_distance) { best = new_rect; best_distance = distance; } } } return best; }
void CLabel::DrawBG(wxDC& dc, wxRect& rc) { CTrack *track = getTrack(); m_rcLabel = rc; wxBrush oldBrush = dc.GetBrush(); wxPen oldpen = dc.GetPen(); wxPen pen( *wxMEDIUM_GREY_PEN ); pen.SetWidth(1); dc.SetPen( pen ); //wxBrush brush(m_color, (IsSelected() ? wxCROSSDIAG_HATCH : wxSOLID)); wxBrush brush(track->GetBGColor(), wxSOLID); dc.SetBrush(brush); int left, top, width, height; if(m_bDrawAquaBG) { // Draw aqua background left = 0; top = rc.GetTop(); width = rc.GetWidth()-left; height = rc.GetHeight(); //dc.DrawRectangle(left, top, width, height); wxRect rc(left+1, top+1, width-2, height-2); DrawAquaRect(dc, rc, 4); } else { // Draw background left = 1;//m_nLevel*4+2; top = rc.GetTop()+1; width = rc.GetWidth()-1;//left-3; height = rc.GetHeight()-2; //dc.DrawRoundedRectangle(left, top, width, height, 4); //DrawRect3D(dc, wxRect(left, top, width, height)); DrawRect3D(dc, rc); } dc.SetTextForeground( track->GetForeColor() ); wxFont oldFont = dc.GetFont(); wxFont font(9, wxSWISS, wxNORMAL, wxBOLD); //wxFont font = oldFont; //font.SetWeight(IsSelected() ? wxBOLD : wxNORMAL); //font.SetPointSize(GetHeight() / 4); font.SetPointSize( 9 ); dc.SetFont(font); //wxFont font(12, wxDEFAULT, wxITALIC, (IsSelected() ? wxBOLD : wxNORMAL)); //dc.SetFont(font); ////dc.SetFont((IsSelected() ? *wxITALIC_FONT : *wxNORMAL_FONT)); // Get text dimensions wxCoord w=0, h=0; wxString csName; track->GetName(csName); dc.GetTextExtent(csName, &w, &h); /*int ptSize = GetHeight() / 2; // Get text dimensions wxCoord w=0, h=0; do { font.SetPointSize(ptSize); dc.GetTextExtent(m_name, &w, &h); ptSize--; } while (w>width && ptSize > 5);*/ // Draw text int x = left + 5;//width/2 - w/2; int y = (rc.GetTop() + (rc.GetHeight()/4) - h/2); dc.DrawText( csName, x, y ); m_rcLabel.SetHeight(rc.GetHeight()); /* int n = rc.GetHeight()/2-2; if(n > 20) n = 20; drawLoopSign(dc, wxRect(5, top+height-n-2, n, n)); drawCacheSign(dc, wxRect(n+5+1, top+height-n-2, n, n)); */ wxRect rcTmp = getPathRect(rc); m_pPathCtrl->DrawBG(dc, rcTmp); dc.SetFont(oldFont); dc.SetPen(oldpen); dc.SetBrush( oldBrush ); }
/// Gets a rectangle from within another image, INCLUDING the alpha channel /// \bug in wxWidgets, wxImage::GetSubImage should do this itself. wxImage GetSubImageWithAlpha( const wxImage & Src, const wxRect &rect ) { //First part of this code is lifted from wxImage::GetSubImage() source code. wxImage image; wxCHECK_MSG( Src.Ok(), image, wxT("invalid image") ); wxCHECK_MSG( (rect.GetLeft()>=0) && (rect.GetTop()>=0) && ( rect.GetRight()<=Src.GetWidth()) && (rect.GetBottom()<=Src.GetHeight()), image, wxT("invalid subimage size") ); int subwidth=rect.GetWidth(); const int subheight=rect.GetHeight(); image.Create( subwidth, subheight, false ); unsigned char *subdata = image.GetData(), *data=Src.GetData(); wxCHECK_MSG( subdata, image, wxT("unable to create image") ); // JKC: Quick hack - don't deal with masks - need to understand macro M_IMGDATA first. // if (Src.M_IMGDATA->m_hasMask) // image.SetMaskColour( Src.M_IMGDATA->m_maskRed, Src.M_IMGDATA->m_maskGreen, Src.M_IMGDATA->m_maskBlue ); int subleft=3*rect.GetLeft(); int width=3*Src.GetWidth(); subwidth*=3; data+=rect.GetTop()*width+subleft; for (long j = 0; j < subheight; ++j) { memcpy( subdata, data, subwidth); subdata+=subwidth; data+=width; } image.InitAlpha(); if( !Src.HasAlpha() ) return image; // OK, so we've copied the RGB data. // Now do the Alpha channel. //wxASSERT( Src.HasAlpha() ); subleft/=3; width/=3; subwidth/=3; data =Src.GetAlpha(); subdata =image.GetAlpha(); data+=rect.GetTop()*width+subleft; for (long j = 0; j < subheight; ++j) { memcpy( subdata, data, subwidth); subdata+=subwidth; data+=width; } return image; }
QRect wxQtConvertRect( const wxRect &rect ) { return QRect( rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight() ); }
/* static */ bool AutoCaptureMechanism::Capture(wxBitmap* bitmap, wxRect rect, int delay) { wxPoint origin = rect.GetPosition(); return Capture(bitmap, origin.x, origin.y, rect.GetWidth(), rect.GetHeight(), delay); }
void wxGridCellChoiceRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) { wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); // first calculate button size // don't draw outside the cell int nButtonWidth = 17; if (rectCell.height < 2) return; wxRect rectButton; rectButton.x = rectCell.x + rectCell.width - nButtonWidth; rectButton.y = rectCell.y + 1; int cell_rows, cell_cols; attr.GetSize(&cell_rows, &cell_cols); rectButton.width = nButtonWidth; if (cell_rows == 1) rectButton.height = rectCell.height-2; else rectButton.height = nButtonWidth; SetTextColoursAndFont(grid, attr, dc, isSelected); int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); // leave room for button wxRect rect = rectCell; rect.SetWidth(rectCell.GetWidth() - rectButton.GetWidth()-2); rect.Inflate(-1); grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), rect, hAlign, vAlign); // don't bother drawing if the cell is too small if (rectButton.height < 4 || rectButton.width < 4) return; // draw 3-d button wxColour colourBackGround = wxColour(COLORBASE); dc.SetBrush(wxBrush(colourBackGround, wxSOLID)); dc.SetPen(wxPen(colourBackGround, 1, wxSOLID)); dc.DrawRectangle(rectButton); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), 1, wxSOLID)); dc.DrawLine(rectButton.GetLeft(), rectButton.GetBottom(), rectButton.GetRight(), rectButton.GetBottom()); dc.DrawLine(rectButton.GetRight(), rectButton.GetBottom(), rectButton.GetRight(), rectButton.GetTop()-1); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW), 1, wxSOLID)); dc.DrawLine(rectButton.GetLeft()+1, rectButton.GetBottom()-1, rectButton.GetRight()-1, rectButton.GetBottom()-1); dc.DrawLine(rectButton.GetRight()-1, rectButton.GetBottom()-1, rectButton.GetRight()-1, rectButton.GetTop()); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT), 1, wxSOLID)); dc.DrawLine(rectButton.GetRight()-2, rectButton.GetTop()+1, rectButton.GetLeft()+1, rectButton.GetTop()+1); dc.DrawLine(rectButton.GetLeft()+1, rectButton.GetTop()+1, rectButton.GetLeft()+1, rectButton.GetBottom()-1); // Draw little triangle int nTriWidth = 7; int nTriHeight = 4; wxPoint point[3]; point[0] = wxPoint(rectButton.GetLeft() + (rectButton.GetWidth()-nTriWidth)/2, rectButton.GetTop()+(rectButton.GetHeight()-nTriHeight)/2); point[1] = wxPoint(point[0].x+nTriWidth-1, point[0].y); point[2] = wxPoint(point[0].x+3, point[0].y+nTriHeight-1); dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), wxSOLID)); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), 1, wxSOLID)); dc.DrawPolygon(3, point); if (m_border == wxLAYOUT_TOP) { dc.SetPen(wxPen(*wxBLACK, 1, wxDOT)); dc.DrawLine(rectCell.GetRight(), rectCell.GetTop(), rectCell.GetLeft(), rectCell.GetTop()); } }
// draw the continuity starting at a specific offset void DrawCont(wxDC& dc, const CC_textline_list& print_continuity, const wxRect& bounding, bool landscape) { SaveAndRestore_DeviceOrigin orig_dev(dc); SaveAndRestore_UserScale orig_scale(dc); SaveAndRestore_TextForeground orig_text(dc); SaveAndRestore_Font orig_font(dc); #if DEBUG dc.DrawRectangle(bounding); #endif dc.SetTextForeground(*wxBLACK); int pageMiddle = (bounding.GetWidth()/2); size_t numLines = 0; for (auto text = print_continuity.begin(); text != print_continuity.end(); ++text) { if (text->GetOnSheet()) { ++numLines; } } int font_size = ((bounding.GetBottom() - bounding.GetTop()) - (numLines - 1)*2)/(numLines ? numLines : 1); //font size, we scale to be no more than 256 pixels. font_size = std::min(font_size, 10); wxFont *contPlainFont = wxTheFontList->FindOrCreateFont(font_size, wxMODERN, wxNORMAL, wxNORMAL); wxFont *contBoldFont = wxTheFontList->FindOrCreateFont(font_size, wxMODERN, wxNORMAL, wxBOLD); wxFont *contItalFont = wxTheFontList->FindOrCreateFont(font_size, wxMODERN, wxITALIC, wxNORMAL); wxFont *contBoldItalFont = wxTheFontList->FindOrCreateFont(font_size, wxMODERN, wxITALIC, wxBOLD); dc.SetFont(*contPlainFont); const wxCoord maxtexth = contPlainFont->GetPointSize()+2; float y = bounding.GetTop(); const wxCoord charWidth = dc.GetCharWidth(); for (auto& cont : print_continuity) { float x = bounding.GetLeft(); // Determine how to center the text if (cont.GetCenter()) { x += pageMiddle; auto chunks = cont.GetChunks(); for (auto& c : chunks) { bool do_tab = false; switch (c.font) { case PSFONT_SYMBOL: { wxCoord textw, texth; dc.GetTextExtent(wxT("O"), &textw, &texth); x += textw * c.text.length(); } break; case PSFONT_NORM: dc.SetFont(*contPlainFont); break; case PSFONT_BOLD: dc.SetFont(*contBoldFont); break; case PSFONT_ITAL: dc.SetFont(*contItalFont); break; case PSFONT_BOLDITAL: dc.SetFont(*contBoldItalFont); break; case PSFONT_TAB: do_tab = true; break; } if (!do_tab && (c.font != PSFONT_SYMBOL)) { wxCoord textw, texth; dc.GetTextExtent(c.text, &textw, &texth); x -= textw/2; } } } // now draw the text unsigned tabnum = 0; auto chunks = cont.GetChunks(); for (auto& c : chunks) { bool do_tab = false; switch (c.font) { case PSFONT_NORM: case PSFONT_SYMBOL: dc.SetFont(*contPlainFont); break; case PSFONT_BOLD: dc.SetFont(*contBoldFont); break; case PSFONT_ITAL: dc.SetFont(*contItalFont); break; case PSFONT_BOLDITAL: dc.SetFont(*contBoldItalFont); break; case PSFONT_TAB: { tabnum++; wxCoord textw = bounding.GetLeft() + charWidth * TabStops(tabnum, landscape); if (textw >= x) x = textw; else x += charWidth; do_tab = true; } break; default: break; } if (c.font == PSFONT_SYMBOL) { wxCoord textw, texth, textd; dc.GetTextExtent(wxT("O"), &textw, &texth, &textd); const float d = textw; const float top_y = y + texth - textd - textw; for (std::string::const_iterator s = c.text.begin(); s != c.text.end(); s++) { { dc.SetPen(*wxBLACK_PEN); SYMBOL_TYPE sym = (SYMBOL_TYPE)(*s - 'A'); switch (sym) { case SYMBOL_SOL: case SYMBOL_SOLBKSL: case SYMBOL_SOLSL: case SYMBOL_SOLX: dc.SetBrush(*wxBLACK_BRUSH); break; default: dc.SetBrush(*wxTRANSPARENT_BRUSH); } dc.DrawEllipse(x, top_y, d, d); switch (sym) { case SYMBOL_SL: case SYMBOL_X: case SYMBOL_SOLSL: case SYMBOL_SOLX: dc.DrawLine(x-1, top_y + d+1, x + d+1, top_y-1); break; default: break; } switch (sym) { case SYMBOL_BKSL: case SYMBOL_X: case SYMBOL_SOLBKSL: case SYMBOL_SOLX: dc.DrawLine(x-1, top_y-1, x + d+1, top_y + d+1); break; default: break; } } x += d; } } else { if (!do_tab) { wxCoord textw, texth; dc.GetTextExtent(c.text, &textw, &texth); dc.DrawText(c.text, x, y); x += textw; } } } y += maxtexth; } #if DEBUG char buffer[100]; snprintf(buffer, sizeof(buffer), "TopLeft %d, %d", bounding.GetTopLeft().x, bounding.GetTopLeft().y); dc.DrawText(buffer, bounding.GetTopLeft()); snprintf(buffer, sizeof(buffer), "BottomRight %d, %d", bounding.GetBottomRight().x, bounding.GetBottomRight().y); dc.DrawText(buffer, bounding.GetBottomRight()); #endif }