void ClippingBoxTestCaseBase::TwoRegionsNonOverlappingNegDim() { // Setting one clipping box with negative size values // and next another box (non-overlapping). // Final clipping box should be empty. 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(0, 0, 0, 0); }
void ClippingBoxTestCaseBase::InitialStateWithTransformedDC() { // Initial clipping box with transformed DC. 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->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(-20, -25, 50, 40); }
void PaintDrawPanel::Render(wxDC& dc) { // Clear dc.SetBackground(*wxWHITE_BRUSH); dc.Clear(); if (mModel) { mModel->DrawShapes(dc); } }
void ClippingBoxTestCaseBase::TwoRegionsOverlappingNegDim() { // Setting one clipping box with negative size values // and next another box (partially overlapping). // Final clipping box should be an intersection of these two boxes // with positive size values. m_dc->SetClippingRegion(90, 95, -80, -75); m_dc->SetClippingRegion(50, 60, 50, 40); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(50, 60, 41, 36); }
void wxPDFViewPage::DrawThumbnail(wxPDFViewPagesClient* client, wxDC& dc, const wxRect& rect) { dc.SetBackground(*wxTRANSPARENT_BRUSH); dc.SetPen(*wxLIGHT_GREY_PEN); dc.DrawRectangle(rect.Inflate(1, 1)); wxBitmap bmp = client->GetCachedBitmap(m_index, rect.GetSize()); if (bmp.Ok()) { dc.DrawBitmap(bmp, rect.GetPosition()); } }
void ZLauncherFrame::RenderFrame(wxDC& dc) { if (m_backgroundImg.IsOk()) { dc.DrawBitmap(m_backgroundImg, 0, 0); } else { dc.SetBackground( APPLICATION_BACKGROUND ); dc.Clear(); } }
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 PreviewWindow::Render(wxDC& dc) { dc.SetBackground(wxBrush(backgroundColour)); dc.Clear(); DrawPath(dc); DrawTrajectory(dc); DrawOrigin(dc); wxString text; text << wxT("X: ") << offset.x << wxT(" Y: ") << offset.y << wxT(" Z: ") << wheelPosition; dc.SetTextForeground(wxColour(255, 255, 255)); dc.DrawText(text, 40, 10); }
static void SwitchSelState(wxDC& dc, wxHtmlRenderingInfo& info, bool toSelection) { wxColour fg = info.GetState().GetFgColour(); wxColour bg = info.GetState().GetBgColour(); if ( toSelection ) { dc.SetBackgroundMode(wxSOLID); dc.SetTextForeground(info.GetStyle().GetSelectedTextColour(fg)); dc.SetTextBackground(info.GetStyle().GetSelectedTextBgColour(bg)); dc.SetBackground(wxBrush(info.GetStyle().GetSelectedTextBgColour(bg), wxSOLID)); } else { dc.SetBackgroundMode(wxTRANSPARENT); dc.SetTextForeground(fg); dc.SetTextBackground(bg); dc.SetBackground(wxBrush(bg, wxSOLID)); } }
void StateEvaluationTreePanel::render(wxDC &dc) { if (Settings.m_ColourScheme == nullptr) return; PrepareDC(dc); auto const &Scheme = *(Settings.m_ColourScheme); dc.SetBackground(wxBrush{Scheme.getDefault().GetBackground()}); dc.Clear(); if (Statement.empty()) return; auto const ActiveStmt = ActiveFn->getActiveStmt(); if (!ActiveStmt) return; dc.SetFont(CodeFont); // Draw the sub-Stmts' nodes. for (auto const &Node : Nodes) { // Don't draw hovered nodes, they will be drawn later. if (&*HoverNodeIt == &Node || &*ReplayHoverNodeIt == &Node) continue; auto const DoHighlight = (HighlightedStmt && Node.Statement == HighlightedStmt) || (HighlightedValue && Node.Value.get() == HighlightedValue); if (DoHighlight) drawNode(dc, Scheme, Node, NodeDecoration::Highlighted); else if (Node.Statement == ActiveStmt) drawNode(dc, Scheme, Node, NodeDecoration::Active); else drawNode(dc, Scheme, Node, NodeDecoration::None); } // Redraw the hovered nodes, so that they outrank active node highlighting. if (HoverNodeIt != Nodes.end()) drawNode(dc, Scheme, *HoverNodeIt, NodeDecoration::Highlighted); if (ReplayHoverNodeIt != Nodes.end()) drawNode(dc, Scheme, *ReplayHoverNodeIt, NodeDecoration::Highlighted); // Draw the pretty-printed Stmt's string. dc.SetTextForeground(Scheme.getDefault().GetForeground()); wxCoord const PageBorderH = dc.GetCharWidth() * Settings.PageBorderHorizontal; wxCoord const PageBorderV = dc.GetCharHeight() * Settings.PageBorderVertical; dc.DrawText(Statement, PageBorderH, PageBorderV); }
void wxlCan::Render( wxDC& dc ) { int w,h; GetVirtualSize( &w, &h ); dc.SetBackground( GetBackgroundColour() ); dc.Clear(); dc.SetBrush(m_backbrush); dc.SetPen( *wxTRANSPARENT_PEN ); dc.DrawRectangle( 0, 0, w, h ); //draw objects m_rootobject.Draw( dc, 0, 0 ); }
static void DrawKDETheme(wxDC& dc,wxSize size) { wxPen pen; pen.SetStyle(wxSOLID); wxBrush brush(kdetheme[13],wxSOLID); dc.SetBackground(brush); dc.Clear(); for(int i=0;i<14;i++) { pen.SetColour(kdetheme[i]); dc.SetPen(pen); dc.DrawLine(0,i,size.GetWidth()-1,i); dc.DrawLine(0,size.GetHeight()-1-i, size.GetWidth()-1,size.GetHeight()-1-i); } };
void SliderBar::draw_area(wxDC & dc) { wxCoord w,h; int pixw; dc.SetBackground(_bgbrush); dc.Clear(); dc.SetBrush(_borderbrush); dc.SetPen(_borderpen); dc.DrawRectangle (0, 0, _width, _height); dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(_barbrush); if (_bar_style == FromLeftStyle) { pixw = (int) ((_value - _lower_bound) / _val_scale); dc.DrawRectangle (1, 1, pixw-1, _height-2); } else if (_bar_style == FromRightStyle) { pixw = (int) ((_upper_bound - _value) / _val_scale); dc.DrawRectangle (pixw, 1, _width - pixw - 1, _height-2); } if (_bar_style != HiddenStyle) { dc.SetBrush(_linebrush); pixw = (int) ((_value - _lower_bound) / _val_scale); dc.DrawRectangle (pixw - 1, 1, 2, _height-2); } dc.SetTextForeground(_textcolor); dc.GetTextExtent(_label_str, &w, &h); dc.DrawText (_label_str, 3, _height - h - 3); if (_showval_flag) { dc.SetTextForeground(_valuecolor); dc.GetTextExtent(_value_str, &w, &h); dc.DrawText (_value_str, _width - w - 3, _height - h - 3); } }
void BasicDrawPane::render(wxDC &dc) { static int frames = 0; frames++; static wxString draw_text = ""; auto new_timestamp = std::chrono::high_resolution_clock::now(); // Calculate framerate every second if (std::chrono::duration_cast<std::chrono::seconds>(new_timestamp - timestamp_).count() >= 1) { timestamp_ = new_timestamp; std::stringstream ss; ss << "FPS: " << frames; frames = 0; draw_text = ss.str(); } dc.SetBackground(*wxWHITE_BRUSH); dc.Clear(); dc.DrawText(draw_text, 0, 0); }
void MyApp::Draw(wxDC&dc) { // This routine just draws a bunch of random stuff on the screen so that we // can check that different types of object are being drawn consistently // between the screen image, the print preview image (at various zoom // levels), and the printed page. dc.SetBackground(*wxWHITE_BRUSH); // dc.Clear(); dc.SetFont(m_testFont); // dc.SetBackgroundMode(wxTRANSPARENT); dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxLIGHT_GREY_BRUSH); dc.DrawRectangle(0, 0, 230, 350); dc.DrawLine(0, 0, 229, 349); dc.DrawLine(229, 0, 0, 349); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetBrush(*wxCYAN_BRUSH); dc.SetPen(*wxRED_PEN); dc.DrawRoundedRectangle(0, 20, 200, 80, 20); dc.DrawText( wxT("Rectangle 200 by 80"), 40, 40); dc.SetPen( wxPen(*wxBLACK, 0, wxPENSTYLE_DOT_DASH) ); dc.DrawEllipse(50, 140, 100, 50); dc.SetPen(*wxRED_PEN); dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180); #if wxUSE_UNICODE const char *test = "Hebrew שלום -- Japanese (日本語)"; wxString tmp = wxConvUTF8.cMB2WC( test ); dc.DrawText( tmp, 10, 200 ); #endif wxPoint points[5]; points[0].x = 0; points[0].y = 0; points[1].x = 20; points[1].y = 0; points[2].x = 20; points[2].y = 20; points[3].x = 10; points[3].y = 20; points[4].x = 10; points[4].y = -20; dc.DrawPolygon( 5, points, 20, 250, wxODDEVEN_RULE ); dc.DrawPolygon( 5, points, 50, 250, wxWINDING_RULE ); dc.DrawEllipticArc( 80, 250, 60, 30, 0.0, 270.0 ); points[0].x = 150; points[0].y = 250; points[1].x = 180; points[1].y = 250; points[2].x = 180; points[2].y = 220; points[3].x = 200; points[3].y = 220; dc.DrawSpline( 4, points ); dc.DrawArc( 20,10, 10,10, 25,40 ); wxString str; int i = 0; str.Printf( wxT("---- Text at angle %d ----"), i ); dc.DrawRotatedText( str, 100, 300, i ); i = m_angle; str.Printf( wxT("---- Text at angle %d ----"), i ); dc.DrawRotatedText( str, 100, 300, i ); wxIcon my_icon = wxICON(sample); dc.DrawIcon( my_icon, 100, 100); if (m_bitmap.IsOk()) dc.DrawBitmap( m_bitmap, 10, 10 ); #if wxUSE_GRAPHICS_CONTEXT wxGraphicsContext *gc = NULL; wxPrinterDC *printer_dc = wxDynamicCast( &dc, wxPrinterDC ); if (printer_dc) gc = wxGraphicsContext::Create( *printer_dc ); wxWindowDC *window_dc = wxDynamicCast( &dc, wxWindowDC ); if (window_dc) gc = wxGraphicsContext::Create( *window_dc ); #ifdef __WXMSW__ wxEnhMetaFileDC *emf_dc = wxDynamicCast( &dc, wxEnhMetaFileDC ); if (emf_dc) gc = wxGraphicsContext::Create( *emf_dc ); #endif if (gc) { // make a path that contains a circle and some lines, centered at 100,100 gc->SetPen( *wxRED_PEN ); wxGraphicsPath path = gc->CreatePath(); path.AddCircle( 50.0, 50.0, 50.0 ); path.MoveToPoint(0.0, 50.0); path.AddLineToPoint(100.0, 50.0); path.MoveToPoint(50.0, 0.0); path.AddLineToPoint(50.0, 100.0 ); path.CloseSubpath(); path.AddRectangle(25.0, 25.0, 50.0, 50.0); gc->StrokePath(path); // draw some text wxString text("Text by wxGraphicsContext"); gc->SetFont( m_testFont, *wxBLACK ); gc->DrawText(text, 25.0, 60.0); // draw rectangle around the text double w, h, d, el; gc->GetTextExtent(text, &w, &h, &d, &el); gc->SetPen( *wxBLACK_PEN ); gc->DrawRectangle(25.0, 60.0, w, h); delete gc; } #endif }
// Draws the background void wxShapeCanvas::DrawBackground(wxDC &dc, bool transformed) { dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); dc.Clear(); }
void WSortView::paint(wxDC& dc, const wxSize& dcsize) { dc.SetBackground(*wxBLACK_BRUSH); dc.Clear(); if (size() == 0) return; size_t fwidth = dcsize.GetWidth(); size_t fheight = dcsize.GetHeight(); size_t width = fwidth - 20; size_t height = fheight - 20; dc.SetDeviceOrigin(10,10); // *** draw array element bars // draw | | | | bars: each bar is width w, separation is w/2 // thus n bars need n * w + (n-1) * w/2 width // 1st variant: space is 0.5 of bar size //double wbar = width / (size() + (size()-1) / 2.0); //double bstep = 1.5 * wbar; // 2nd variant: one pixel between bars double wbar = (width - (size()-1)) / (double)size(); if (width <= (size()-1)) wbar = 0.0; double bstep = wbar + 1.0; // special case for bstep = 2 pixel -> draw 2 pixel bars instead of 1px // bar/1px gaps. if ( fabs(wbar - 1.0) < 0.1 && fabs(bstep - 2.0) < 0.1 ) wbar = 2, bstep = 2; static const wxPen pens[] = { *wxWHITE_PEN, *wxRED_PEN, *wxGREEN_PEN, *wxCYAN_PEN, wxPen(wxColour(255,255,0)), // 4 yellow wxPen(wxColour(255,0,255)), // 5 magenta wxPen(wxColour(255,192,128)), // 6 orange wxPen(wxColour(255,128,192)), // 7 pink wxPen(wxColour(128,192,255)), // 8 darker cyan wxPen(wxColour(192,255,128)), // 9 darker green wxPen(wxColour(192,128,255)), // 10 purple wxPen(wxColour(128,255,192)), // 11 light green wxPen(wxColour(128,128,255)), // 12 blue wxPen(wxColour(192,128,192)), // 13 dark purple wxPen(wxColour(128,192,192)), // 14 dark cyan wxPen(wxColour(192,192,128)), // 15 dark yellow wxPen(wxColour(0,128,255)), // 16 blue/cyan mix }; static const wxBrush brushes[] = { *wxWHITE_BRUSH, *wxRED_BRUSH, *wxGREEN_BRUSH, *wxCYAN_BRUSH, wxBrush(wxColour(255,255,0)), // 4 yellow wxBrush(wxColour(255,0,255)), // 5 magenta wxBrush(wxColour(255,192,128)), // 6 orange wxBrush(wxColour(255,128,192)), // 7 pink wxBrush(wxColour(128,192,255)), // 8 darker cyan wxBrush(wxColour(192,255,128)), // 9 darker green wxBrush(wxColour(192,128,255)), // 10 purple wxBrush(wxColour(128,255,192)), // 11 light green wxBrush(wxColour(128,128,255)), // 12 blue wxBrush(wxColour(192,128,192)), // 13 dark purple wxBrush(wxColour(128,192,192)), // 14 dark cyan wxBrush(wxColour(192,192,128)), // 15 dark yellow wxBrush(wxColour(0,128,255)), // 16 blue/cyan mix }; wxMutexLocker lock(m_mutex); ASSERT(lock.IsOk()); for (size_t i = 0; i < size(); ++i) { int clr; // select color if (i == m_access1.index) { clr = m_access1.color; } else if (i == m_access2.index) { clr = m_access2.color; } else if ( (clr = InWatchList(i)) != 0 ) { // clr already set } else if (m_mark[i] != 0) { clr = m_mark[i]; } else if ( (clr = InAccessList(i)) >= 0 ) { } else { clr = 0; } ASSERT(clr < (int)(sizeof(brushes) / sizeof(brushes[0]))); dc.SetPen( pens[clr] ); dc.SetBrush( brushes[clr] ); dc.DrawRectangle(i*bstep, height, wxMax(1, // draw at least 1 pixel (wxCoord((i+1)*bstep) - wxCoord(i*bstep)) // integral gap to next bar - (bstep - wbar) // space between bars ), -(double)height * m_array[i].get_direct() / m_array_max); } }
void PlotXY::OnDraw(wxDC& dc) { agw::PlotLua* pl = plotLua_.get(); std::vector<agw::PlotLayer_sptr>& layers = pl->layers_; if (layers.size() == 0) return; int xv, yv; GetVirtualSize(&xv, &yv); PixelWorld& pw = pl->world_; pw.calc(xv,yv); pw.calcScales(layers); wxBrush backBrush(pw.backColor_); dc.SetBackground(backBrush); dc.DrawRectangle(0,0,xv,yv); wxPen axePen(pw.axisColor_); auto savePen = dc.GetPen(); dc.SetPen(axePen); auto xright = pw.left_ + pw.xspan_; auto xbottom = pw.top_ + pw.yspan_; if (pw.leftFrame_) dc.DrawLine(pw.left_, pw.top_,pw.left_, xbottom); if (pw.topFrame_) dc.DrawLine(pw.left_, pw.top_, xright, pw.top_); if (pw.rightFrame_) dc.DrawLine(xright, pw.top_,xright, xbottom); if (pw.bottomFrame_) dc.DrawLine(xright, xbottom, pw.left_, xbottom); pw.yScale_.renderDC(dc,pw); // bottom axis, pw.xScale_.renderDC(dc,pw); auto it = layers.begin(); auto fin = layers.end(); for( ; it != fin; it++) { PlotLayer* p = it->get(); if (p->isVisible()) p->renderDC(dc, pw); } dc.SetPen(savePen); std::vector<PlotLayer_sptr>& text = pl->text_.labels_; it = text.begin(); fin = text.end(); for( ; it != fin; it++) { PlotLayer* p = it->get(); p->setPlot(plotLua_); if (p->isVisible()) p->renderDC(dc, pw); } PlotLayer* p = pl->text_.legend_.get(); if (p && p->isVisible()) { p->setPlot(plotLua_); p->renderDC(dc, pw); } }
void OnDraw(wxDC& dc) { dc.SetBackground(m_view->GetBackgroundColour()); dc.Clear(); dc.SetFont(m_view->GetFont()); wxRect updateRect = GetUpdateClientRect(); updateRect.SetPosition(CalcUnscrolledPosition(updateRect.GetPosition())); int startRow = updateRect.GetTop() / m_rowHeight; int endRow = std::ceil(updateRect.GetBottom() / (double)m_rowHeight); if (endRow > m_view->m_dataSize / m_view->m_rowsize) endRow = m_view->m_dataSize / m_view->m_rowsize; wxSize offsetSize = dc.GetTextExtent("00000000"); offsetSize.x += 4; wxSize byteSize = dc.GetTextExtent("00"); byteSize.x += 2; wxRect visRect = GetClientSize(); wxPoint viewStart = GetViewStart(); for (int row = startRow; row <= endRow; ++row) { int offset = row * m_view->m_rowsize; wxPoint rowPos = wxPoint(2, (row * m_rowHeight) + 2); int rowsize = m_view->m_rowsize; if (offset + rowsize > m_view->m_dataSize) rowsize = m_view->m_dataSize - offset; // Draw offset dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); dc.DrawText(wxString::Format("%.8X", offset), rowPos); rowPos.x += offsetSize.GetWidth(); // Draw row values dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); for (int i = 0; i < m_view->m_rowsize; ++i) { if (i < rowsize) dc.DrawText(wxString::Format("%.2X", m_view->m_data[offset + i]), rowPos); rowPos.x += byteSize.GetWidth(); } rowPos.x += m_charWidth; // Draw row characters wxString str((const char*)&m_view->m_data[offset], rowsize); for (auto it = str.begin(); it != str.end(); ++it) { if (*it < 32) *it = '.'; } dc.DrawText(str, rowPos); rowPos.y += m_rowHeight; } }
////////////// // 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 MyFrame::Draw(wxDC& dc) { // This routine just draws a bunch of random stuff on the screen so that we // can check that different types of object are being drawn consistently // between the screen image, the print preview image (at various zoom // levels), and the printed page. dc.SetBackground(*wxWHITE_BRUSH); dc.Clear(); dc.SetFont(wxGetApp().m_testFont); dc.SetBackgroundMode(wxTRANSPARENT); dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxLIGHT_GREY_BRUSH); // dc.SetBackground(*wxWHITE_BRUSH); dc.DrawRectangle(0, 0, 230, 350); dc.DrawLine(0, 0, 229, 349); dc.DrawLine(229, 0, 0, 349); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetBrush(*wxCYAN_BRUSH); dc.SetPen(*wxRED_PEN); dc.DrawRoundedRectangle(0, 20, 200, 80, 20); dc.DrawText( wxT("Rectangle 200 by 80"), 40, 40); dc.SetPen( wxPen(*wxBLACK,0,wxDOT_DASH) ); dc.DrawEllipse(50, 140, 100, 50); dc.SetPen(*wxRED_PEN); dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180); #if wxUSE_UNICODE //char *test = "Hebrew שלום -- Japanese (日本語)"; //wxString tmp = wxConvUTF8.cMB2WC( test ); //dc.DrawText( tmp, 10, 200 ); #endif wxPoint points[5]; points[0].x = 0; points[0].y = 0; points[1].x = 20; points[1].y = 0; points[2].x = 20; points[2].y = 20; points[3].x = 10; points[3].y = 20; points[4].x = 10; points[4].y = -20; dc.DrawPolygon( 5, points, 20, 250, wxODDEVEN_RULE ); dc.DrawPolygon( 5, points, 50, 250, wxWINDING_RULE ); dc.DrawEllipticArc( 80, 250, 60, 30, 0.0, 270.0 ); points[0].x = 150; points[0].y = 250; points[1].x = 180; points[1].y = 250; points[2].x = 180; points[2].y = 220; points[3].x = 200; points[3].y = 220; dc.DrawSpline( 4, points ); dc.DrawArc( 20,10, 10,10, 25,40 ); wxString str; int i = 0; str.Printf( wxT("---- Text at angle %d ----"), i ); dc.DrawRotatedText( str, 100, 300, i ); i = m_angle; str.Printf( wxT("---- Text at angle %d ----"), i ); dc.DrawRotatedText( str, 100, 300, i ); wxIcon my_icon = wxICON(mondrian) ; dc.DrawIcon( my_icon, 100, 100); if (m_bitmap.Ok()) { dc.DrawBitmap(m_bitmap, 10, 25); } if (m_imgUp.Ok()) { dc.DrawBitmap(m_imgUp, 300, 200); dc.DrawBitmap(m_imgUp, 300, 250, true); } }
void wxCustomButton::Paint( wxDC &dc ) { int w, h; GetSize(&w,&h); wxColour foreColour = GetForegroundColour(); wxColour backColour = GetBackgroundColour(); if (m_focused) { backColour.Set( wxMin(backColour.Red() + 20, 255), wxMin(backColour.Green() + 20, 255), wxMin(backColour.Blue() + 20, 255) ); } wxBitmap bitmap; if (IsEnabled()) { if (GetValue() && m_bmpSelected.Ok()) bitmap = m_bmpSelected; else if (m_focused && m_bmpFocus.Ok()) bitmap = m_bmpFocus; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; } else { // try to create disabled if it doesn't exist if (!m_bmpDisabled.Ok() && m_bmpLabel.Ok()) m_bmpDisabled = CreateBitmapDisabled(m_bmpLabel); if (m_bmpDisabled.Ok()) bitmap = m_bmpDisabled; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; foreColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); } #if wxCHECK_VERSION(2, 8, 0) // wxCONTROL_DISABLED //flags may have the wxCONTROL_PRESSED, wxCONTROL_CURRENT or wxCONTROL_ISDEFAULT int ren_flags = 0; if (GetValue()) ren_flags |= wxCONTROL_PRESSED; if (m_focused) ren_flags |= wxCONTROL_CURRENT; if (!IsEnabled()) ren_flags |= wxCONTROL_DISABLED; wxRendererNative::Get().DrawPushButton(this, dc, wxRect(0, 0, w, h), ren_flags); #else wxBrush brush(backColour, wxSOLID); dc.SetBackground(brush); dc.SetBrush(brush); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(0, 0, w, h); #endif // !wxCHECK_VERSION(2, 8, 0) if (bitmap.Ok()) dc.DrawBitmap(bitmap, m_bitmapPos.x, m_bitmapPos.y, true ); if (!GetLabel().IsEmpty()) { dc.SetFont(GetFont()); dc.SetTextBackground(backColour); dc.SetTextForeground(foreColour); dc.DrawText(GetLabel(), m_labelPos.x, m_labelPos.y); } #if !wxCHECK_VERSION(2, 8, 0) if (GetValue()) // draw sunken border { dc.SetPen(*wxGREY_PEN); dc.DrawLine(0,h-1,0,0); dc.DrawLine(0,0,w,0); dc.SetPen(*wxWHITE_PEN); dc.DrawLine(w-1,1,w-1,h-1); dc.DrawLine(w-1,h-1,0,h-1); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(1,h-2,1,1); dc.DrawLine(1,1,w-1,1); } else if (((m_button_style & wxCUSTBUT_FLAT) == 0) || m_focused) // draw raised border { dc.SetPen(*wxWHITE_PEN); dc.DrawLine(0,h-2,0,0); dc.DrawLine(0,0,w-1,0); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(w-1,0,w-1,h-1); dc.DrawLine(w-1,h-1,-1,h-1); dc.SetPen(*wxGREY_PEN); dc.DrawLine(2,h-2,w-2,h-2); dc.DrawLine(w-2,h-2,w-2,1); } #endif // !wxCHECK_VERSION(2, 8, 0) dc.SetBackground(wxNullBrush); dc.SetBrush(wxNullBrush); dc.SetPen(wxNullPen); }
//+-------------------------------------------------------------+ //| Card::Draw() | //+-------------------------------------------------------------+ //| Description: | //| Draw the card at (x, y). | //| If the card is facedown draw the back of the card. | //| If the card is faceup draw the front of the card. | //| Cards are not held in bitmaps, instead they are drawn | //| from their constituent parts when required. | //| hbmap_symbols contains large and small suit symbols and | //| pip values. These are copied to the appropriate part of | //| the card. Picture cards use the pictures defined in | //| hbmap_pictures. Note that only one picture is defined | //| for the Jack, Queen and King, unlike a real pack where | //| each suit is different. | //| | //| WARNING: | //| The locations of these symbols is 'hard-wired' into the | //| code. Editing the bitmaps or the numbers below will | //| result in the wrong symbols being displayed. | //+-------------------------------------------------------------+ void Card::Draw(wxDC& dc, int x, int y) { wxBrush backgroundBrush( dc.GetBackground() ); dc.SetBrush(* wxWHITE_BRUSH); dc.SetPen(* wxBLACK_PEN); dc.DrawRoundedRectangle(x, y, m_width, m_height, 4); if (m_wayUp == facedown) { dc.SetBackground(* wxRED_BRUSH); dc.SetBackgroundMode(wxSOLID); wxBrush* brush = wxTheBrushList->FindOrCreateBrush( *wxBLACK, wxCROSSDIAG_HATCH ); dc.SetBrush(* brush); dc.DrawRoundedRectangle( x + 4, y + 4, m_width - 8, m_height - 8, 2 ); } else { wxMemoryDC memoryDC; memoryDC.SelectObject(*m_symbolBmap); // dc.SetBackgroundMode(wxTRANSPARENT); dc.SetTextBackground(*wxWHITE); switch (m_suit) { case spades: case clubs: dc.SetTextForeground(*wxBLACK); break; case diamonds: case hearts: dc.SetTextForeground(*wxRED); break; } int symsize = 11; int sympos = 14; int sympos2 = 25; int symdist = 5; int symdist2 = 6; int pipsize,pippos,valueheight,valuewidth; int valuepos; if (m_scale > 1.2) { pipsize = symsize; pippos = sympos; valueheight = 10; valuewidth = 9; valuepos = 50; } else { pipsize = 7; pippos = 0; valueheight = 7; valuewidth = 6; valuepos = 36; } // Draw the value dc.Blit((wxCoord)(x + m_scale*3), (wxCoord)(y + m_scale*3), valuewidth, valueheight, &memoryDC, valuewidth * (m_pipValue - 1), valuepos, wxCOPY); dc.Blit((wxCoord)(x + m_width - m_scale*3 - valuewidth), (wxCoord)(y + m_height - valueheight - m_scale*3), valuewidth, valueheight, &memoryDC, valuewidth * (m_pipValue - 1), valuepos+valueheight, wxCOPY); // Draw the pips dc.Blit((wxCoord)(x + m_scale*3 + valuewidth+2), (wxCoord)(y + m_scale*3), pipsize, pipsize, &memoryDC, pipsize * m_suit, pippos, wxCOPY); dc.Blit((wxCoord)(x + m_width - m_scale*3-valuewidth-pipsize-2), (wxCoord)(y + m_height - pipsize - m_scale*3), pipsize, pipsize, &memoryDC, pipsize * m_suit, pipsize+pippos, wxCOPY); switch (m_pipValue) { case 1: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - m_scale*5 + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); break; case 3: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); case 2: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); break; case 5: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); case 4: dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); break; case 8: dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10), (wxCoord)(y - symdist + 5 * m_height / 8), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); case 7: dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10), (wxCoord)(y - symdist + 3 * m_height / 8), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); case 6: dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); break; case 10: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + 2 * m_height / 3), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); case 9: dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist2 + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist2 + 5 * m_height / 12), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + 7 * m_height / 12), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist2 + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist2 + 5 * m_height / 12), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + 7 * m_height / 12), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + m_height / 3), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); break; case 11: case 12: case 13: memoryDC.SelectObject(*m_pictureBmap); int picwidth = 40,picheight = 45; dc.Blit((wxCoord)(x + (m_width-picwidth)/2), (wxCoord)(y - picheight/2 + m_height/2), picwidth, picheight, &memoryDC, picwidth * (m_pipValue - 11), 0, wxCOPY); memoryDC.SelectObject(*m_symbolBmap); dc.Blit((wxCoord)(x + m_width-(m_width-picwidth)/2-symsize-3), (wxCoord)(y - picheight/2+m_height/2+1), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x + (m_width-picwidth)/2+2), (wxCoord)(y + picheight/2 + m_height/2-symsize), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); break; } } dc.SetBackground( backgroundBrush ); } // Card:Draw()
void wxCustomButton::Paint( wxDC &dc ) { #if (wxMINOR_VERSION<8) dc.BeginDrawing(); #endif int w, h; GetSize(&w,&h); wxColour foreColour = GetForegroundColour(); wxColour backColour = GetBackgroundColour(); if (m_focused) { backColour.Set( wxMin(backColour.Red() + 20, 255), wxMin(backColour.Green() + 20, 255), wxMin(backColour.Blue() + 20, 255) ); } wxBitmap bitmap; if (IsEnabled()) { if (GetValue() && m_bmpSelected.Ok()) bitmap = m_bmpSelected; else if (m_focused && m_bmpFocus.Ok()) bitmap = m_bmpFocus; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; } else { // try to create disabled if it doesn't exist if (!m_bmpDisabled.Ok() && m_bmpLabel.Ok()) m_bmpDisabled = CreateBitmapDisabled(m_bmpLabel); if (m_bmpDisabled.Ok()) bitmap = m_bmpDisabled; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; foreColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); } wxBrush brush(backColour, wxSOLID); dc.SetBackground(brush); dc.SetBrush(brush); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(0, 0, w, h); if (bitmap.Ok()) dc.DrawBitmap(bitmap, m_bitmapPos.x, m_bitmapPos.y, TRUE ); if (!GetLabel().IsEmpty()) { dc.SetFont(GetFont()); dc.SetTextBackground(backColour); dc.SetTextForeground(foreColour); dc.DrawText(GetLabel(), m_labelPos.x, m_labelPos.y); } if (GetValue()) // draw sunken border { dc.SetPen(*wxGREY_PEN); dc.DrawLine(0,h-1,0,0); dc.DrawLine(0,0,w,0); dc.SetPen(*wxWHITE_PEN); dc.DrawLine(w-1,1,w-1,h-1); dc.DrawLine(w-1,h-1,0,h-1); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(1,h-2,1,1); dc.DrawLine(1,1,w-1,1); } else if (((m_button_style & wxCUSTBUT_FLAT) == 0) || m_focused) // draw raised border { dc.SetPen(*wxWHITE_PEN); dc.DrawLine(0,h-2,0,0); dc.DrawLine(0,0,w-1,0); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(w-1,0,w-1,h-1); dc.DrawLine(w-1,h-1,-1,h-1); dc.SetPen(*wxGREY_PEN); dc.DrawLine(2,h-2,w-2,h-2); dc.DrawLine(w-2,h-2,w-2,1); } dc.SetBackground(wxNullBrush); dc.SetBrush(wxNullBrush); dc.SetPen(wxNullPen); #if (wxMINOR_VERSION<8) dc.EndDrawing(); #endif }
void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) { int w = 0; int h = 0; GetClientSize(&w,&h); w -= scrollBar->GetSize().GetWidth(); dc.SetFont(font); dc.SetBackground(rowColors[COLOR_DEFAULT]); dc.Clear(); // Draw labels dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(rowColors[COLOR_LEFT_COL]); 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 wxColour text_standard(to_wx(OPT_GET("Colour/Subtitle Grid/Standard")->GetColor())); wxColour text_selection(to_wx(OPT_GET("Colour/Subtitle Grid/Selection")->GetColor())); wxColour text_collision(to_wx(OPT_GET("Colour/Subtitle Grid/Collision")->GetColor())); // First grid row wxPen grid_pen(to_wx(OPT_GET("Colour/Subtitle Grid/Lines")->GetColor())); dc.SetPen(grid_pen); dc.DrawLine(0, 0, w, 0); dc.SetPen(*wxTRANSPARENT_PEN); wxString strings[] = { _("#"), _("L"), _("Start"), _("End"), _("Style"), _("Actor"), _("Effect"), _("Left"), _("Right"), _("Vert"), _("Text") }; int override_mode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt(); wxString replace_char; if (override_mode == 1) replace_char = lagi_wxString(OPT_GET("Subtitle/Grid/Hide Overrides Char")->GetString()); for (int i = 0; i < nDraw + 1; i++) { int curRow = i + yPos - 1; RowColor curColor = COLOR_DEFAULT; // Header if (i == 0) { curColor = COLOR_HEADER; dc.SetTextForeground(text_standard); } // Lines else if (AssDialogue *curDiag = GetDialogue(curRow)) { GetRowStrings(curRow, curDiag, paint_columns, strings, !!override_mode, replace_char); bool inSel = !!selection.count(curDiag); if (inSel && curDiag->Comment) curColor = COLOR_SELECTED_COMMENT; else if (inSel) curColor = COLOR_SELECTION; else if (curDiag->Comment) curColor = COLOR_COMMENT; else if (OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame")->GetBool() && IsDisplayed(curDiag)) curColor = COLOR_VISIBLE; else curColor = COLOR_DEFAULT; if (active_line != curDiag && curDiag->CollidesWith(active_line)) dc.SetTextForeground(text_collision); else if (inSel) dc.SetTextForeground(text_selection); else dc.SetTextForeground(text_standard); } else { assert(false); } // Draw row background color if (curColor) { dc.SetBrush(rowColors[curColor]); dc.DrawRectangle((curColor == 1) ? 0 : colWidth[0],i*lineHeight+1,w,lineHeight); } // Draw text int dx = 0; int dy = i*lineHeight; for (int j = 0; j < 11; j++) { if (colWidth[j] == 0) continue; if (paint_columns[j]) { wxSize ext = dc.GetTextExtent(strings[j]); int left = dx + 4; int top = dy + (lineHeight - ext.GetHeight()) / 2; // Centered columns if (!(j == 4 || j == 5 || j == 6 || j == 10)) { left += (colWidth[j] - 6 - ext.GetWidth()) / 2; } dc.DrawText(strings[j], left, top); } dx += colWidth[j]; } // Draw grid dc.DestroyClippingRegion(); dc.SetPen(grid_pen); dc.DrawLine(0,dy+lineHeight,w,dy+lineHeight); dc.SetPen(*wxTRANSPARENT_PEN); } // Draw grid columns int dx = 0; dc.SetPen(grid_pen); 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,maxH); // Draw currently active line border if (GetActiveLine()) { dc.SetPen(wxPen(to_wx(OPT_GET("Colour/Subtitle Grid/Active Border")->GetColor()))); dc.SetBrush(*wxTRANSPARENT_BRUSH); int dy = (line_index_map[GetActiveLine()]+1-yPos) * lineHeight; dc.DrawRectangle(0,dy,w,lineHeight+1); } }