prims.cc (_Jv_argv, _Jv_argc): New fields.

2000-10-02  Bryce McKinlay  <bryce@albatross.co.nz>

	* prims.cc (_Jv_argv, _Jv_argc): New fields.
	(JvRunMain): Set _Jv_argv and _Jv_argc.
	* java/awt/Component.java: Minor fixes.
	* java/awt/Image.java (UndefinedProperty): Initialize final field.
	* java/awt/Toolkit.java (systemEventQueue): Removed.
	(getDefaultToolkit): Default to "gnu.awt.gtk.GtkToolkit".
	* java/awt/Window.java (getToolkit): Don't call super.
	* java/awt/image/BufferedImage.java: Fix definate assignment errors.
	* java/awt/peer/ContainerPeer.java (insets): Remove unused method.
	* gnu/awt/gtk/GtkComponentPeer.java: New file.
	* gnu/awt/gtk/GtkContainerPeer.java: New file.
	* gnu/awt/gtk/GtkFramePeer.java: New file.
	* gnu/awt/gtk/GtkMainThread.java: New file.
	* gnu/awt/gtk/GtkToolkit.java: New file.
	* gnu/awt/gtk/GtkWindowPeer.java: New file.
	* gnu/awt/gtk/gtkcommon.cc: New file.
	* gnu/awt/gtk/gtkcommon.h: New file.
	* gnu/awt/gtk/natGtkComponentPeer.cc: New file.
	* gnu/awt/gtk/natGtkContainerPeer.cc: New file.
	* gnu/awt/gtk/natGtkFramePeer.cc: New file.
	* gnu/awt/gtk/natGtkMainThread.cc: New file.
	* gnu/awt/gtk/natGtkToolkit.cc: New file.
	* gnu/awt/gtk/natGtkWindowPeer.cc: New file.

From-SVN: r36688
This commit is contained in:
Bryce McKinlay 2000-10-02 06:14:25 +01:00
parent f15b9af984
commit 0acff4bc96
21 changed files with 1266 additions and 12 deletions

View File

@ -0,0 +1,269 @@
/* GtkComponentPeer.java -- Implements ComponentPeer with GTK
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the peer AWT libraries of GNU Classpath.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published
by the Free Software Foundation, either version 2 of the License, or
(at your option) any later verion.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */
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
{
// We need to put a reference to the Event Queue somewhere. This seems like
// a convenient place.
static EventQueue eventQueue = new EventQueue();
Component awtComponent;
gnu.gcj.RawData ptr; // Actual gtk object.
static
{
// This will start the main toolkit thread.
GtkToolkit.instance.init();
}
public int checkImage (Image image, int width, int height,
ImageObserver observer)
{
return -1;
/*
GtkImage i = (GtkImage) image;
return i.checkImage ();
*/
}
public Image createImage (ImageProducer producer)
{
return null;
//return new GtkImage (producer, null);
}
public Image createImage (int width, int height)
{
return null;
/*
GdkGraphics g = new GdkGraphics (width, height);
return new GtkOffScreenImage (null, g, width, height);
*/
}
public void disable ()
{
setEnabled (false);
}
native public void dispose ();
public void enable ()
{
setEnabled (true);
}
/**
* Get the graphics configuration of the component. The color model
* of the component can be derived from the configuration.
*/
public GraphicsConfiguration getGraphicsConfiguration ()
{
return null;
}
public FontMetrics getFontMetrics (Font font)
{
return null;
//return new GdkFontMetrics (font);
}
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)
{
/*
GtkImage i = (GtkImage) image;
if (i.isLoaded ()) return true;
class PrepareImage extends Thread
{
GtkImage image;
ImageObserver observer;
PrepareImage (GtkImage image, ImageObserver observer)
{
this.image = image;
this.observer = observer;
}
public void run ()
{
// XXX: need to return data to image observer
image.source.startProduction (null);
}
}
new PrepareImage (i, observer).start ();
*/
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();
// TODO: Each of these calls will currently perform a separate native lock.
// It may be desirable to use our own, recusive mutex implementation by
// passing our threads implementation to g_threads_init().
// This would greatly reduce locking calls in the peer code, and allow us
// to aquire the lock from java code.
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 ();
// FIXME: It may make sense to do the following directly from the native
// code.
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));
}
}

View File

@ -0,0 +1,55 @@
/* GtkContainerPeer.java -- Implements ContainerPeer with GTK
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the peer AWT libraries of GNU Classpath.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published
by the Free Software Foundation, either version 2 of the License, or
(at your option) any later verion.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */
package gnu.awt.gtk;
import java.awt.*;
import java.awt.event.*;
import java.awt.peer.ContainerPeer;
public abstract class GtkContainerPeer extends GtkComponentPeer
implements ContainerPeer
{
// FIXME?
static Insets insets = new Insets(0,0,0,0);
protected GtkContainerPeer (Container awtContainer)
{
super (awtContainer);
}
public Insets getInsets()
{
// FIXME?
return insets;
}
public void beginValidate()
{
// FIXME
}
public void endValidate()
{
// FIXME
}
protected native void create();
}

View File

@ -0,0 +1,42 @@
/* GtkFramePeer.java -- Implements FramePeer with GTK
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the peer AWT libraries of GNU Classpath.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published
by the Free Software Foundation, either version 2 of the License, or
(at your option) any later verion.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */
package gnu.awt.gtk;
import java.awt.*;
import java.awt.event.*;
import java.awt.peer.FramePeer;
public class GtkFramePeer extends GtkWindowPeer
implements FramePeer
{
protected GtkFramePeer (Frame awtFrame)
{
super (awtFrame);
//init ();
}
public native void setIconImage(Image image);
public native void setMenuBar(MenuBar mb);
public native void setResizable(boolean resizable);
public native void setTitle(String title);
protected native void create();
}

View File

@ -0,0 +1,36 @@
/* GtkMainThread.java -- Runs gtk_main()
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the peer AWT libraries of GNU Classpath.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published
by the Free Software Foundation, either version 2 of the License, or
(at your option) any later verion.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */
package gnu.awt.gtk;
public class GtkMainThread extends Thread
{
native void gtkMain();
public GtkMainThread()
{
super ("GtkMain");
}
public void run()
{
gtkMain();
}
}

View File

@ -0,0 +1,314 @@
/* GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the peer AWT libraries of GNU Classpath.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published
by the Free Software Foundation, either version 2 of the License, or
(at your option) any later verion.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */
package gnu.awt.gtk;
import java.awt.*;
import java.net.*;
import java.util.Hashtable;
import java.util.Properties;
import java.util.MissingResourceException;
import java.awt.datatransfer.*;
import java.awt.image.*;
import java.awt.peer.*;
public class GtkToolkit extends java.awt.Toolkit
{
static GtkMainThread gtkthread;
static EventQueue evtqueue;
static Hashtable containers = new Hashtable();
static Clipboard systemClipboard;
static GtkToolkit instance = null;
public GtkToolkit ()
{
gtkInit();
instance = this;
//systemClipboard = new GtkClipboard ();
}
// Start the thread to run the GTK event loop. This is called from
// a GtkComponentPeer static initializer.
void init ()
{
gtkthread = new GtkMainThread ();
gtkthread.start();
}
static native void gtkInit();
native public void beep ();
public int checkImage (Image image, int width, int height,
ImageObserver observer)
{
return ImageObserver.ALLBITS;
// GtkImage i = (GtkImage) image;
// return i.checkImage ();
}
public Image createImage(String filename)
{
return null;
}
public Image createImage(URL url)
{
return null;
}
public Image createImage (ImageProducer producer)
{
// return new GtkImage (producer, null);
return null;
}
public Image createImage (byte[] imagedata, int imageoffset,
int imagelength)
{
System.out.println ("createImage byte[] NOT SUPPORTED");
return null;
}
public ColorModel getColorModel ()
{
return ColorModel.getRGBdefault ();
}
public String[] getFontList ()
{
return (new String[] { "Dialog",
"DialogInput",
"Monospaced",
"Serif",
"SansSerif" });
}
public FontMetrics getFontMetrics (Font font)
{
// return new GdkFontMetrics (font);
return null;
}
public Image getImage (String filename)
{
// return new GtkImage (new GdkPixbufDecoder (filename), null);
return null;
}
public Image getImage (URL url)
{
// return new GtkImage (new GdkPixbufDecoder (url), null);
return null;
}
/*
public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props)
{
return null;
}
*/
native public int getScreenResolution();
native public Dimension getScreenSize ();
public Clipboard getSystemClipboard()
{
return systemClipboard;
}
public boolean prepareImage (Image image, int width, int height,
ImageObserver observer)
{
return false;
}
native public void sync ();
protected void setComponentState (Component c, GtkComponentPeer cp)
{
/* Make the Peer reflect the state of the Component */
if (! (c instanceof Window))
{
cp.setCursor (c.getCursor ());
Rectangle bounds = c.getBounds ();
cp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
if (c instanceof Canvas)
System.out.println ("width " + bounds.width + " height " + bounds.height);
cp.setVisible (c.isVisible ());
}
}
protected ButtonPeer createButton (Button b)
{
return null;
/*
GtkButtonPeer bp = new GtkButtonPeer (b);
Rectangle bounds = b.getBounds ();
bp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
return bp;
*/
}
protected CanvasPeer createCanvas (Canvas c)
{
// return new GtkCanvasPeer (c);
return null;
}
protected CheckboxPeer createCheckbox (Checkbox cb)
{
return null;
/*
if (cb.getCheckboxGroup () != null)
return new GtkRadioButtonPeer (cb);
else
return new GtkCheckButtonPeer (cb);
*/
}
protected CheckboxMenuItemPeer createCheckboxMenuItem (CheckboxMenuItem cmi)
{
return null;
//return new GtkCheckboxMenuItemPeer (cmi);
}
protected ChoicePeer createChoice (Choice c)
{
return null;
//return new GtkChoicePeer (c);
}
protected DialogPeer createDialog (Dialog d)
{
return null;
//return new GtkDialogPeer (d);
}
protected FileDialogPeer createFileDialog (FileDialog fd)
{
return null;
//return new GtkFileDialogPeer (fd);
}
protected FramePeer createFrame (Frame f)
{
return new GtkFramePeer (f);
}
protected LabelPeer createLabel (Label label)
{
return null;
//return new GtkLabelPeer (label);
}
protected ListPeer createList (List list)
{
return null;
//return new GtkListPeer (list);
}
protected MenuPeer createMenu (Menu m)
{
return null;
//return new GtkMenuPeer (m);
}
protected MenuBarPeer createMenuBar (MenuBar mb)
{
return null;
//return new GtkMenuBarPeer (mb);
}
protected MenuItemPeer createMenuItem (MenuItem mi)
{
return null;
//return new GtkMenuItemPeer (mi);
}
protected PanelPeer createPanel (Panel p)
{
return null;
//return new GtkPanelPeer (p);
}
protected PopupMenuPeer createPopupMenu (PopupMenu target)
{
return null;
//return new GtkPopupMenuPeer (target);
}
protected ScrollPanePeer createScrollPane (ScrollPane sp)
{
return null;
//return new GtkScrollPanePeer (sp);
}
protected ScrollbarPeer createScrollbar (Scrollbar sb)
{
return null;
//return new GtkScrollbarPeer (sb);
}
protected TextAreaPeer createTextArea (TextArea ta)
{
return null;
//return new GtkTextAreaPeer (ta);
}
protected TextFieldPeer createTextField (TextField tf)
{
return null;
//return new GtkTextFieldPeer (tf);
}
protected WindowPeer createWindow (Window w)
{
return new GtkWindowPeer (w);
}
protected FontPeer getFontPeer (String name, int style)
{
return null;
/*
try
{
GtkFontPeer fp = new GtkFontPeer (name, style);
return fp;
}
catch (MissingResourceException ex)
{
return null;
}
*/
}
protected EventQueue getSystemEventQueueImpl()
{
return GtkComponentPeer.eventQueue;
}
protected void loadSystemColors (int[] systemColors)
{
}
}

View File

@ -0,0 +1,39 @@
/* GtkWindowPeer.java -- Implements WindowPeer with GTK
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the peer AWT libraries of GNU Classpath.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published
by the Free Software Foundation, either version 2 of the License, or
(at your option) any later verion.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */
package gnu.awt.gtk;
import java.awt.*;
import java.awt.event.*;
import java.awt.peer.WindowPeer;
public class GtkWindowPeer extends GtkContainerPeer
implements WindowPeer
{
protected GtkWindowPeer (Window awtWindow)
{
super (awtWindow);
}
public native void toBack();
public native void toFront();
protected native void create();
}

View File

