sdl.test.gui.unit
Class ImageComp

java.lang.Object
  |
  +--sdl.test.gui.GUIComponent
        |
        +--sdl.test.gui.unit.ImageComp
All Implemented Interfaces:
sdl.event.EventListener, GUIHierarchyListener

public class ImageComp
extends GUIComponent

Demonstrates extending GUIComponent, draws a picture in the background. Here's the code

 public class ImageComp extends GUIComponent
 {
         private SDLSurface background;
 
         public ImageComp(String filename)
         {
                 background = SDLImage.createFromFile(filename);
         }
         public void paint(GUIGraphics g)
         {
 
                 //super.paint(g);
                 java.awt.Rectangle bounds = this.getBounds();
                 g.setColor(getBackground());
                 g.fill3DRect(bounds);
 
                 int w,h;
 
                 // take the smaller of the two dimensions
                 if ((w=background.m_Width)> bounds.width) w=bounds.width-6;
                 if ((h=background.m_Height)> bounds.height) h=bounds.height-6;
 
                 // Remember, for g, all coordinates are rleative to parent
                 SDLRect src = new SDLRect(0,0,w,h);
                 SDLRect dest = new SDLRect(bounds.x+3,bounds.y+3,bounds.width,bounds.height);
                 System.out.println("ImageComp blitting surface src, dest="+ src + " " +dest);
                 g.blitSurface(background,src,dest);	
 
         }
 
  } 
  


Field Summary
 
Fields inherited from class sdl.test.gui.GUIComponent
componentListeners, parent, subComponents
 
Constructor Summary
ImageComp(java.lang.String filename)
           
 
Method Summary
 void paint(GUIGraphics g)
           
 
Methods inherited from class sdl.test.gui.GUIComponent
addComponentListener, contains, dispatchEvent, getBackground, getBounds, getComponentAt, getGraphics, getLocation, getLocationOnScreen, getParent, getSize, incomingEvents, paintAll, processEvent, setBackground, setBounds, setBounds, setLocation, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageComp

public ImageComp(java.lang.String filename)
Method Detail

paint

public void paint(GUIGraphics g)
Overrides:
paint in class GUIComponent