MCPcopy Create free account
hub / github.com/LMMS/lmms / paintEvent

Method paintEvent

src/gui/widgets/LcdWidget.cpp:128–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126
127
128void LcdWidget::paintEvent( QPaintEvent* )
129{
130 QPainter p( this );
131
132 QSize cellSize( m_cellWidth, m_cellHeight );
133
134 QRect cellRect( 0, 0, m_cellWidth, m_cellHeight );
135
136 int margin = 1; // QStyle::PM_DefaultFrameWidth;
137 //int lcdWidth = m_cellWidth * m_numDigits + (margin*m_marginWidth)*2;
138
139// p.translate( width() / 2 - lcdWidth / 2, 0 );
140 p.save();
141
142 p.translate( margin, margin );
143
144 // Left Margin
145 p.drawPixmap( cellRect, *m_lcdPixmap,
146 QRect( QPoint( charsPerPixmap*m_cellWidth,
147 isEnabled()?0:m_cellHeight ),
148 cellSize ) );
149
150 p.translate( m_marginWidth, 0 );
151
152 // Padding
153 for( int i=0; i < m_numDigits - m_display.length(); i++ )
154 {
155 p.drawPixmap( cellRect, *m_lcdPixmap,
156 QRect( QPoint( 10 * m_cellWidth, isEnabled()?0:m_cellHeight) , cellSize ) );
157 p.translate( m_cellWidth, 0 );
158 }
159
160 // Digits
161 for( int i=0; i < m_display.length(); i++ )
162 {
163 int val = m_display[i].digitValue();
164 if( val < 0 )
165 {
166 if( m_display[i] == '-' )
167 val = 11;
168 else
169 val = 10;
170 }
171 p.drawPixmap( cellRect, *m_lcdPixmap,
172 QRect( QPoint( val*m_cellWidth,
173 isEnabled()?0:m_cellHeight ),
174 cellSize ) );
175 p.translate( m_cellWidth, 0 );
176 }
177
178 // Right Margin
179 p.drawPixmap( QRect( 0, 0, m_marginWidth-1, m_cellHeight ), *m_lcdPixmap,
180 QRect( charsPerPixmap*m_cellWidth, isEnabled()?0:m_cellHeight,
181 m_cellWidth / 2, m_cellHeight ) );
182
183
184 p.restore();
185

Callers

nothing calls this directly

Calls 7

QRectClass · 0.85
isEnabledFunction · 0.85
pointSizeFFunction · 0.85
saveMethod · 0.80
drawPrimitiveMethod · 0.80
lengthMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected