| 433 | } |
| 434 | |
| 435 | bool NumericTextCtrl::Layout() |
| 436 | { |
| 437 | if (!mFormatter) |
| 438 | return {}; |
| 439 | |
| 440 | ComputeSizing(); |
| 441 | |
| 442 | auto& prefix = mFormatter->GetPrefix(); |
| 443 | auto& fields = mFormatter->GetFields(); |
| 444 | auto& digits = mFormatter->GetDigitInfos(); |
| 445 | |
| 446 | wxMemoryDC memDC; |
| 447 | wxCoord strW, strH; |
| 448 | memDC.SetFont(*mLabelFont); |
| 449 | memDC.GetTextExtent(prefix, &strW, &strH); |
| 450 | |
| 451 | int i; |
| 452 | |
| 453 | // Draw the background bitmap - it contains black boxes where |
| 454 | // all of the digits go and all of the other text |
| 455 | wxPen Pen; |
| 456 | wxBrush Brush; |
| 457 | |
| 458 | mBackgroundBitmap = std::make_unique<wxBitmap>(mWidth + mButtonWidth, mHeight,24); |
| 459 | memDC.SelectObject(*mBackgroundBitmap); |
| 460 | |
| 461 | theTheme.SetBrushColour( Brush, clrTimeHours ); |
| 462 | memDC.SetBrush(Brush); |
| 463 | memDC.SetPen(*wxTRANSPARENT_PEN); |
| 464 | memDC.DrawRectangle(0, 0, mWidth + mButtonWidth, mHeight); |
| 465 | |
| 466 | int numberBottom = mBorderTop + (mDigitBoxH - mDigitH)/2 + mDigitH; |
| 467 | |
| 468 | memDC.GetTextExtent(wxT("0"), &strW, &strH); |
| 469 | int labelTop = numberBottom - strH; |
| 470 | |
| 471 | memDC.SetTextForeground(theTheme.Colour( clrTimeFont )); |
| 472 | memDC.SetTextBackground(theTheme.Colour( clrTimeBack )); |
| 473 | memDC.DrawText(prefix, mBorderLeft, labelTop); |
| 474 | |
| 475 | theTheme.SetBrushColour( Brush, clrTimeBack ); |
| 476 | memDC.SetBrush(Brush); |
| 477 | |
| 478 | for(i = 0; i < digits.size(); i++) |
| 479 | memDC.DrawRectangle(GetBox(i)); |
| 480 | memDC.SetBrush( wxNullBrush ); |
| 481 | |
| 482 | for(i = 0; i < fields.size(); i++) |
| 483 | memDC.DrawText(fields[i].label, mFieldPositions[i].labelX, labelTop); |
| 484 | |
| 485 | if (mMenuEnabled) { |
| 486 | theTheme.SetPenColour( Pen, clrTimeFont ); |
| 487 | theTheme.SetBrushColour( Brush, clrTimeFont ); |
| 488 | memDC.SetPen(Pen); |
| 489 | memDC.SetBrush(Brush); |
| 490 | AColor::Arrow(memDC, |
| 491 | mWidth + 5, |
| 492 | (mHeight / 2) - 2, |