예제 #1
0
void JBtnObj::update(JGraphics g, double dx, double dy, JRegion& rgn, double scale) {
  JRect rect = getIExtent(dx, dy, scale), thumb;
  JRegion frgn(rect.shrinkBy(depth, depth));
  if ((rect.width > 0) && (rect.height > 0)) {
    g.setJColor(bkgnd);
    g.fillJRect(rect);
    thumb = rect.shrink(depth, depth);
    if ((thumb.width > 0) && (thumb.height > 0)) {
      switch (type) {
        case TYPE_RECT:
          g.draw3DJRect(thumb, ((value) ? -depth : depth));
          break;
        case TYPE_LEFT:
        case TYPE_RIGHT:
        case TYPE_UP:
        case TYPE_DOWN:
          g.draw3DJTriangle(thumb, 
            ((value) ? -depth : depth), type-1);
          break;
      }
      if (label.length()) {
        g.setJColor(color);
        drawText(g, label, thumb.shrink(depth, depth));
      }
    }
  }
}
예제 #2
0
void J1DMObj::paint(JGraphics g, double dx, double dy, JRegion& rgn, double scale) {
     JRect rect = getIExtent(dx, dy, scale);
     g.setJColor(moduleColor);
     if ((rect.width > depth2) && (rect.height > depth2)) {
          g.draw3DJRect(rect, depth);
          g.fillJRect(rect.shrinkBy(depth, depth));
//          g.draw3DJRect(rect.shrink(depth, depth), -1);
	 } else g.fillJRect(rect);
     update(g, dx, dy, rgn, scale);
}
예제 #3
0
void J1DSliderObj::update(JGraphics g, double dx, double dy, JRegion& rgn, double scale) {
  int dt = depth2+2;
  JRect rect = getIExtent(dx, dy, scale);
  if ((rect.width > dt) && (rect.height > dt)) {
    int oldv = value;
    JRect clip = rect, thumb;
    JRegion frgn(clip.shrinkBy(depth+1, depth+1));
    if (type == HORIZONTAL) {
      int len = rect.width-dt-dt;
      if (oldf != factor) {
	oldf = factor;
	fraction = (factor*rect.width-dt)/len;
	fraction = max(0.0, min(1.0, fraction));
      }
      int pos = (int)JMath::round(fraction*len);
      thumb = JRect(clip.x+pos, clip.y, dt, clip.height);
    } else {
      int len = rect.height-dt-dt;
      if (oldf != factor) {
	oldf = factor;
	fraction = (factor*rect.height-dt)/len;
	fraction = max(0.0, min(1.0, fraction));
      }
      int pos = (int)JMath::round((1.0-fraction)*len);
      thumb = JRect(clip.x, clip.y+pos, clip.width, dt);
    }
    int vmin = getMin();
    value = (int)JMath::round(fraction*(getMax()-vmin)+vmin);
    if (value != oldv) broadcast(0);
    g.setJColor(color);
    g.fill3DJRect(thumb, depth);
    g.setJRegion((frgn & rgn)-JRegion(thumb));
    g.setJColor(bkgnd);
    g.fillJRect(clip);
    g.setJRegion(rgn);
  }
}