home *** CD-ROM | disk | FTP | other *** search
- package icontrols.marquee;
-
- import com.ms.wd.ui.Bitmap;
- import com.ms.wd.ui.Brush;
- import com.ms.wd.ui.Color;
- import com.ms.wd.ui.Control;
- import com.ms.wd.ui.Font;
- import com.ms.wd.ui.Graphics;
- import com.ms.wd.ui.Point;
- import com.ms.wd.ui.Rectangle;
- import com.ms.wd.win32.RECT;
- import com.ms.wd.win32.Windows;
-
- public class TextElement implements IMarqueeElement {
- String m_text;
- Font m_font;
- Color m_colorBack;
- Color m_colorFore;
- Bitmap m_bitmapCached;
- Graphics m_graphicsCached;
- Rectangle m_location = new Rectangle();
- Object m_tag;
- int m_wrapCount = 0;
-
- public void create(Control ctl, int width, int height) {
- Graphics g = ctl.createGraphics();
- if (this.m_font == null) {
- this.m_font = g.getFont();
- } else {
- g.setFont(this.m_font);
- }
-
- if (this.m_colorBack == null) {
- this.m_colorBack = g.getBackColor();
- }
-
- if (this.m_colorFore == null) {
- this.m_colorFore = g.getTextColor();
- }
-
- Point extents;
- if (width == 0) {
- extents = g.getTextSize(this.m_text);
- } else {
- extents = g.getTextSize(this.m_text, width, 16);
- }
-
- this.m_location.width = width > extents.x | width == 0 ? extents.x : width;
- this.m_location.height = height > extents.y | height == 0 ? extents.y : height;
- this.m_bitmapCached = new Bitmap(extents.x, extents.y);
- this.m_graphicsCached = this.m_bitmapCached.getGraphics();
- this.m_graphicsCached.setFont(this.m_font);
- this.m_graphicsCached.setBackColor(this.m_colorBack);
- this.m_graphicsCached.setTextColor(this.m_colorFore);
- if (width == 0) {
- this.m_graphicsCached.drawString(this.m_text, 0, 0);
- } else {
- this.m_graphicsCached.setBrush(new Brush(this.m_colorBack));
- this.m_graphicsCached.drawRect(0, 0, extents.x, extents.y);
- this.m_graphicsCached.drawString(this.m_text, 0, 0, extents.x, extents.y, 16);
- }
-
- g.dispose();
- }
-
- public TextElement(Object tag, String text, Font font, Color fore, Color back) {
- this.m_tag = tag;
- this.m_text = text;
- this.m_font = font;
- this.m_colorBack = back;
- this.m_colorFore = fore;
- }
-
- public Object getTag() {
- return this.m_tag;
- }
-
- public Object getTag(int x, int y) {
- return this.m_location.contains(x, y) ? this.m_tag : null;
- }
-
- public void paintIn(Rectangle rec, Graphics g) {
- if (this.m_graphicsCached != null) {
- RECT recIntersect = new RECT();
- RECT recPaint = rec.toRECT();
- RECT recLocation = this.m_location.toRECT();
- if (Windows.IntersectRect(recIntersect, recPaint, recLocation)) {
- 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);
- }
- }
-
- }
-
- public void scroll(int x, int y) {
- Rectangle var10000 = this.m_location;
- var10000.x += x;
- var10000 = this.m_location;
- var10000.y += y;
- }
-
- public int getWrapCount() {
- return this.m_wrapCount;
- }
-
- public void setWrapCount(int i) {
- this.m_wrapCount = i;
- }
-
- public void finalize() {
- if (this.m_graphicsCached != null) {
- this.m_graphicsCached.dispose();
- this.m_graphicsCached = null;
- }
-
- }
-
- public Rectangle getBounds() {
- return this.m_location;
- }
-
- public void setLocation(int x, int y) {
- this.m_location.x = x;
- this.m_location.y = y;
- }
- }
-