Commit aa66a642 by Thomas Fitzsimmons Committed by Thomas Fitzsimmons

GtkButtonPeer.java, [...]: Remove files.

2003-12-01  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/awt/gtk/GtkButtonPeer.java, gnu/awt/gtk/gtkcommon.cc,
	gnu/awt/gtk/gtkcommon.h, gnu/awt/gtk/GtkComponentPeer.java,
	gnu/awt/gtk/GtkContainerPeer.java,
	gnu/awt/gtk/GtkFramePeer.java, gnu/awt/gtk/GtkLabelPeer.java,
	gnu/awt/gtk/GtkMainThread.java, gnu/awt/gtk/GtkToolkit.java,
	gnu/awt/gtk/GtkWindowPeer.java, gnu/awt/gtk/natGtkButtonPeer.cc,
	gnu/awt/gtk/natGtkComponentPeer.cc,
	gnu/awt/gtk/natGtkContainerPeer.cc,
	gnu/awt/gtk/natGtkFramePeer.cc, gnu/awt/gtk/natGtkLabelPeer.cc,
	gnu/awt/gtk/natGtkMainThread.cc, gnu/awt/gtk/natGtkToolkit.cc,
	gnu/awt/gtk/natGtkWindowPeer.cc: Remove files.

From-SVN: r74118
parent dc170a87
2003-12-01 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/awt/gtk/GtkButtonPeer.java, gnu/awt/gtk/gtkcommon.cc,
gnu/awt/gtk/gtkcommon.h, gnu/awt/gtk/GtkComponentPeer.java,
gnu/awt/gtk/GtkContainerPeer.java,
gnu/awt/gtk/GtkFramePeer.java, gnu/awt/gtk/GtkLabelPeer.java,
gnu/awt/gtk/GtkMainThread.java, gnu/awt/gtk/GtkToolkit.java,
gnu/awt/gtk/GtkWindowPeer.java, gnu/awt/gtk/natGtkButtonPeer.cc,
gnu/awt/gtk/natGtkComponentPeer.cc,
gnu/awt/gtk/natGtkContainerPeer.cc,
gnu/awt/gtk/natGtkFramePeer.cc, gnu/awt/gtk/natGtkLabelPeer.cc,
gnu/awt/gtk/natGtkMainThread.cc, gnu/awt/gtk/natGtkToolkit.cc,
gnu/awt/gtk/natGtkWindowPeer.cc: Remove files.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
(closed): Mark loader parameter as unused.
......
/* GtkButtonPeer.java -- Implements ButtonPeer 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 version.
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.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.peer.*;
public class GtkButtonPeer extends GtkComponentPeer
implements ButtonPeer
{
protected native void create ();
public native void setLabel (String label);
public GtkButtonPeer (Button b)
{
super (b);
}
public void handleEvent (AWTEvent e)
{
// if (e.getID () == MouseEvent.MOUSE_CLICKED && isEnabled ()
// && !modalHasGrab ())
// {
// MouseEvent me = (MouseEvent) e;
// if (!me.isConsumed ()
// && (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0)
// postActionEvent (((Button)awtComponent).getActionCommand (),
// me.getModifiers ());
// }
// if (e.getID () == KeyEvent.KEY_PRESSED)
// {
// KeyEvent ke = (KeyEvent) e;
// if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_SPACE)
// postActionEvent (((Button)awtComponent).getActionCommand (),
// ke.getModifiers ());
// }
super.handleEvent (e);
}
}
/* 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 version.
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));
}
}
/* 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 version.
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();
}
/* 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 version.
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();
}
/* GtkLabelPeer.java -- Implements LabelPeer 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 version.
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.peer.*;
public class GtkLabelPeer extends GtkComponentPeer
implements LabelPeer
{
public GtkLabelPeer (Label l)
{
super (l);
}
public native void setText (String text);
public native void setAlignment (int alignment);
protected native void create ();
}
/* 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 version.
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();
}
}
/* 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 version.
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)
{
}
}
/* 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 version.
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();
}
// -*- 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"
// -*- 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>
class _Jv_GdkThreadLock
{
public:
_Jv_GdkThreadLock ()
{
GDK_THREADS_ENTER ();
}
~_Jv_GdkThreadLock ()
{
GDK_THREADS_LEAVE ();
}
};
// 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__ */
// Native Gtk AWT button code
#include <config.h>
#include <gcj/cni.h>
#include "gtkcommon.h"
#include <gnu/awt/gtk/GtkButtonPeer.h>
#include <java/awt/Button.h>
void
gnu::awt::gtk::GtkButtonPeer::setLabel (java::lang::String *label)
{
_Jv_GdkThreadLock sync;
jsize len = 0;
if (label)
len = JvGetStringUTFLength (label);
char buf[len + 1];
// FIXME: this can allocate an unbounded amount. Should use heap
// even though it is slower.
if (label)
JvGetStringUTFRegion (label, 0, label->length(), buf);
buf[len] = '\0';
// The button child is a label.
GtkBin *bin = GTK_BIN (ptr);
gtk_label_set_text (GTK_LABEL (bin->child), buf);
}
void
gnu::awt::gtk::GtkButtonPeer::create ()
{
if (! ptr)
{
_Jv_GdkThreadLock sync;
// This is a little inefficient.
ptr = (gnu::gcj::RawData *) gtk_button_new_with_label ("");
using namespace ::java::awt;
Button *button = reinterpret_cast<Button *> (awtComponent);
setLabel (button->getLabel ());
}
gnu::awt::gtk::GtkComponentPeer::create ();
}
// void
// gnu::awt::gtk::GtkButtonPeer::clicked (::gnu::gcj::RawData *button_wrap,
// ::gnu::gcj::RawData *peer_wrap)
// {
// GtkButtonPeer *button = reinterpret_cast<GtkButtonPeer *> (peer_wrap);
// }
// 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 <config.h>
#include <gcj/cni.h>
#include <java/awt/Point.h>
#include <java/awt/Dimension.h>
#include <java/awt/Cursor.h>
#include "gtkcommon.h"
#include <gnu/awt/gtk/GtkComponentPeer.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 ()
{
gint x, y;
_Jv_GdkThreadLock sync;
gdk_window_get_root_origin (GTK_WIDGET (ptr)->window, &x, &y);
return new ::java::awt::Point (x, y);
}
::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 *cursor)
{
GdkCursorType type;
switch (cursor->type)
{
case ::java::awt::Cursor::CROSSHAIR_CURSOR:
type = GDK_CROSSHAIR;
break;
case ::java::awt::Cursor::TEXT_CURSOR:
type = GDK_XTERM;
break;
case ::java::awt::Cursor::WAIT_CURSOR:
type = GDK_WATCH;
break;
case ::java::awt::Cursor::SW_RESIZE_CURSOR:
type = GDK_BOTTOM_LEFT_CORNER;
break;
case ::java::awt::Cursor::SE_RESIZE_CURSOR:
type = GDK_BOTTOM_RIGHT_CORNER;
break;
case ::java::awt::Cursor::NW_RESIZE_CURSOR:
type = GDK_TOP_LEFT_CORNER;
break;
case ::java::awt::Cursor::NE_RESIZE_CURSOR:
type = GDK_TOP_RIGHT_CORNER;
break;
case ::java::awt::Cursor::N_RESIZE_CURSOR:
type = GDK_TOP_SIDE;
break;
case ::java::awt::Cursor::S_RESIZE_CURSOR:
type = GDK_RIGHT_SIDE;
break;
case ::java::awt::Cursor::W_RESIZE_CURSOR:
type = GDK_LEFT_SIDE;
break;
case ::java::awt::Cursor::E_RESIZE_CURSOR:
type = GDK_BOTTOM_SIDE;
break;
case ::java::awt::Cursor::HAND_CURSOR:
type = GDK_HAND1;
break;
case ::java::awt::Cursor::MOVE_CURSOR:
type = GDK_FLEUR;
break;
case ::java::awt::Cursor::CUSTOM_CURSOR:
// FIXME: not implemented yet. We want a gtk-specific subclass
// of Cursor which holds a new gdk cursor. For now, fall
// through.
case ::java::awt::Cursor::DEFAULT_CURSOR:
default:
type = GDK_LEFT_PTR;
break;
}
_Jv_GdkThreadLock sync;
GtkWidget *widget = GTK_WIDGET (ptr);
GdkCursor *cursor = gdk_cursor_new (type);
gdk_window_set_cursor (widget->window, cursor);
gdk_cursor_destroy (cursor);
}
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 ();
}
// 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();
}
// 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();
}
// Native Gtk AWT label code.
#include <config.h>
#include <gcj/cni.h>
#include "gtkcommon.h"
#include <gnu/awt/gtk/GtkLabelPeer.h>
#include <java/awt/Label.h>
void
gnu::awt::gtk::GtkLabelPeer::setText (java::lang::String *text)
{
_Jv_GdkThreadLock sync;
jsize len = 0;
if (text)
len = JvGetStringUTFLength (text);
// FIXME: this can allocate an unbounded amount. Should use heap
// even though it is slower.
char buf[len + 1];
if (text)
JvGetStringUTFRegion (text, 0, text->length(), buf);
buf[len] = '\0';
gtk_label_set_text (GTK_LABEL (ptr), buf);
}
void
gnu::awt::gtk::GtkLabelPeer::setAlignment (jint alignment)
{
using namespace java::awt;
gfloat value = 0.5;
if (alignment == Label::LEFT)
value = 0.0;
else if (alignment == Label::RIGHT)
value = 1.0;
_Jv_GdkThreadLock sync;
gtk_misc_set_alignment (GTK_MISC (ptr), 0.5f, value);
}
void
gnu::awt::gtk::GtkLabelPeer::create ()
{
if (! ptr)
{
_Jv_GdkThreadLock sync;
// This is a little inefficient.
ptr = (gnu::gcj::RawData *) gtk_label_new ("");
using namespace ::java::awt;
Label *label = reinterpret_cast<Label *> (awtComponent);
setText (label->getText ());
setAlignment (label->getAlignment ());
}
gnu::awt::gtk::GtkComponentPeer::create ();
}
// 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 ();
}
// 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 ();
}
// 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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment