Example #1
0
void
WndProperty::on_paint(Canvas &canvas)
{
  const bool focused = edit.has_focus();

  /* background and selector */
  if (focused) {
    canvas.clear(look.focused.background_color);
    PaintSelector(canvas, get_client_rect(), look);
  } else {
    /* don't need to erase the background when it has been done by the
       parent window already */
    if (have_clipping())
      canvas.clear(look.background_color);
  }

  WindowControl::on_paint(canvas);

  /* kludge: don't draw caption if width is too small (but not 0),
     used by the polar configuration panel.  This concept needs to be
     redesigned. */
  if (mCaptionWidth != 0 && !mCaption.empty()) {
    canvas.set_text_color(focused
                          ? look.focused.text_color
                          : look.text_color);
    canvas.background_transparent();
    canvas.select(*look.text_font);

    PixelSize tsize = canvas.text_size(mCaption.c_str());

    RasterPoint org;
    if (mCaptionWidth < 0) {
      org.x = mEditPos.x;
      org.y = mEditPos.y - tsize.cy;
    } else {
      org.x = mCaptionWidth - (tsize.cx + 1);
      org.y = (get_size().cy - tsize.cy) / 2;
    }

    if (org.x < 1)
      org.x = 1;

    if (have_clipping())
      canvas.text(org.x, org.y, mCaption.c_str());
    else
      canvas.text_clipped(org.x, org.y, mCaptionWidth - org.x,
                          mCaption.c_str());
  }
}
Example #2
0
void
WndProperty::on_paint(Canvas &canvas)
{
  /* background and selector */
  if (edit.has_focus()) {
    canvas.clear(GetBackColor().highlight());
    PaintSelector(canvas, get_client_rect());
  } else
    canvas.clear(GetBackColor());

  SIZE tsize;
  POINT org;

  WindowControl::on_paint(canvas);

  canvas.set_text_color(GetForeColor());
  canvas.background_transparent();
  canvas.select(*GetFont());

  tsize = canvas.text_size(mCaption);

  if (mCaptionWidth == 0) {
    org.x = mEditPos.x;
    org.y = mEditPos.y - tsize.cy;
  } else {
    org.x = mCaptionWidth - mBitmapSize - (tsize.cx + 1);
    org.y = (get_size().cy - tsize.cy) / 2;
  }

  if (org.x < 1)
    org.x = 1;

  canvas.text(org.x, org.y, mCaption);

  // can't but dlgComboPicker here b/c it calls paint when combopicker closes too
  // so it calls dlgCombopicker on the click/focus handlers for the wndproperty & label
  if (!mDialogStyle && edit.has_focus() && !edit.is_read_only()) {
    canvas.stretch(mHitRectDown.left, mHitRectDown.top,
                   mBitmapSize, mBitmapSize,
                   hBmpLeft32,
                   mDownDown ? 32 : 0, 0, 32, 32);

    canvas.stretch(mHitRectUp.left, mHitRectUp.top,
                   mBitmapSize, mBitmapSize,
                   hBmpRight32,
                   mUpDown ? 32 : 0, 0, 32, 32);
  }
}
Example #3
0
void
WndProperty::on_paint(Canvas &canvas)
{
  const bool focused = edit.has_focus();

  /* background and selector */
  if (focused) {
    canvas.clear(look.focused.background_color);
    PaintSelector(canvas, get_client_rect(), look);
  } else {
    /* don't need to erase the background when it has been done by the
       parent window already */
    if (have_clipping())
      canvas.clear(look.background_color);
  }

  WindowControl::on_paint(canvas);

  /* kludge: don't draw caption if width is too small (but not 0),
     used by the polar configuration panel.  This concept needs to be
     redesigned. */
  if (mCaptionWidth != 0 && !mCaption.empty()) {
    canvas.set_text_color(focused
                          ? look.focused.text_color
                          : look.text_color);
    canvas.background_transparent();
    canvas.select(*GetFont());

    PixelSize tsize = canvas.text_size(mCaption.c_str());

    RasterPoint org;
    if (mCaptionWidth < 0) {
      org.x = mEditPos.x;
      org.y = mEditPos.y - tsize.cy;
    } else {
      org.x = mCaptionWidth - mBitmapSize - (tsize.cx + 1);
      org.y = (get_size().cy - tsize.cy) / 2;
    }

    if (org.x < 1)
      org.x = 1;

    if (have_clipping())
      canvas.text(org.x, org.y, mCaption.c_str());
    else
      canvas.text_clipped(org.x, org.y, mCaptionWidth - org.x,
                          mCaption.c_str());
  }

  // can't but dlgComboPicker here b/c it calls paint when combopicker closes too
  // so it calls dlgCombopicker on the click/focus handlers for the wndproperty & label
  if (!mDialogStyle && edit.has_focus() && !edit.is_read_only()) {
    canvas.stretch(mHitRectDown.left, mHitRectDown.top,
                   mBitmapSize, mBitmapSize,
                   hBmpLeft32,
                   mDownDown ? 32 : 0, 0, 32, 32);

    canvas.stretch(mHitRectUp.left, mHitRectUp.top,
                   mBitmapSize, mBitmapSize,
                   hBmpRight32,
                   mUpDown ? 32 : 0, 0, 32, 32);
  }
}