If you have a complex background you want for your Component and you don’t need it to be redrawn from scratch in your paint() method you can create a background Image and use that in your paint() method.
Something like:
void CMidiDisplayComponent::createNewBackground()
{
m_GrooveBackground = Image (Image::RGB,
jmax (1, m_Background.getWidth()), jmax (1, m_Background.getHeight()),
true);
Graphics g (m_GrooveBackground); // m_GrooveBackground is a class Image member
g.drawImageAt (m_Background, 0, 0); // m_Background is a class Image member
drawStaffLines (g);
:
repaint();
}
then
void CMidiDisplayComponent::paint (Graphics& g)
{
g.drawImageAt (m_GrooveBackground, 0, 0);
}
That way the background in this example only gets recalculated/redrawn when the groove’s length changes.
Rail
