//----------------------------------------------------------------------------
// Method: NewControl::paintWindow
//
// Description: 'paintWindow' is called in response to a paint event, 'evt'.
//              It establishes the colors to paint as well as determines
//              how large and where to draw the text.
//----------------------------------------------------------------------------
Boolean NewControl::paintWindow(IPaintEvent& evt)
   {
   IColor clrBackground(defclrBackground);
   IColor clrForeground(defclrForeground);
   IColor clrHilite(defclrHilite);

   IPresSpaceHandle hps = evt.presSpaceHandle();

   // Should make a separate method which sets the logical
   // color table for the HPS into RGB mode and sets all our
   // colors. Also, colors could be cached in private data
   // and only updated when presparams change.
   establishColor(clrBackground, background, defclrBackground);
   establishColor(clrForeground, foreground, defclrForeground);
   establishColor(clrHilite, hilite, defclrHilite);

   evt.clearBackground(clrBackground);

   // Create the text to draw
   IString theText(dummyText);
   IString theNumber(clicks);
   theNumber.rightJustify(4);
   IString both(theText + theNumber);

   POINTL aptl[TXTBOX_COUNT];
   POINTL ptl = {0,0};

   // Find where we're going to draw our text and how big it will be.
   GpiQueryTextBox(hps,
                   strlen((char*)both),
                   (char*)both,
                   TXTBOX_COUNT,
                   aptl);

   long textWidth = MAX(aptl[TXTBOX_TOPRIGHT].x,
                        aptl[TXTBOX_BOTTOMRIGHT].x);
   long textHeight = MAX(aptl[TXTBOX_TOPLEFT].y,
                         aptl[TXTBOX_TOPRIGHT].y);

   // Center the text before drawing it.
   long x = (cx - textWidth) / 2;
   long y = (cy - textHeight) / 2;

   evt.drawText(theText, IPoint(x, y), clrForeground);

   GpiQueryTextBox(hps,
                   strlen((char*)theText),
                   (char*)theText,
                   TXTBOX_COUNT,
                   aptl);

   // Draw the number to the side of the text
   x += aptl[TXTBOX_CONCAT].x;
   evt.drawText(theNumber, IPoint(x, y), clrHilite);

   return true;
   }
QPixmap QSettingColorTableItem::CreatePixmap() const
{
	if (m_pSetting == NULL || (m_pSetting->GetType() & 0xF) != Setting::SettingTypeColor)
		return QPixmap();
	else
	{
		QPixmap bmpImage(sizeHint().height() - 4, sizeHint().height() - 4);
		QPainter dcImage;
		QColor clrBackground(m_pSetting->GetValue().strValue);
		dcImage.begin(&bmpImage, table()->viewport());
		dcImage.setBackgroundColor(clrBackground.isValid() ? clrBackground : QColor(0, 0, 0));
		dcImage.eraseRect(bmpImage.rect());
		dcImage.drawRect(bmpImage.rect());
		dcImage.end();
		return bmpImage;
	}
}