diff options
| author | James E. Blair <corvus@gnu.org> | 1998-11-25 06:17:12 +0000 |
|---|---|---|
| committer | James E. Blair <corvus@gnu.org> | 1998-11-25 06:17:12 +0000 |
| commit | bc3b75041352b408da507680813351203aa6b29a (patch) | |
| tree | 9258b217d784de92928e08cd9d2aa3691476559d /gnu/java | |
| parent | 7c31cc845a8aa0bc3d01900885caecf3423214c0 (diff) | |
| download | classpath-bc3b75041352b408da507680813351203aa6b29a.tar.gz | |
Initial commit of GTK peers.
Diffstat (limited to 'gnu/java')
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkButtonPeer.java | 47 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkComponentPeer.java | 224 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkContainerPeer.java | 62 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkDialogPeer.java | 54 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkFileDialogPeer.java | 56 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkFramePeer.java | 59 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkGenericPeer.java | 30 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkMainThread.java | 63 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkPanelPeer.java | 39 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkScrollPanePeer.java | 111 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkToolkit.java | 243 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/GtkWindowPeer.java | 67 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/Makefile | 43 | ||||
| -rw-r--r-- | gnu/java/awt/peer/gtk/Test.java | 77 |
14 files changed, 1175 insertions, 0 deletions
diff --git a/gnu/java/awt/peer/gtk/GtkButtonPeer.java b/gnu/java/awt/peer/gtk/GtkButtonPeer.java new file mode 100644 index 000000000..92164f3ab --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkButtonPeer.java @@ -0,0 +1,47 @@ +/* + * GtkButtonPeer.java -- Implements ButtonPeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.*; +import java.awt.peer.*; + +public class GtkButtonPeer extends GtkComponentPeer + implements ButtonPeer +{ + + native void GtkButtonNewWithLabel (String label); + native void GtkButtonLabelSet (String label); + + public GtkButtonPeer (Button b, ComponentPeer cp) + { + GtkButtonNewWithLabel (b.getLabel()); + Point p=b.getLocation(); + System.out.println("buttonpeer: location: "+p.x+","+p.y); + + GtkFixedPut (cp,p.x,p.y); + } + + public void setLabel (String label) + { + System.out.println("java setlabel"); + GtkButtonLabelSet(label); + } +} diff --git a/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java new file mode 100644 index 000000000..28facf8a7 --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkComponentPeer.java @@ -0,0 +1,224 @@ +/* + * GtkComponentPeer.java -- Implements ComponentPeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.*; +import java.awt.image.*; +import java.awt.peer.ComponentPeer; + +public class GtkComponentPeer extends GtkGenericPeer + implements ComponentPeer +{ + native void GtkWidgetShow(); + native void GtkWidgetShowChildren(); + native void GtkWidgetGetDimensions(int[] dim); + native void GtkWidgetSetUsize(int width, int height); + + native void GtkFixedNew (int w, int h); + native void GtkFixedPut (Object parent, int x, int y); + native void GtkFixedMove(int x, int y); + + public int checkImage (Image image, int width, int height, + ImageObserver observer) + { + return 0; + } + + public Image createImage (ImageProducer producer) + { + return null; + } + + public Image createImage (int width, int height) + { + return null; + } + + public void disable () + { + System.out.println("componentpeer: disable"); + } + + public void dispose () + { + System.out.println("componentpeer: dispose"); + } + + public void enable () + { + System.out.println("componentpeer: enable"); + } + + public ColorModel getColorModel () + { + System.out.println("componentpeer: getcolormodel"); + return null; + } + + public FontMetrics getFontMetrics (Font f) + { + System.out.println("componentpeer: getfontmetrics"); + return null; + } + + public Graphics getGraphics () + { + System.out.println("componentpeer: getgraphics"); + return null; + } + + public Point getLocationOnScreen () + { + System.out.println("componentpeer: getlocationonscreen"); + return null; + } + + public Dimension getMinimumSize () + { + int dim[]=new int[2]; + GtkWidgetGetDimensions (dim); + System.out.println ("componentpeer: min: " + dim[0] + ", " + dim[1]); + Dimension d = new Dimension (dim[0],dim[1]); + return (d); + } + + public Dimension getPreferredSize () + { + int dim[]=new int[2]; + GtkWidgetGetDimensions (dim); + Dimension d = new Dimension (dim[0],dim[1]); + + System.out.println ("Cpeer.pref: " +this+":"+ dim[0] + ", " + dim[1]); + return (d); + } + + public Toolkit getToolkit () + { + return Toolkit.getDefaultToolkit(); + } + + public boolean handleEvent (Event e) + { + System.out.println("componentpeer: handleevent"); + return false; + } + + public void handleEvent (AWTEvent e) + { + System.out.println("componentpeer: handleawtevent"); + } + + public void hide () + { + System.out.println("componentpeer: hide"); + } + + public boolean isFocusTraversable () + { + return false; + } + + public Dimension minimumSize () + { + System.out.println("componentpeer: minimumsize"); + return getMinimumSize(); + } + + public void paint(Graphics g) + { + System.out.println("componentpeer: paint"); + GtkWidgetShow(); + } + + public Dimension preferredSize() + { + System.out.println("Cpeer.preferredsize"); + return getPreferredSize(); + } + + public boolean prepareImage (Image image, int width, int height, + ImageObserver observer) + { + return false; + } + + public void print (Graphics g) + { + } + + public void repaint (long tm, int x, int y, int width, int height) + { + System.out.println("componentpeer: repaint"); + } + + public void requestFocus () + { + } + + public void reshape (int x, int y, int width, int height) + { + System.out.println("componentpeer: reshape"); + } + + public void setBackground (Color c) + { + } + + public void setBounds (int x, int y, int width, int height) + { + System.out.println("Cpeer.setbounds: "+this+": "+x+","+y+","+width+","+height); + GtkWidgetSetUsize(width,height); + GtkFixedMove(x,y); + } + + public void setCursor (Cursor cursor) + { + } + + public void setEnabled (boolean b) + { + System.out.println("componentpeer: setenabled"); + } + + public void setFont (Font f) + { + } + + public void setForeground (Color c) + { + } + + public void setVisible (boolean b) + { + if(b) + { + System.out.println("componentpeer: setting visible: "+ this); + GtkWidgetShow(); + } + } + + public void show () + { + setVisible(true); + } +} + + diff --git a/gnu/java/awt/peer/gtk/GtkContainerPeer.java b/gnu/java/awt/peer/gtk/GtkContainerPeer.java new file mode 100644 index 000000000..ebf150b49 --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkContainerPeer.java @@ -0,0 +1,62 @@ +/* + * GtkContainerPeer.java -- Implements ContainerPeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.Insets; +import java.awt.peer.ContainerPeer; + +public class GtkContainerPeer extends GtkComponentPeer + implements ContainerPeer +{ + Insets myInsets; + + public GtkContainerPeer() + { + myInsets=new Insets(0,0,0,0); + } + + public void beginValidate() + { + System.out.println("container beginvalidate"); + /* We should probably put some code here to "freeze" + the native container widget. Until that happens, we + may see the layout manager moving widgets. */ + } + + public void endValidate() + { + System.out.println("container endvalidate"); + /* The way I am interpreting this is that now that the Container + has validated its peers, we should cause the container widget + to unfreeze and draw the container's children. -JB */ + GtkWidgetShowChildren(); + } + + public Insets getInsets() + { + return myInsets; + } + + public Insets insets() + { + return getInsets(); + } +} diff --git a/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/gnu/java/awt/peer/gtk/GtkDialogPeer.java new file mode 100644 index 000000000..6a3dc2ffc --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkDialogPeer.java @@ -0,0 +1,54 @@ +/* + * GtkDialogPeer.java -- Implements DialogPeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.*; +import java.awt.peer.*; + +public class GtkDialogPeer extends GtkWindowPeer + implements DialogPeer +{ + public GtkDialogPeer(Dialog d) + { + super(dialogType,d); + System.out.println("DialogPeer contructor"); + } + + public GtkDialogPeer(int type, Dialog d) + { + super(type,d); + System.out.println("DialogPeer int contstructor"); + } + + public void setTitle(String title) + { + System.out.println("setting title"); + GtkWindowSetTitle(title); + } + + public void setResizable(boolean resizable) + { + int r=resizable?1:0; + + GtkWindowSetPolicy(r,r,0); //shrink,grow,auto + } +} + diff --git a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java new file mode 100644 index 000000000..277df0550 --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java @@ -0,0 +1,56 @@ +/* + * GtkFileDialogPeer.java -- Implements FileDialogPeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.io.FilenameFilter; +import java.awt.peer.*; +import java.awt.*; + +public class GtkFileDialogPeer extends GtkDialogPeer + implements FileDialogPeer +{ + + native void GtkFileSelectionNew(); + native void GtkFileSelectionSetFilename(String file); + + public GtkFileDialogPeer(FileDialog fd) + { + super (bogusType, fd); + System.out.println("FileDialogPeer contructor"); + GtkFileSelectionNew(); + } + + public void setDirectory(String directory) + { + GtkFileSelectionSetFilename(directory); + } + + public void setFile(String file) + { + GtkFileSelectionSetFilename(file); + } + + public void setFilenameFilter(FilenameFilter filter) + { + /* GTK has no filters. */ + } +} + diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java new file mode 100644 index 000000000..98e1b1275 --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java @@ -0,0 +1,59 @@ +/* + * GtkFramePeer.java -- Implements FramePeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.*; +import java.awt.peer.FramePeer; + +public class GtkFramePeer extends GtkWindowPeer + implements FramePeer +{ + public GtkFramePeer(Frame f) + { + super(toplevelType,f); + Dimension d=f.getSize(); + System.out.println("FramePeer contructor: "+d.width+" x "+d.height); + } + + public void setIconImage (Image image) + { + /* TODO: Waiting on Toolkit Image routines */ + } + + public void setMenuBar (MenuBar bar) + { + /* TODO: Waiting on MenuComponentPeer */ + } + + public void setTitle(String title) + { + GtkWindowSetTitle(title); + } + + public void setResizable(boolean resizable) + { + int r=resizable?1:0; + + GtkWindowSetPolicy(r,r,0); //shrink,grow,auto + } +} + + diff --git a/gnu/java/awt/peer/gtk/GtkGenericPeer.java b/gnu/java/awt/peer/gtk/GtkGenericPeer.java new file mode 100644 index 000000000..885c41caa --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkGenericPeer.java @@ -0,0 +1,30 @@ +/* + * GtkGenericPeer.java - Has a hashcode. Yuck. + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; + +/* This class will go away with Japhar integration. For use with Sun's JDK + this may be required, unless another method of associating Java objects + with GTK objects is used. */ + +public class GtkGenericPeer +{ + final int native_state=java.lang.System.identityHashCode(this); +} diff --git a/gnu/java/awt/peer/gtk/GtkMainThread.java b/gnu/java/awt/peer/gtk/GtkMainThread.java new file mode 100644 index 000000000..b06540511 --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkMainThread.java @@ -0,0 +1,63 @@ +/* + * GtkMainThread.java -- Runs gtk_main() + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; + +public class GtkMainThread extends GtkGenericPeer + implements Runnable +{ + private static Thread mainThread = null; + + native static void GtkInitTable(); + static native void GtkInit(); + native void GtkMain(); + + public GtkMainThread() + { + start(); + } + + public void start() + { + if (mainThread == null) + { + mainThread = new Thread(this, "GtkMain"); + synchronized (this) { + mainThread.start(); + try { + wait(); + } catch (InterruptedException e) { } + } + } + } + + public void run() + { + synchronized (this) { + GtkInitTable(); + GtkInit(); + notify(); + } + GtkMain(); + } +} + + + diff --git a/gnu/java/awt/peer/gtk/GtkPanelPeer.java b/gnu/java/awt/peer/gtk/GtkPanelPeer.java new file mode 100644 index 000000000..462d7fb7d --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkPanelPeer.java @@ -0,0 +1,39 @@ +/* + * GtkPanelPeer.java -- Implements PanelPeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.peer.*; +import java.awt.*; + +public class GtkPanelPeer extends GtkContainerPeer + implements PanelPeer +{ + + public GtkPanelPeer(Panel p, ComponentPeer parent) + { + System.out.println("new panelpeer: parent: "+ parent); + + Dimension d=p.getSize(); + Point pnt=p.getLocation(); + + GtkFixedNew(d.width, d.height); + GtkFixedPut (parent, pnt.x, pnt.y); + } +} diff --git a/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java b/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java new file mode 100644 index 000000000..25f777828 --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java @@ -0,0 +1,111 @@ +/* + * GtkScrollPanePeer.java -- Implements ScrollPanePeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.peer.*; +import java.awt.*; + +public class GtkScrollPanePeer extends GtkContainerPeer + implements ScrollPanePeer +{ + int policy; + int sbHeight, sbWidth; + ScrollPane myScrollPane; + + native void GtkScrolledWindowNew(int policy, int w, int h, int[] dims); + native void GtkScrolledWindowSetScrollPosition(int x, int y); + native void GtkScrolledWindowSetHScrollIncrement (int u); + native void GtkScrolledWindowSetVScrollIncrement (int u); + native void GtkScrolledWindowSetSize(int w, int h); + + public GtkScrollPanePeer(ScrollPane p, ComponentPeer parent) + { + System.out.println("new scrollpanepeer"); + + myScrollPane=p; + policy=p.getScrollbarDisplayPolicy(); + + int mypolicy=1; + switch (policy) + { + case ScrollPane.SCROLLBARS_ALWAYS: mypolicy=1; break; + case ScrollPane.SCROLLBARS_AS_NEEDED: mypolicy=2; break; + case ScrollPane.SCROLLBARS_NEVER: mypolicy=3; break; + } + + Point pnt=p.getLocation(); + Dimension pdim=p.getSize(); + + System.out.println(":" + pdim.width + " " + pdim.height); + + int dims[]=new int[2]; + + GtkScrolledWindowNew(mypolicy, pdim.width, pdim.height, dims); + + sbWidth=dims[0]; + sbHeight=dims[1]; + + GtkFixedPut (parent, pnt.x, pnt.y); + } + + public void childResized (int w, int h) + { + System.out.println("SPP: child resized to: "+ w + " x " + h); + + GtkScrolledWindowSetSize(w, h); + } + + public int getHScrollbarHeight () + { + return sbHeight; + } + + public int getVScrollbarWidth () + { + return sbWidth; + } + + public void setScrollPosition (int x, int y) + { + GtkScrolledWindowSetScrollPosition(x, y); + } + + public void setUnitIncrement (Adjustable adj, int u) + { + /* Er... What calls this? */ + + System.out.println("SPP: setUI: "+adj+":"+u); + if (adj.getOrientation()==Adjustable.HORIZONTAL) + GtkScrolledWindowSetHScrollIncrement (u); + else + GtkScrolledWindowSetVScrollIncrement (u); + } + + public void setValue (Adjustable adj, int v) + { + System.out.println("SPP: setVal: "+adj+":"+v); + Point p=myScrollPane.getScrollPosition (); + if (adj.getOrientation()==Adjustable.HORIZONTAL) + GtkScrolledWindowSetScrollPosition (v,p.y); + else + GtkScrolledWindowSetScrollPosition (p.x,v); + adj.setValue(v); + } +} diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java new file mode 100644 index 000000000..28a5f5638 --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkToolkit.java @@ -0,0 +1,243 @@ +/* + * GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.*; +import java.net.*; +import java.util.*; +import java.awt.datatransfer.*; +import java.awt.image.*; +import java.awt.peer.*; +import java.util.Hashtable; + +/* This class uses a deprecated method java.awt.peer.ComponentPeer.getPeer(). + This merits comment. We are basically calling Sun's bluff on this one. + We think Sun has deprecated it simply to discourage its use as it is + bad programming style. However, we need to get at a component's peer in + this class. If getPeer() ever goes away, we can implement a hash table + that will keep up with every window's peer, but for now this is faster. */ + +public class GtkToolkit extends java.awt.Toolkit +{ + GtkMainThread main; + Hashtable containers = new Hashtable(); + + static + { + System.out.println("loading library"); + System.loadLibrary("gtkpeer"); + } + + public GtkToolkit () + { + main=new GtkMainThread(); + } + + public void beep () + { + } + + public int checkImage (Image image, int width, int height, + ImageObserver observer) + { + return 0; + } + + public Image createImage (ImageProducer producer) + { + return null; + } + + public Image createImage (byte[] imagedata, int imageoffset, + int imagelength) + { + return null; + } + + public ColorModel getColorModel () + { + return null; + } + + public String[] getFontList () + { + return null; + } + + public FontMetrics getFontMetrics (Font font) + { + return null; + } + + public Image getImage (String filename) + { + return null; + } + + public Image getImage (URL url) + { + return null; + } + + public PrintJob getPrintJob (Frame frame, String jobtitle, + Properties props) + { + return null; + } + + public int getScreenResolution() + { + return 0; + } + + public Dimension getScreenSize () + { + return null; + } + + public Clipboard getSystemClipboard() + { + return null; + } + + public boolean prepareImage (Image image, int width, int height, + ImageObserver observer) + { + return false; + } + + public void sync() + { + } + + protected ButtonPeer createButton (Button b) + { + return(new GtkButtonPeer (b,b.getParent().getPeer())); + } + + protected CanvasPeer createCanvas (Canvas c) + { + return null; + } + + protected CheckboxPeer createCheckbox (Checkbox cb) + { + return null; + } + + protected CheckboxMenuItemPeer createCheckboxMenuItem (CheckboxMenuItem cmi) + { + return null; + } + + protected ChoicePeer createChoice (Choice c) + { + return null; + } + + protected DialogPeer createDialog (Dialog d) + { + return(new GtkDialogPeer(d)); + } + + protected FileDialogPeer createFileDialog (FileDialog fd) + { + return(new GtkFileDialogPeer(fd)); + } + + protected FramePeer createFrame (Frame f) + { + return(new GtkFramePeer (f)); + } + + protected LabelPeer createLabel (Label l) + { + return null; + } + + protected ListPeer createList (List l) + { + return null; + } + + protected MenuPeer createMenu (Menu m) + { + return null; + } + + protected MenuBarPeer createMenuBar (MenuBar mb) + { + return null; + } + + protected MenuItemPeer createMenuItem (MenuItem mi) + { + return null; + } + + protected PanelPeer createPanel (Panel p) + { + return (new GtkPanelPeer (p,p.getParent().getPeer())); + } + + protected PopupMenuPeer createPopupMenu (PopupMenu target) + { + return null; + } + + protected ScrollPanePeer createScrollPane (ScrollPane sp) + { + return (new GtkScrollPanePeer (sp,sp.getParent().getPeer())); + } + + protected ScrollbarPeer createScrollbar (Scrollbar sb) + { + return null; + } + + protected TextAreaPeer createTextArea (TextArea ta) + { + return null; + } + + protected TextFieldPeer createTextField (TextField tf) + { + return null; + } + + protected WindowPeer createWindow(Window w) + { + return(new GtkWindowPeer(w)); + } + + protected FontPeer getFontPeer (String name, int style) + { + return null; + } + + protected EventQueue getSystemEventQueueImpl() + { + return null; + } + + protected void loadSystemColors (int[] systemColors) + { + } +} diff --git a/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/gnu/java/awt/peer/gtk/GtkWindowPeer.java new file mode 100644 index 000000000..53211fa8c --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkWindowPeer.java @@ -0,0 +1,67 @@ +/* + * GtkWindowPeer.java -- Implements WindowPeer with GTK + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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.java.awt.peer.gtk; +import java.awt.peer.*; +import java.awt.*; + +public class GtkWindowPeer extends GtkContainerPeer + implements WindowPeer +{ + static final int bogusType=0; + static final int toplevelType=1; + static final int dialogType=2; + static final int popupType=3; + + native void GtkWindowNew(int type, int w, int h); + native void GtkWindowSetTitle(String title); + native void GtkWindowSetPolicy(int shrink, int grow, int autos); + native void GdkWindowLower(); + native void GdkWindowRaise(); + + public GtkWindowPeer(int type, Window w) + { + System.out.println("WindowPeer int cons"); + + /* A bogusType indicates that we should not create a GTK window. */ + + if(type!=bogusType) + { + Dimension d=w.getSize(); + GtkWindowNew(type,d.width,d.height); + } + } + + public GtkWindowPeer(Window w) + { + this(popupType,w); + System.out.println("WindowPeer default cons"); + } + + public void toBack() + { + GdkWindowLower(); + } + + public void toFront() + { + GdkWindowRaise(); + } +} diff --git a/gnu/java/awt/peer/gtk/Makefile b/gnu/java/awt/peer/gtk/Makefile new file mode 100644 index 000000000..ee8036c0f --- /dev/null +++ b/gnu/java/awt/peer/gtk/Makefile @@ -0,0 +1,43 @@ +CC = javac +PACKAGE = gnu.java.awt.peer.gtk + +# This is where the JNI header files get copied to. +# This is in here because it is convenient to me. We can do this another way. +NATIVEDIR = ../../../../../native/$(PACKAGE) + +package := $(subst .,_, $(PACKAGE)) + +objects = GtkButtonPeer.class GtkFileDialogPeer.class GtkPanelPeer.class \ + GtkComponentPeer.class GtkFramePeer.class GtkToolkit.class \ + GtkContainerPeer.class GtkWindowPeer.class GtkDialogPeer.class \ + GtkMainThread.class GtkScrollPanePeer.class \ + GtkGenericPeer.class Test.class +jniclass = GtkButtonPeer GtkFileDialogPeer GtkComponentPeer \ + GtkContainerPeer GtkWindowPeer GtkMainThread \ + GtkScrollPanePeer +jnideps := $(foreach class,$(jniclass),$(package)_$(strip $(class)).h) + +all: Test headers + +Test: $(objects) + +$(objects): %.class: %.java + $(CC) $*.java + +.PHONY: clean +clean: + rm *.class *~ *.h + +headers: $(jnideps) + +#$(jnideps): %.h +# echo $* + +$(jnideps): $(package)_%.h: %.class + javah -jni $(PACKAGE).$* + cp $(package)_$*.h $(NATIVEDIR)/$*.h + +run: Test + java Test + + diff --git a/gnu/java/awt/peer/gtk/Test.java b/gnu/java/awt/peer/gtk/Test.java new file mode 100644 index 000000000..42f14d92c --- /dev/null +++ b/gnu/java/awt/peer/gtk/Test.java @@ -0,0 +1,77 @@ +/* + * Test.java -- Tests the GTK Toolkit + * + * Copyright (c) 1998 Free Software Foundation, Inc. + * Written by James E. Blair <corvus@gnu.org> + * + * 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 + */ + +import java.util.*; +import java.awt.*; +import java.awt.peer.*; + +class Test +{ + public static void main(String args[]) + { + + Properties prop=System.getProperties (); + prop.put ("awt.toolkit","gnu.java.awt.peer.gtk.GtkToolkit"); + System.setProperties (prop); + + Frame f=new Frame(); + + f.setSize(200,200); + + Panel pan=new Panel(); + + Button nb=new Button(); + nb.setLabel("Hello World!"); + + Button nb2=new Button(); + nb2.setLabel("Hello World two!"); + + pan.add(nb); + pan.add(nb2); + f.add(pan,"North"); + + ScrollPane sp=new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); + Panel p=new Panel(); + p.add(new Button("Stop")); + p.add(new Button("evil")); + p.add(new Button("hoarders")); + p.add(new Button("use")); + p.add(new Button("GNU")); + p.add(new Button("Linux")); + + sp.add(p); + f.add(sp,"South"); + + Button eb=new Button(); + eb.setLabel("Hello World east!"); + f.add(eb,"East"); + + Button wb=new Button(); + wb.setLabel("Hello World west!"); + f.add(wb,"West"); + + f.pack(); + f.show(); + sp.setScrollPosition (10,0); + System.out.println("done"); + } +} + |
