MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / OnPaint

Method OnPaint

src/base_grid.cpp:265–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265void BaseGrid::OnPaint(wxPaintEvent &) {
266 // Find which columns need to be repainted
267 std::vector<char> paint_columns;
268 paint_columns.resize(columns.size(), false);
269 bool any = false;
270 for (wxRegionIterator region(GetUpdateRegion()); region; ++region) {
271 wxRect updrect = region.GetRect();
272 int x = 0;
273 for (size_t i : agi::util::range(columns.size())) {
274 int width = columns[i]->Width();
275 if (width && updrect.x < x + width && updrect.x + updrect.width > x) {
276 paint_columns[i] = true;
277 any = true;
278 }
279 x += width;
280 }
281 }
282
283 if (!any) return;
284
285 int w = 0;
286 int h = 0;
287 GetClientSize(&w,&h);
288 w -= scrollBar->GetSize().GetWidth();
289
290 wxAutoBufferedPaintDC dc(this);
291 dc.SetFont(font);
292
293 dc.SetBackground(row_colors.Default);
294 dc.Clear();
295
296 // Draw labels
297 dc.SetPen(*wxTRANSPARENT_PEN);
298 dc.SetBrush(row_colors.LeftCol);
299 dc.DrawRectangle(0, lineHeight, columns[0]->Width(), h-lineHeight);
300
301 // Row colors
302 wxColour text_standard(to_wx(OPT_GET("Colour/Subtitle Grid/Standard")->GetColor()));
303 wxColour text_selection(to_wx(OPT_GET("Colour/Subtitle Grid/Selection")->GetColor()));
304 wxColour text_collision(to_wx(OPT_GET("Colour/Subtitle Grid/Collision")->GetColor()));
305
306 // First grid row
307 wxPen grid_pen(to_wx(OPT_GET("Colour/Subtitle Grid/Lines")->GetColor()));
308 dc.SetPen(grid_pen);
309 dc.DrawLine(0, 0, w, 0);
310 dc.SetPen(*wxTRANSPARENT_PEN);
311
312 auto paint_text = [&](wxString const& str, int x, int y, int col) {
313 int left = x + 4;
314 if (columns[col]->Centered()) {
315 wxSize ext = dc.GetTextExtent(str);
316 left += (columns[col]->Width() - 6 - ext.GetWidth()) / 2;
317 }
318
319 dc.DrawText(str, left, y + 2);
320 };
321
322 // Paint header

Callers

nothing calls this directly

Calls 15

wxPenClass · 0.85
SetFontMethod · 0.80
SetBackgroundMethod · 0.80
DrawRectangleMethod · 0.80
GetColorMethod · 0.80
DrawLineMethod · 0.80
GetActiveLineMethod · 0.80
push_backMethod · 0.80
CollidesWithMethod · 0.80
rangeFunction · 0.70
to_wxFunction · 0.70
midFunction · 0.70

Tested by

no test coverage detected