GtkComponentPeer.java [plain text]
package gnu.awt.gtk;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.peer.ComponentPeer;
public abstract class GtkComponentPeer implements ComponentPeer
{
static EventQueue eventQueue = new EventQueue();
Component awtComponent;
gnu.gcj.RawData ptr;
static
{
GtkToolkit.instance.init();
}
public int checkImage (Image image, int width, int height,
ImageObserver observer)
{
return -1;
}
public Image createImage (ImageProducer producer)
{
return null;
}
public Image createImage (int width, int height)
{
return null;
}
public void disable ()
{
setEnabled (false);
}
native public void dispose ();
public void enable ()
{
setEnabled (true);
}
public GraphicsConfiguration getGraphicsConfiguration ()
{
return null;
}
public FontMetrics getFontMetrics (Font font)
{
return null;
}
public Graphics getGraphics ()
{
throw new InternalError ();
}
public native Point getLocationOnScreen ();
public native Dimension getMinimumSize();
public native Dimension getPreferredSize();
public Toolkit getToolkit ()
{
return GtkToolkit.instance;
}
public void handleEvent(AWTEvent e)
{
}
public void hide ()
{
setVisible (false);
}
public void show ()
{
setVisible (true);
}
public boolean isFocusTraversable ()
{
return true;
}
public Dimension minimumSize ()
{
return getMinimumSize();
}
public Dimension preferredSize()
{
return getPreferredSize();
}
public void paint (Graphics g)
{
awtComponent.paint (g); }
public boolean prepareImage (Image image, int width, int height,
ImageObserver observer)
{
return false;
}
public void print (Graphics g)
{
throw new RuntimeException ();
}
native public void requestFocus ();
public void repaint (long tm, int x, int y, int width, int height)
{
eventQueue.postEvent (new PaintEvent (
awtComponent, PaintEvent.UPDATE, new Rectangle (x, y, width, height)));
}
public void reshape (int x, int y, int width, int height)
{
setBounds (x, y, width, height);
}
public native void setBounds (int x, int y, int width, int height);
public native void setCursor (Cursor cursor);
public native void setEnabled (boolean b);
public native void setEventMask(long eventMask);
public native void setFont(Font font);
public native void setForeground(Color color);
public native void setBackground (Color c);
public native void setVisible(boolean visible);
native void realize();
protected GtkComponentPeer (Component awtComponent)
{
this.awtComponent = awtComponent;
create();
Rectangle r = awtComponent.getBounds();
setBounds (r.x, r.y, r.width, r.height);
Color c = awtComponent.getForeground();
if (c != null)
setForeground (c);
c = awtComponent.getBackground();
if (c != null)
setBackground (c);
setEnabled (awtComponent.isEnabled());
Font f = awtComponent.getFont();
if (f != null)
setFont (awtComponent.getFont());
realize();
}
protected native void create ();
protected void postMouseEvent(int id, long when, int mods, int x, int y,
int clickCount, boolean popupTrigger)
{
eventQueue.postEvent(new MouseEvent(awtComponent, id, when, mods, x, y,
clickCount, popupTrigger));
}
protected void postExposeEvent (int x, int y, int width, int height)
{
eventQueue.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
new Rectangle (x, y, width, height)));
}
protected void postKeyEvent (int id, long when, int mods,
int keyCode, char keyChar)
{
eventQueue.postEvent (new KeyEvent (awtComponent, id, when, mods,
keyCode, keyChar));
}
protected void postFocusEvent (int id, boolean temporary)
{
eventQueue.postEvent (new FocusEvent (awtComponent, id, temporary));
}
protected void postItemEvent (Object item, int stateChange)
{
eventQueue.postEvent (new ItemEvent ((ItemSelectable)awtComponent,
ItemEvent.ITEM_STATE_CHANGED,
item, stateChange));
}
}