Пример #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());
  }
}
Пример #2
0
void
WndProperty::OnPaint(Canvas &canvas)
{
  const bool focused = edit.has_focus();

  /* background and selector */
  if (focused) {
    canvas.clear(look.focused.background_color);
  } 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::OnPaint(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 (caption_width != 0 && !caption.empty()) {
    canvas.SetTextColor(focused
                          ? look.focused.text_color
                          : look.text_color);
    canvas.SetBackgroundTransparent();
    canvas.Select(*look.text_font);

    PixelSize tsize = canvas.CalcTextSize(caption.c_str());

    RasterPoint org;
    if (caption_width < 0) {
      org.x = edit_rc.left;
      org.y = edit_rc.top - tsize.cy;
    } else {
      org.x = caption_width - tsize.cx - Layout::FastScale(3);
      org.y = (get_size().cy - tsize.cy) / 2;
    }

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

    if (have_clipping())
      canvas.text(org.x, org.y, caption.c_str());
    else
      canvas.text_clipped(org.x, org.y, caption_width - org.x,
                          caption.c_str());
  }
}
Пример #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);
  }
}