private void paintSliderBackground(Graphics g, Bitmap left, Bitmap middle, Bitmap right) {
    int sliderHeight = _imageSlider.getHeight();
    int sliderBackYOffset = (_totalHeight - sliderHeight) >> 1;

    // Left
    g.drawBitmap(0, sliderBackYOffset, _xLeftBackMargin, sliderHeight, left, 0, 0); // lefttop
    // Middle
    g.tileRop(
        _rop,
        _xRightBackMargin,
        sliderBackYOffset,
        _totalWidth - _xLeftBackMargin - _xRightBackMargin,
        sliderHeight,
        middle,
        0,
        0); // top
    // Right
    g.drawBitmap(
        _totalWidth - _xRightBackMargin,
        sliderBackYOffset,
        _xRightBackMargin,
        sliderHeight,
        right,
        0,
        0); // lefttop
  }
 protected void drawFocus(Graphics g, boolean on) {
   boolean oldDrawStyleFocus = g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS);
   try {
     if (on) {
       g.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, true);
     }
     paint(g);
   } finally {
     g.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, oldDrawStyleFocus);
   }
 }
  public void paint(Graphics g) {
    // Calculate the slider position
    int sliderHeight = _imageSlider.getHeight();
    int sliderBackYOffset = (_totalHeight - sliderHeight) >> 1;

    // Determine a Background Color for the slider
    int backgroundColor = _defaultBackgroundColour;
    if (_backgroundSelectedColours != null || _backgroundColours != null) {

      if (_selected) {
        backgroundColor =
            _backgroundSelectedColours != null
                ? _backgroundSelectedColours[getState()]
                : _defaultSelectColour;
      } else if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
        backgroundColor =
            _backgroundColours != null ? _backgroundColours[getState()] : _defaultHoverColour;
      } else {
        backgroundColor = _defaultBackgroundColour;
      }
    }
    g.setColor(backgroundColor);
    g.fillRect(1, sliderBackYOffset + 1, _totalWidth - 2, sliderHeight - 2);

    if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
      paintSliderBackground(
          g, _imageSliderFocusLeft, _imageSliderFocusCenter, _imageSliderFocusRight);
    } else {
      paintSliderBackground(g, _imageSliderLeft, _imageSliderCenter, _imageSliderRight);
    }

    // Calculate the thumb position
    int thumbXOffset = ((_totalWidth - _thumbWidth) * _currentState) / _numStates;

    // Draw the thumb
    g.drawBitmap(
        thumbXOffset,
        (_totalHeight - _thumbHeight) >> 1,
        _thumbWidth,
        _thumbHeight,
        _imageThumb,
        0,
        0);
  }
Пример #4
0
 protected void paint(Graphics graphics) {
   if (m_bitmap != null)
     graphics.drawBitmap(0, 0, getVisibleWidth(), getVisibleHeight(), m_bitmap, 0, 0);
 }
Пример #5
0
 protected void drawFocus(Graphics g, boolean on) {
   // Paint() handles it all
   g.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, true);
   paintBackground(g);
   paint(g);
 }
Пример #6
0
 protected void paint(Graphics g) {
   int index = g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS) ? FOCUS : NORMAL;
   g.drawBitmap(
       0, 0, _bitmaps[index].getWidth(), _bitmaps[index].getHeight(), _bitmaps[index], 0, 0);
 }
  /**
   * Field implementation.
   *
   * @see net.rim.device.api.ui.Field#paint(Graphics)
   */
  protected void paint(Graphics graphics) {
    // First draw the background colour and picture

    switch (Display.getWidth()) {
      case 480:
        graphics.drawBitmap(12, 10, dbmp.getWidth(), dbmp.getHeight(), dbmp, 0, 0);
        graphics.drawBitmap(167, 10, ibmp.getWidth(), ibmp.getHeight(), ibmp, 0, 0);
        graphics.drawBitmap(324, 10, tbmp.getWidth(), tbmp.getHeight(), tbmp, 0, 0);
        graphics.setFont(font);
        graphics.setColor(Color.DARKSLATEGRAY);
        graphics.drawText(_dboc, 18, 40);
        graphics.drawText(_iboc, 173, 40);
        graphics.drawText(_tboc, 330, 40);
        break;
      case 360:
        graphics.drawBitmap(15, 10, dbmp.getWidth(), dbmp.getHeight(), dbmp, 0, 0);
        graphics.drawBitmap(185, 10, ibmp.getWidth(), ibmp.getHeight(), ibmp, 0, 0);
        graphics.setFont(font);
        graphics.setColor(Color.DARKSLATEGRAY);
        graphics.drawText(_dboc, 28, 40);
        graphics.drawText(_iboc, 198, 40);
        graphics.drawBitmap(15, 65, tbmp.getWidth(), tbmp.getHeight(), tbmp, 0, 0);
        graphics.drawText(_tboc, 130, 95);
        break;
      default:
        graphics.drawBitmap(15, 9, dbmp.getWidth(), dbmp.getHeight(), dbmp, 0, 0);
        graphics.drawBitmap(166, 10, ibmp.getWidth(), ibmp.getHeight(), ibmp, 0, 0);
        graphics.setFont(font);
        graphics.setColor(Color.DARKSLATEGRAY);
        graphics.drawText(_dboc, 18, 40);
        graphics.drawText(_iboc, 172, 40);
        graphics.drawBitmap(15, 65, tbmp.getWidth(), tbmp.getHeight(), tbmp, 0, 0);
        graphics.drawText(_tboc, 110, 95);
        break;
    }
  }