@ -0,0 +1,14 @@
// -*- c++ -*-
// gtkutils.cc - Common functions for the gtk AWT peers.
/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <gtk/gtk.h>
#include "gtkcommon.h"

View File

@ -0,0 +1,71 @@
// -*- c++ -*-
// gtkutils.h - Common defines and inline functions for the gtk AWT peers.
/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#ifndef __GTKCOMMON_H__
#define __GTKCOMMON_H__
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <java/awt/Color.h>
// Convert AWT Color to gdk color value.
static inline void
_Jv_ConvertAwtColor(java::awt::Color* awtcolor, GdkColor* gdkcolor)
{
jint rgb = awtcolor->getRGB();
gushort r = (rgb >> 16) & 0xFF;
gushort g = (rgb >> 8) & 0xFF;
gushort b = rgb & 0xFF;
gdkcolor->red = (r << 8) + r;
gdkcolor->green = (g << 8) + g;
gdkcolor->blue = (b << 8) + b;
// FIXME: Deal with colormap? gdk_color_alloc()?
}
// Convert gdk color value to AWT Color.
static inline java::awt::Color*
_Jv_ConvertGtkColor (GdkColor* gdkcolor)
{
jint r = gdkcolor->red >> 8;
jint g = gdkcolor->green >> 8;
jint b = gdkcolor->blue >> 8;
java::awt::Color *c = new java::awt::Color(r,g,b);
return c;
}
static inline void
_Jv_GdkScaleColor (GdkColor* oldc, GdkColor* newc, gfloat scale)
{
// FIXME: Need to deal with overflows or find a better way
*newc = *oldc;
newc->red += (gushort) (newc->red * scale);
newc->green += (gushort) (newc->green * scale);
newc->blue += (gushort) (newc->blue * scale);
}
// Normally the X queue gets flushed automatically when gtk's event loop goes
// idle. However, some calls do not cause any activitity on the event loop,
// so we need to occasionally flush pending requests manually because we arn't
// running from the gtk_main thread. Note that gdk_flush calls XSync(), which
// is more than what is needed here.
static inline void
_Jv_FlushRequests ()
{
// FIXME: What about platforms that arn't X?
XFlush (GDK_DISPLAY ());
}
#endif /* __GTKUTILS_H__ */

View File

@ -0,0 +1,205 @@
// This file was created by `gcjh -stubs'. -*- c++ -*-
//
// This file is intended to give you a head start on implementing native
// methods using CNI.
// Be aware: running `gcjh -stubs ' once more for this class may
// overwrite any edits you have made to this file.
#include <java/awt/Point.h>
#include <java/awt/Dimension.h>
#include <gnu/awt/gtk/GtkComponentPeer.h>
#include <gcj/cni.h>
#include <gtk/gtk.h>
#include "gtkcommon.h"
void
gnu::awt::gtk::GtkComponentPeer::dispose ()
{
GDK_THREADS_ENTER ();
gtk_widget_destroy (GTK_WIDGET (ptr));
GDK_THREADS_LEAVE ();
}
::java::awt::Point *
gnu::awt::gtk::GtkComponentPeer::getLocationOnScreen ()
{
GDK_THREADS_ENTER ();
GDK_THREADS_LEAVE ();
// FIXME
return NULL;
}
::java::awt::Dimension *
gnu::awt::gtk::GtkComponentPeer::getMinimumSize ()
{
GtkRequisition req;
::java::awt::Dimension *dim = new ::java::awt::Dimension ();
GDK_THREADS_ENTER ();
gtk_widget_size_request (GTK_WIDGET (ptr), &req);
GDK_THREADS_LEAVE ();
dim->width = (jint) req.width;
dim->height = (jint) req.height;
return dim;
}
::java::awt::Dimension *
gnu::awt::gtk::GtkComponentPeer::getPreferredSize ()
{
return getMinimumSize ();
}
void
gnu::awt::gtk::GtkComponentPeer::requestFocus ()
{
GDK_THREADS_ENTER ();
gtk_widget_grab_focus (GTK_WIDGET (ptr));
GDK_THREADS_LEAVE ();
}
void
gnu::awt::gtk::GtkComponentPeer::setBounds (jint x, jint y,
jint width, jint height)
{
GDK_THREADS_ENTER ();
GtkWidget *widget = GTK_WIDGET (ptr);
gtk_widget_set_usize (widget, width, height);
//gtk_layout_move (GTK_LAYOUT (widget->parent), widget, x, y);
GDK_THREADS_LEAVE ();
}
void
gnu::awt::gtk::GtkComponentPeer::setCursor (::java::awt::Cursor *)
{
// JvFail ("gnu::awt::gtk::GtkComponentPeer::setCursor (::java::awt::Cursor *) not implemented");
}
void
gnu::awt::gtk::GtkComponentPeer::setEnabled (jboolean enabled)
{
GDK_THREADS_ENTER ();
gtk_widget_set_sensitive (GTK_WIDGET (ptr), enabled);
GDK_THREADS_LEAVE ();
}
void
gnu::awt::gtk::GtkComponentPeer::setEventMask (jlong)
{
// TODO
}
void
gnu::awt::gtk::GtkComponentPeer::setFont (::java::awt::Font *)
{
// TODO
}
void
gnu::awt::gtk::GtkComponentPeer::setForeground (::java::awt::Color *color)
{
// FIXME: This doesn't work if component is already realized/visible
GdkColor gcolor;
_Jv_ConvertAwtColor(color, &gcolor);
GDK_THREADS_ENTER ();
GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (ptr));
style->bg[GTK_STATE_NORMAL] = gcolor;
style->bg[GTK_STATE_ACTIVE] = gcolor;
style->bg[GTK_STATE_PRELIGHT] = gcolor;
style->bg[GTK_STATE_SELECTED] = gcolor;
style->bg[GTK_STATE_INSENSITIVE] = gcolor;
gtk_widget_set_style (GTK_WIDGET (ptr), style);
GDK_THREADS_LEAVE ();
}
void
gnu::awt::gtk::GtkComponentPeer::setBackground (::java::awt::Color *color)
{
// FIXME: This doesn't work if component is already realized/visible
GdkColor gcolor;
_Jv_ConvertAwtColor(color, &gcolor);
GDK_THREADS_ENTER ();
GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (ptr));
style->bg[GTK_STATE_NORMAL] = gcolor;
style->bg[GTK_STATE_ACTIVE] = gcolor;
style->bg[GTK_STATE_PRELIGHT] = gcolor;
style->bg[GTK_STATE_SELECTED] = gcolor;
style->bg[GTK_STATE_INSENSITIVE] = gcolor;
// gtk allows us to set color values for different states of the
// widget. AWT only provides a single background color, so scale it
// to get some reasonable values.
// _Jv_GdkScaleColor (&gcolor, &style->bg[GTK_STATE_ACTIVE], -0.1);
// _Jv_GdkScaleColor (&gcolor, &style->bg[GTK_STATE_PRELIGHT], 0.2);
// _Jv_GdkScaleColor (&gcolor, &style->bg[GTK_STATE_SELECTED], -0.2);
// _Jv_GdkScaleColor (&gcolor, &style->bg[GTK_STATE_INSENSITIVE], -0.2);
gtk_widget_set_style (GTK_WIDGET (ptr), style);
GDK_THREADS_LEAVE ();
}
void
gnu::awt::gtk::GtkComponentPeer::setVisible (jboolean visible)
{
GDK_THREADS_ENTER ();
GtkWidget *widget = GTK_WIDGET (ptr);
if (visible)
gtk_widget_show (widget);
else
gtk_widget_hide (widget);
_Jv_FlushRequests ();
GDK_THREADS_LEAVE ();
}
void
gnu::awt::gtk::GtkComponentPeer::create ()
{
}
void
gnu::awt::gtk::GtkComponentPeer::realize ()
{
GDK_THREADS_ENTER ();
gtk_widget_realize (GTK_WIDGET (ptr));
GDK_THREADS_LEAVE ();
}

View File

@ -0,0 +1,15 @@
// This file was created by `gcjh -stubs'. -*- c++ -*-
//
// This file is intended to give you a head start on implementing native
// methods using CNI.
// Be aware: running `gcjh -stubs ' once more for this class may
// overwrite any edits you have made to this file.
#include <gnu/awt/gtk/GtkContainerPeer.h>
#include <gcj/cni.h>
void
gnu::awt::gtk::GtkContainerPeer::create ()
{
gnu::awt::gtk::GtkComponentPeer::create();
}

View File

@ -0,0 +1,51 @@
// This file was created by `gcjh -stubs'. -*- c++ -*-
//
// This file is intended to give you a head start on implementing native
// methods using CNI.
// Be aware: running `gcjh -stubs ' once more for this class may
// overwrite any edits you have made to this file.
#include <gnu/awt/gtk/GtkFramePeer.h>
#include <gcj/cni.h>
#include <gtk/gtk.h>
void
gnu::awt::gtk::GtkFramePeer::setIconImage (::java::awt::Image *)
{
// TODO
}
void
gnu::awt::gtk::GtkFramePeer::setMenuBar (::java::awt::MenuBar *)
{
// TODO
}
void
gnu::awt::gtk::GtkFramePeer::setResizable (jboolean)
{
// TODO
}
void
gnu::awt::gtk::GtkFramePeer::setTitle (::java::lang::String *)
{
// TODO
}
void
gnu::awt::gtk::GtkFramePeer::create ()
{
if (ptr == NULL)
{
GDK_THREADS_ENTER ();
ptr = (gnu::gcj::RawData *) gtk_window_new(GTK_WINDOW_TOPLEVEL);
GDK_THREADS_LEAVE ();
}
gnu::awt::gtk::GtkContainerPeer::create();
}

View File

@ -0,0 +1,22 @@
// This file was created by `gcjh -stubs'. -*- c++ -*-
//
// This file is intended to give you a head start on implementing native
// methods using CNI.
// Be aware: running `gcjh -stubs ' once more for this class may
// overwrite any edits you have made to this file.
#include <gnu/awt/gtk/GtkMainThread.h>
#include <gcj/cni.h>
#include <gtk/gtk.h>
void
gnu::awt::gtk::GtkMainThread::gtkMain ()
{
GDK_THREADS_ENTER ();
gtk_main ();
GDK_THREADS_LEAVE ();
}

View File

@ -0,0 +1,75 @@
// This file was created by `gcjh -stubs'. -*- c++ -*-
//
// This file is intended to give you a head start on implementing native
// methods using CNI.
// Be aware: running `gcjh -stubs ' once more for this class may
// overwrite any edits you have made to this file.
#include <java/awt/Dimension.h>
#include <gnu/awt/gtk/GtkToolkit.h>
#include <gcj/cni.h>
#include <gtk/gtk.h>
// GTK requires the program's argc and argv variables.
extern char **_Jv_argv;
extern int _Jv_argc;
// Call gtk_init. It is very important that this happen before any other
// gtk calls.
void
gnu::awt::gtk::GtkToolkit::gtkInit ()
{
// Initialize GLib in thread-safe mode. We assume that GLib is using the
// same native threads library as libgcj. Refer to comments in
// GtkComponentPeer constructor.
g_thread_init (NULL);
gtk_init (&_Jv_argc, &_Jv_argv);
}
void
gnu::awt::gtk::GtkToolkit::beep ()
{
GDK_THREADS_ENTER ();
gdk_beep ();
GDK_THREADS_LEAVE ();
}
jint
gnu::awt::gtk::GtkToolkit::getScreenResolution ()
{
jint res;
GDK_THREADS_ENTER ();
res = (int) (gdk_screen_width () / (gdk_screen_width_mm () / 25.4));
GDK_THREADS_LEAVE ();
return res;
}
::java::awt::Dimension *
gnu::awt::gtk::GtkToolkit::getScreenSize ()
{
::java::awt::Dimension *dim = new ::java::awt::Dimension ();
GDK_THREADS_ENTER ();
dim->width = gdk_screen_width ();
dim->height = gdk_screen_height ();
GDK_THREADS_LEAVE ();
return dim;
}
void
gnu::awt::gtk::GtkToolkit::sync ()
{
GDK_THREADS_ENTER ();
gdk_flush ();
GDK_THREADS_LEAVE ();
}

View File

