home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / COMMON / TOOLS / VB / CABINETS / MSDAO350.CAB / icontrols / marquee / ImageElement.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-08  |  3.0 KB  |  87 lines

  1. package icontrols.marquee;
  2.  
  3. import com.ms.wd.ui.Bitmap;
  4. import com.ms.wd.ui.Control;
  5. import com.ms.wd.ui.Graphics;
  6. import com.ms.wd.ui.Point;
  7. import com.ms.wd.ui.Rectangle;
  8. import com.ms.wd.win32.RECT;
  9. import com.ms.wd.win32.Windows;
  10.  
  11. public class ImageElement implements IMarqueeElement {
  12.    Bitmap m_bitmapCached;
  13.    Graphics m_graphicsCached;
  14.    Rectangle m_location = new Rectangle();
  15.    Object m_tag;
  16.    int m_wrapCount = 0;
  17.  
  18.    public void create(Control ctl, int width, int height) {
  19.       if (this.m_bitmapCached != null) {
  20.          Point size = this.m_bitmapCached.getSize();
  21.          this.m_location.width = width > size.x | width == 0 ? size.x : width;
  22.          this.m_location.height = height > size.y | height == 0 ? size.y : height;
  23.          this.m_graphicsCached = this.m_bitmapCached.getGraphics();
  24.       }
  25.  
  26.    }
  27.  
  28.    public ImageElement(Object tag, Bitmap bitmap) {
  29.       this.m_tag = tag;
  30.       this.m_bitmapCached = bitmap;
  31.    }
  32.  
  33.    public Object getTag() {
  34.       return this.m_tag;
  35.    }
  36.  
  37.    public Object getTag(int x, int y) {
  38.       return this.m_location.contains(x, y) ? this.m_tag : null;
  39.    }
  40.  
  41.    public void paintIn(Rectangle rec, Graphics g) {
  42.       if (this.m_graphicsCached != null) {
  43.          RECT recIntersect = new RECT();
  44.          RECT recPaint = rec.toRECT();
  45.          RECT recLocation = this.m_location.toRECT();
  46.          if (Windows.IntersectRect(recIntersect, recPaint, recLocation)) {
  47.             Windows.BitBlt(g.getHandle(), recIntersect.left, recIntersect.top, recIntersect.right - recIntersect.left, recIntersect.bottom - recIntersect.top, this.m_graphicsCached.getHandle(), recIntersect.left - this.m_location.x, recIntersect.top - this.m_location.y, 13369376);
  48.          }
  49.       }
  50.  
  51.    }
  52.  
  53.    public void scroll(int x, int y) {
  54.       Rectangle var10000 = this.m_location;
  55.       var10000.x += x;
  56.       var10000 = this.m_location;
  57.       var10000.y += y;
  58.    }
  59.  
  60.    public int getWrapCount() {
  61.       return this.m_wrapCount;
  62.    }
  63.  
  64.    public void setWrapCount(int count) {
  65.       this.m_wrapCount = count;
  66.    }
  67.  
  68.    public void finalize() {
  69.       if (this.m_graphicsCached != null) {
  70.          this.m_graphicsCached.dispose();
  71.          this.m_graphicsCached = null;
  72.       }
  73.  
  74.    }
  75.  
  76.    public Rectangle getBounds() {
  77.       return this.m_location;
  78.    }
  79.  
  80.    public void setLocation(int x, int y) {
  81.       Rectangle var10000 = this.m_location;
  82.       var10000.x += x;
  83.       var10000 = this.m_location;
  84.       var10000.y += y;
  85.    }
  86. }
  87.