@ -0,0 +1,40 @@
// This file was created by `gcjh -stubs'. -*- c++ -*-
//
// This file is intended to give you a head start on implementing native
// methods using CNI.
// Be aware: running `gcjh -stubs ' once more for this class may
// overwrite any edits you have made to this file.
#include <gnu/awt/gtk/GtkWindowPeer.h>
#include <gcj/cni.h>
#include <gtk/gtk.h>
void
gnu::awt::gtk::GtkWindowPeer::toBack ()
{
GDK_THREADS_ENTER ();
gdk_window_lower (GTK_WIDGET (ptr)->window);
GDK_THREADS_LEAVE ();
}
void
gnu::awt::gtk::GtkWindowPeer::toFront ()
{
GDK_THREADS_ENTER ();
gdk_window_raise (GTK_WIDGET (ptr)->window);
GDK_THREADS_LEAVE ();
}
void
gnu::awt::gtk::GtkWindowPeer::create ()
{
if (ptr == NULL)
{
GDK_THREADS_ENTER ();
ptr = (gnu::gcj::RawData *) gtk_window_new(GTK_WINDOW_POPUP);
GDK_THREADS_LEAVE ();
}
gnu::awt::gtk::GtkContainerPeer::create();
}

View File

@ -220,6 +220,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
public void setEnabled(boolean b)
{
this.enabled = b;
if (peer != null)
peer.setEnabled(b);
}
/** @deprecated */
@ -299,8 +301,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (peer != null)
peer.setForeground(c);
this.foreground = c;
if (peer != null)
peer.setForeground(foreground);
}
/** @return the background color of the component. null may be
@ -321,7 +321,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (peer != null)
peer.setBackground(c);
this.background = c;
if (peer != null) peer.setBackground(background);
}
public Font getFont()
@ -1412,7 +1411,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
etc. */
}
void addNotifyContainerChildren() {
void addNotifyContainerChildren()
{
// nothing to do unless we're a container
}

View File

@ -24,7 +24,7 @@ import java.awt.image.ImageProducer;
public abstract class Image extends Object
{
public static final Object UndefinedProperty;
public static final Object UndefinedProperty = new Object();
public static final int SCALE_DEFAULT = 1<<0,
SCALE_FAST = 1<<1,

View File

@ -21,7 +21,6 @@ import gnu.gcj.awt.GLightweightPeer;
public abstract class Toolkit
{
static Toolkit defaultToolkit;
static EventQueue systemEventQueue = new EventQueue();
PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
Hashtable desktopProperties = new Hashtable();
@ -33,7 +32,7 @@ public abstract class Toolkit
Class toolkit_class;
String tk_class_name = System.getProperty("awt.toolkit");
if (tk_class_name == null)
tk_class_name = "gnu.awt.peer.gtk.GTKToolkit";
tk_class_name = "gnu.awt.gtk.GtkToolkit";
try
{

View File

@ -186,10 +186,11 @@ public class Window extends Container
}
}
/** @specnote Unlike Component.getToolkit, this implementation always
returns the value of Toolkit.getDefaultToolkit(). */
public Toolkit getToolkit()
{
// FIXME: why different from Component.getToolkit() ?
return super.getToolkit();
return Toolkit.getDefaultToolkit ();
}
public final String getWarningString()

View File

@ -62,7 +62,7 @@ public class BufferedImage extends java.awt.Image
public BufferedImage(int w, int h, int type)
{
ColorModel cm;
ColorModel cm = null;
boolean alpha = false;
boolean premultiplied = false;
@ -85,7 +85,7 @@ public class BufferedImage extends java.awt.Image
case TYPE_INT_ARGB_PRE:
case TYPE_USHORT_565_RGB:
case TYPE_USHORT_555_RGB:
int[] masks;
int[] masks = null;
switch (type)
{
case TYPE_INT_RGB:

View File

@ -12,7 +12,6 @@ import java.awt.Insets;
public interface ContainerPeer extends ComponentPeer
{
Insets insets();
Insets getInsets();
void beginValidate();
void endValidate();

View File

@ -91,6 +91,10 @@ property_pair *_Jv_Environment_Properties;
// The name of this executable.
static char * _Jv_execName;
// Stash the argv pointer to benefit native libraries that need it.
const char **_Jv_argv;
int _Jv_argc;
#ifdef ENABLE_JVMPI
// Pointer to JVMPI notification functions.
void (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (JVMPI_Event *event);
@ -865,6 +869,9 @@ JvRunMain (jclass klass, int argc, const char **argv)
{
PROCESS_GCJ_PROPERTIES;
_Jv_argv = argv;
_Jv_argc = argc;
main_init ();
#ifdef HAVE_PROC_SELF_EXE
char exec_name[20];